This new post is an exception to the rule of commenting on books I have read, or better studied even their code. Since the author is an old colleague and a friend of mine who has helped me in the past, I feel obliged to present his new book, which is currently in preparation. I am afraid I have not studied the whole text, the complete source code is though available; just read some parts of it. Furthermore, enduring for 2 days the second release of JDeveloper 11g was more than just enough for me. IDE XML editing exceptions popping up all the time! Thus, one can certainly say that I am biased and my preview comments are not complete. I can surely live with that and if you can do so too, let us go on with the presentation!
The master chef who authored the recipes offers valuable advice and plenty of examples of source code, unlike other recently published ADF books who seem to target more to project managers; rather avoid exposing the reader to code. The step by step instructions are easy to follow and implement in your own project, saving you time and effort. Furthermore, the text contains quite advanced techniques about refactoring, debugging, profiling, testing and optimizing, fine-tuning and monitoring an ADF application. Such topics are not included even in ADF books written by Oracle stuff. Moreover ignorance of them has been in the past the cause of hiring external consultants and spending all project contingency funds. Nevertheless, the text only mentions using business components as the model technology and not EJBs, neither facelets. Further details about the book one can find here.
Friday, 23 December 2011
Friday, 18 November 2011
Comments on Getting Started With Oracle BPM 11gR1 Suite, by Heidi Buelow, Manoj Das, Manas Deb, Prasen Palvankar, Meera Srinivasan
On the bright side the text is well written in American English. It is well organized, full of helpful images of the older JDeveloper 11.1.1.2 version, tutorials and hands on practice. The setup instructions are accurate, detailed and the full source code is available online too.
On the dark side, the text is full of marketing lecture, whole chapters of promoting the suite, using rather banal and boring expressions of the type: "best of breed software" and so on. What is worse is that instead of warning the reader of potential hazards, which might risk a project's outcome, the authors seem to prefer to conceal the product defects.
Consider for example chapter 10. On page 254 it reads: "The next chapter provides instructions on running and testing the process." But what follows is Using Process Composer, neither running nor testing the application. What is more, a defect is hidden here: if one follows the relevant OTN online tutorials to proceed on his own, one hits on a bug, mentioned here. For the JDeveloper 11.1.1.4 user the process becomes eventually visible in BPM Workspace in Application panel, only if one restarts the application server; which is rather unacceptable for production deployments.
All in all, the book offers a spherical hands on introduction to the BPMN suite, including ADF (sadly only business components, no EJB's) and other relevant technologies by insiders, that is oracle employees. However, a more pragmatic approach to acknowledging defects and providing workarounds, if possible, would be ideal! Furthermore, a word about the myth of developing via the oracle SOA platform, without writing any Java code, which oracle marketing endorsed. After all, Mr Piotr Bazan summarizes so right, what the man in the street thinks about it: "Have to say I've never worked with such buggy tools where every step brings a new problem." Isn't that the reasons that JDeveloper related jobs are so hard to find worldwide on the one hand, and the salaries offered are way more than the average on the other?
On the dark side, the text is full of marketing lecture, whole chapters of promoting the suite, using rather banal and boring expressions of the type: "best of breed software" and so on. What is worse is that instead of warning the reader of potential hazards, which might risk a project's outcome, the authors seem to prefer to conceal the product defects.
Consider for example chapter 10. On page 254 it reads: "The next chapter provides instructions on running and testing the process." But what follows is Using Process Composer, neither running nor testing the application. What is more, a defect is hidden here: if one follows the relevant OTN online tutorials to proceed on his own, one hits on a bug, mentioned here. For the JDeveloper 11.1.1.4 user the process becomes eventually visible in BPM Workspace in Application panel, only if one restarts the application server; which is rather unacceptable for production deployments.
All in all, the book offers a spherical hands on introduction to the BPMN suite, including ADF (sadly only business components, no EJB's) and other relevant technologies by insiders, that is oracle employees. However, a more pragmatic approach to acknowledging defects and providing workarounds, if possible, would be ideal! Furthermore, a word about the myth of developing via the oracle SOA platform, without writing any Java code, which oracle marketing endorsed. After all, Mr Piotr Bazan summarizes so right, what the man in the street thinks about it: "Have to say I've never worked with such buggy tools where every step brings a new problem." Isn't that the reasons that JDeveloper related jobs are so hard to find worldwide on the one hand, and the salaries offered are way more than the average on the other?
Thursday, 15 September 2011
Comments on Spring 3 in action, by Craig Walls
On the bright side, the text is very well written without spelling errors. The author has organized each sequence of paragraphs so well, as neat as a chain having rings following one chapter after another. There are plenty of metaphors, analogies and examples from the daily life to help the reader grasp the Spring fundamentals.
On the dark side, the book has no tutorial format; in other words the reader cannot study the material, by doing some practice. The source code available online is given completed in its final form, as a whole, without the intermediate steps required to take, as presented by each chapter. Thus, if one attempts to run some code, one needs to improvise, there is no guidance as to the libraries necessary to run, other than the exceptions and the search pages found on the internet. As of now JDeveloper only supports Spring version 2.5. If one uses Eclipse Helios and the oracle DB and weblogic packages, one is bound to see errors while installing ie sts tools, since conflicts exist between failing package dependencies:
Your original request has been modified.
"Spring IDE Core (required)" is already installed, so an update will be performed instead.
Cannot complete the install because one or more required items could not be found.
Software being installed: SpringSource Tool Suite (required) 2.6.1.201105091000-RELEASE (com.springsource.sts.feature.group 2.6.1.201105091000-RELEASE)
Missing requirement: com.springsource.sts.ide.ui 2.6.0.201105091000-RELEASE requires 'bundle org.eclipse.ajdt.ui 0.0.0' but it could not be found
Cannot satisfy dependency:
From: SpringSource Tool Suite (required) 2.6.1.201105091000-RELEASE (com.springsource.sts.feature.group 2.6.1.201105091000-RELEASE)
To: com.springsource.sts.ide.ui [2.6.0.201105091000-RELEASE]
All in all, the book seems most suitable to the experienced Spring developer who would like to get informed of the newest advances of the framework, or people who 'd rather just read text, and some code snippets, passively. The ones who learn better by doing would be better off by following first some spring tutorials, about using Eclipse in combination with spring, such as those offered by Rose India.
On the dark side, the book has no tutorial format; in other words the reader cannot study the material, by doing some practice. The source code available online is given completed in its final form, as a whole, without the intermediate steps required to take, as presented by each chapter. Thus, if one attempts to run some code, one needs to improvise, there is no guidance as to the libraries necessary to run, other than the exceptions and the search pages found on the internet. As of now JDeveloper only supports Spring version 2.5. If one uses Eclipse Helios and the oracle DB and weblogic packages, one is bound to see errors while installing ie sts tools, since conflicts exist between failing package dependencies:
Your original request has been modified.
"Spring IDE Core (required)" is already installed, so an update will be performed instead.
Cannot complete the install because one or more required items could not be found.
Software being installed: SpringSource Tool Suite (required) 2.6.1.201105091000-RELEASE (com.springsource.sts.feature.group 2.6.1.201105091000-RELEASE)
Missing requirement: com.springsource.sts.ide.ui 2.6.0.201105091000-RELEASE requires 'bundle org.eclipse.ajdt.ui 0.0.0' but it could not be found
Cannot satisfy dependency:
From: SpringSource Tool Suite (required) 2.6.1.201105091000-RELEASE (com.springsource.sts.feature.group 2.6.1.201105091000-RELEASE)
To: com.springsource.sts.ide.ui [2.6.0.201105091000-RELEASE]
All in all, the book seems most suitable to the experienced Spring developer who would like to get informed of the newest advances of the framework, or people who 'd rather just read text, and some code snippets, passively. The ones who learn better by doing would be better off by following first some spring tutorials, about using Eclipse in combination with spring, such as those offered by Rose India.
Thursday, 8 September 2011
The Java SOA cookbook, by Eben Hewitt
On the bright side the cook book is well written, in American English, with some spelling errors.The error page of the book presents at the moment only unconfirmed errata:
http://oreilly.com/catalog/errataunconfirmed.csp?isbn=9780596520731
The book consists of a series of useful stand alone ...dishes; articles structured like this: specific problem, relevant solution, discussion of java code, criticism and alternatives. The reader may not study the book from the start of the menu to the end page sequentially, one might well consult the book about everyday tasks, ie finding a specific file in jarred libraries in linux, and only that. The ...chef expresses his opinion openly about purity of ingredients, ie using cookies is not ReST style programming, uses mainly open source tools to cook; such as Eclipse, Netbeans, Glassfish, .Net clients and some weblogic, but sadly for oracle fans, no flavour of JDeveloper at all! However, the author is not prejudiced against oracle products, as he praises the enterprise service bus.
On the dark side, some of the recipes are incomplete, probably due to space restrictions, meaning that sometimes the input to a servlet is not dynamic; fed by a database but static, hard coded values in a constructor of a convenience class. Moreover, the source code for each chapter offered on line is all pasted in a single file, not separate class files, thus finding the snippet you need can be time consuming.
All in all, this is a very useful cookbook, presenting advanced java version 1.6 code, practical solutions to real life problems, excluding design patterns. It offers plenty of food for thought, as it tries to answer a daily question asked by the vast majority of women, developers and chefs for centuries: what shall we cook today? Bon Appetit ladies and gentlemen!
http://oreilly.com/catalog/errataunconfirmed.csp?isbn=9780596520731
The book consists of a series of useful stand alone ...dishes; articles structured like this: specific problem, relevant solution, discussion of java code, criticism and alternatives. The reader may not study the book from the start of the menu to the end page sequentially, one might well consult the book about everyday tasks, ie finding a specific file in jarred libraries in linux, and only that. The ...chef expresses his opinion openly about purity of ingredients, ie using cookies is not ReST style programming, uses mainly open source tools to cook; such as Eclipse, Netbeans, Glassfish, .Net clients and some weblogic, but sadly for oracle fans, no flavour of JDeveloper at all! However, the author is not prejudiced against oracle products, as he praises the enterprise service bus.
On the dark side, some of the recipes are incomplete, probably due to space restrictions, meaning that sometimes the input to a servlet is not dynamic; fed by a database but static, hard coded values in a constructor of a convenience class. Moreover, the source code for each chapter offered on line is all pasted in a single file, not separate class files, thus finding the snippet you need can be time consuming.
All in all, this is a very useful cookbook, presenting advanced java version 1.6 code, practical solutions to real life problems, excluding design patterns. It offers plenty of food for thought, as it tries to answer a daily question asked by the vast majority of women, developers and chefs for centuries: what shall we cook today? Bon Appetit ladies and gentlemen!
Tuesday, 23 August 2011
Providing the model layer for a ReSTful web service
In this new article we shall discuss about implementing the model layer for a simple REST style web service, presented in a book authored by Eben Hewitt, called SOA Cookbook. In example 8-1 the author presents a plain servlet which draws hard coded values from a pojo called ProductCatalog. The XML values returned in the browser are the ones that are statically hard coded in the pojo's constructor. The original idea to extend the example, was to provide dynamic data from querying a database. Providing an entity bean for the Product and a stateless ejb 3 as a facade to query, seemed as a straightforward suggestion. As far as java 1.6 and JDeveloper 11.1.2 was concerned, that was merely wishful thinking!
The first exception deprived me of using directly the entity manager to access the db:
com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
javax.persistence.EntityManager is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at javax.persistence.EntityManager
at public javax.persistence.EntityManager com.soacookbook.ProductCatalog.entityManager
at com.soacookbook.ProductCatalog
javax.persistence.EntityManager does not have a no-arg default constructor.
this problem is related to the following location:
at javax.persistence.EntityManager
at public javax.persistence.EntityManager com.soacookbook.ProductCatalog.entityManager
at com.soacookbook.ProductCatalog
The most I could do this way was to access the db using a EJB client. The EJB code won't be displayed for brevity! Although I have received a warning that samplecode.oracle.com in its current form is being decommissioned on November 1st, 2011, the full source code can be found here, and is given as usual, without any guarantee of support, etc.
The view layer for now, is to remain as is!
The original code for the servlet from the aforementioned book, which was to remain intact, follows:
package com.soacookbook.web;
import com.soacookbook.ProductCatalog;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
public class SimpleRestServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/xml; charset=UTF-8";
private static final String DOC_TYPE = null;
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public SimpleRestServlet() {
super();
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
System.out.println("DoGet invoked on RESTful service.");
ProductCatalog catalog = new ProductCatalog();
Source xmlSource = asXml(catalog);
ServletOutputStream out = response.getOutputStream();
response.setContentType("text/xml");
StreamResult st = new StreamResult(out);
try {
Transformer t = TransformerFactory.newInstance().newTransformer();
t.transform(xmlSource, st);
} catch (Exception e) {
throw new ServletException(e);
}
System.out.println("All done.");
}
private static Source asXml(ProductCatalog pc) throws ServletException {
System.out.println("Marshalling...");
Source source = null;
Document doc = null;
try {
JAXBContext ctx = JAXBContext.newInstance(ProductCatalog.class);
Marshaller m = ctx.createMarshaller();
DocumentBuilder parser =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = parser.newDocument();
System.out.println("Products=" + pc);
m.marshal(pc, doc);
System.out.println("Marshalled catalog to XML.");
} catch (JAXBException je) {
throw new ServletException(je);
} catch (ParserConfigurationException pce) {
throw new ServletException(pce);
}
source = new DOMSource(doc);
System.out.println("Returning XML source.");
return source;
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
doGet(request, response);
}
}
The model layer with the dynamic query:
The table script as generated by JDeveloper 11.1.2:
CREATE TABLE "FUSIONEJB3"."PRODUCT"
(
"ID" VARCHAR2(255 BYTE) NOT NULL ENABLE,
"PRICE" NUMBER(19,4),
"NAME" VARCHAR2(255 BYTE),
PRIMARY KEY ("ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ENABLE
)
SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
(
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT
)
TABLESPACE "USERS" ;
Impressive, isn't it? Next populate the table with sample data.
REM INSERTING into PRODUCT
Insert into PRODUCT (ID,PRICE,NAME) values ('GermanBonds',50,'Euro BRD Bonds');
Insert into PRODUCT (ID,PRICE,NAME) values ('USShares ',20,'US dollar mutual fund common shares');
The Product entity follows next:
package com.soacookbook.entities;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.xml.bind.annotation.XmlType;
@XmlType
@Entity
@NamedQueries( { @NamedQuery(name = "Product.findAll",
query = "select o from Product o") })
public class Product implements Serializable {
private String id;
private String name;
private BigDecimal price;
public Product() {
}
public Product(String id, String name, BigDecimal price) {
this.id = id;
this.name = name;
this.price = price;
}
@Id
@Column(nullable = false)
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
}
Although the first thought was to preserve the original working source code provided by the book author, some modifications were necessary. The final form of ProductCatalog follows:
package com.soacookbook;
import com.soacookbook.client.ProductCatalogSEClient;
import com.soacookbook.entities.Product;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class ProductCatalog {
private List<Product> products;
public ProductCatalog() {
super();
ProductCatalogSEClient productCatalogSEClient = new ProductCatalogSEClient();
products = productCatalogSEClient.getAllProducts();
}
//Don't you dare, no other getter there!
public void setProducts(List<Product> products) {
this.products = products;
}
}
Had you dared to generate an accessor, this would be the exception:
Application-managed EntityManagers, outside the Java EE container, save the day!
The first successful attempt to access the db was via the Java SE client:
package com.soacookbook.client;
import com.soacookbook.ProductCatalog;
import com.soacookbook.entities.Product;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
public class ProductCatalogSEClient {
private EntityManager entityManager;
private EntityManagerFactory entityManagerFactory;
private Hashtable emProps = new Hashtable();
public ProductCatalogSEClient() {
super();
}
public static void main(String[] args) {
ProductCatalogSEClient productCatalogSEClient = new ProductCatalogSEClient();
List<Product> products = productCatalogSEClient.getAllProducts();
Iterator i = products.iterator();
while (i.hasNext())
{
Product product = (Product) i.next();
System.out.println("Id:"+ product.getId() +" Name:"+product.getName()
+ " price " + product.getPrice());
}
}
public List<Product> getAllProducts(){
List<Product> products= null;
try {
entityManagerFactory =
Persistence.createEntityManagerFactory("JavaSEClient");
// not the same with example8-1 !
entityManager = entityManagerFactory.createEntityManager(emProps);
Query query = entityManager.createNamedQuery("Product.findAll");
products=query.getResultList();
} catch (Exception e) {
// TODO: Add catch code
e.printStackTrace();
} finally {
entityManager.close();
entityManagerFactory.close();
}
return products;
}
}
A second introduction to EE is superfluous: no more user credentials please!
However, if one copied the working properties for the SE client and pasted to the EE edition unit:
Internal Exception: java.sql.SQLException: User: fusionEJB3, failed to be authenticated.
Error Code: 0
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:309)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:138)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:94)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
The correct persistence.xml has no user credentials for the EJB client, unlike the java SE one:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="1.0">
<persistence-unit name="example8-1">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/fusionEJB3</jta-data-source>
<class>com.soacookbook.entities.Product</class>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="eclipselink.target-database" value="Oracle"/>
<property name="eclipselink.logging.level" value="ALL"/>
</properties>
</persistence-unit>
<persistence-unit name="JavaSEClient" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.soacookbook.entities.Product</class>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="eclipselink.target-database" value="Oracle"/>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
<property name="javax.persistence.jdbc.password" value="fusionEJB3"/>
<property name="javax.persistence.jdbc.user" value="fusionEJB3"/>
<property name="eclipselink.logging.level" value="ALL"/>
<property name="eclipselink.orm.validate.schema" value="true"/>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@hera:1521:orcl"/>
</properties>
</persistence-unit>
</persistence>
Finally, if one types: http://localhost:7101/example8-1/Products
the XML datagram appears:
<productCatalog>
<products><id>GermanBonds</id><name>Euro BRD Bonds</name><price>50</price></products>
<products><id>USShares </id><name>US dollar mutual fund common shares</name><price>20</price></products>
</productCatalog>
Making use of EJB 3.1 features via Netbeans 7.0.1
If one has the option of using the latest jdk 1.7, things can be far less complicated:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.soacookbook.facade;
import com.soacookbook.entities.Product;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Nick
*/
@XmlRootElement
@Stateless
@LocalBean
public class ProductCatalog implements Serializable {
private static final long serialVersionUID = 1L;
@PersistenceContext(unitName="chapter8-1-ejbPU")
private EntityManager em;
private List<Product> products;
public List<Product> getProducts() {
return products;
}
public void setProducts(List<Product> products) {
this.products = products;
}
public List<Product> getAllProducts() {
Query query = em.createNamedQuery("Product.findAll");
products = new ArrayList<Product>();
//logger.info("Query max results: "+ query.getMaxResults());
products = query.getResultList();
return products;
}
}
As far as the servlet is concerned, one may now use dependency injection:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.soacookbook.web;
import com.soacookbook.facade.ProductCatalog;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
/**
* @date Aug 26, 2011
* @author Nick
*/
public class SimpleRestServlet extends HttpServlet {
@EJB
private ProductCatalog catalog;
public void init(ServletConfig config) throws ServletException {
//try {
super.init(config);
/*Context context = new InitialContext();
catalog =
(ProductCatalog) context.lookup("java:global/chapter8-1/chapter8-1-ejb/ProductCatalog");*/
catalog.getAllProducts();
/* } catch (NamingException ex) {
Logger.getLogger(SimpleRestServlet.class.getName()).log(Level.SEVERE, null, ex);
}*/
}
public SimpleRestServlet() {
super();
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
try {
System.out.println("DoGet invoked on RESTful service.");
Source xmlSource = asXml(catalog);
ServletOutputStream out = response.getOutputStream();
response.setContentType("text/xml");
StreamResult st = new StreamResult(out);
try {
javax.xml.transform.Transformer t = TransformerFactory.newInstance().newTransformer();
t.transform(xmlSource, st);
} catch (Exception e) {
throw new ServletException(e);
}
System.out.println("All done.");
} catch (Exception ex) {
Logger.getLogger(SimpleRestServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
private static Source asXml(ProductCatalog pc) throws ServletException {
System.out.println("Marshalling...");
Source source = null;
Document doc = null;
try {
JAXBContext ctx = JAXBContext.newInstance(ProductCatalog.class);
Marshaller m = ctx.createMarshaller();
DocumentBuilder parser =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = parser.newDocument();
System.out.println("Products=" + pc);
m.marshal(pc, doc);
System.out.println("Marshalled catalog to XML.");
} catch (JAXBException je) {
throw new ServletException(je);
} catch (ParserConfigurationException pce) {
throw new ServletException(pce);
}
source = new DOMSource(doc);
System.out.println("Returning XML source.");
return source;
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
doGet(request, response);
}
}
The first exception deprived me of using directly the entity manager to access the db:
com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
javax.persistence.EntityManager is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at javax.persistence.EntityManager
at public javax.persistence.EntityManager com.soacookbook.ProductCatalog.entityManager
at com.soacookbook.ProductCatalog
javax.persistence.EntityManager does not have a no-arg default constructor.
this problem is related to the following location:
at javax.persistence.EntityManager
at public javax.persistence.EntityManager com.soacookbook.ProductCatalog.entityManager
at com.soacookbook.ProductCatalog
The most I could do this way was to access the db using a EJB client. The EJB code won't be displayed for brevity! Although I have received a warning that samplecode.oracle.com in its current form is being decommissioned on November 1st, 2011, the full source code can be found here, and is given as usual, without any guarantee of support, etc.
The view layer for now, is to remain as is!
The original code for the servlet from the aforementioned book, which was to remain intact, follows:
package com.soacookbook.web;
import com.soacookbook.ProductCatalog;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
public class SimpleRestServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/xml; charset=UTF-8";
private static final String DOC_TYPE = null;
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public SimpleRestServlet() {
super();
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
System.out.println("DoGet invoked on RESTful service.");
ProductCatalog catalog = new ProductCatalog();
Source xmlSource = asXml(catalog);
ServletOutputStream out = response.getOutputStream();
response.setContentType("text/xml");
StreamResult st = new StreamResult(out);
try {
Transformer t = TransformerFactory.newInstance().newTransformer();
t.transform(xmlSource, st);
} catch (Exception e) {
throw new ServletException(e);
}
System.out.println("All done.");
}
private static Source asXml(ProductCatalog pc) throws ServletException {
System.out.println("Marshalling...");
Source source = null;
Document doc = null;
try {
JAXBContext ctx = JAXBContext.newInstance(ProductCatalog.class);
Marshaller m = ctx.createMarshaller();
DocumentBuilder parser =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = parser.newDocument();
System.out.println("Products=" + pc);
m.marshal(pc, doc);
System.out.println("Marshalled catalog to XML.");
} catch (JAXBException je) {
throw new ServletException(je);
} catch (ParserConfigurationException pce) {
throw new ServletException(pce);
}
source = new DOMSource(doc);
System.out.println("Returning XML source.");
return source;
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
doGet(request, response);
}
}
The model layer with the dynamic query:
The table script as generated by JDeveloper 11.1.2:
CREATE TABLE "FUSIONEJB3"."PRODUCT"
(
"ID" VARCHAR2(255 BYTE) NOT NULL ENABLE,
"PRICE" NUMBER(19,4),
"NAME" VARCHAR2(255 BYTE),
PRIMARY KEY ("ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ENABLE
)
SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
(
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT
)
TABLESPACE "USERS" ;
Impressive, isn't it? Next populate the table with sample data.
REM INSERTING into PRODUCT
Insert into PRODUCT (ID,PRICE,NAME) values ('GermanBonds',50,'Euro BRD Bonds');
Insert into PRODUCT (ID,PRICE,NAME) values ('USShares ',20,'US dollar mutual fund common shares');
The Product entity follows next:
package com.soacookbook.entities;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.xml.bind.annotation.XmlType;
@XmlType
@Entity
@NamedQueries( { @NamedQuery(name = "Product.findAll",
query = "select o from Product o") })
public class Product implements Serializable {
private String id;
private String name;
private BigDecimal price;
public Product() {
}
public Product(String id, String name, BigDecimal price) {
this.id = id;
this.name = name;
this.price = price;
}
@Id
@Column(nullable = false)
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
}
Some more modifications of the book code:
Although the first thought was to preserve the original working source code provided by the book author, some modifications were necessary. The final form of ProductCatalog follows:
package com.soacookbook;
import com.soacookbook.client.ProductCatalogSEClient;
import com.soacookbook.entities.Product;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class ProductCatalog {
private List<Product> products;
public ProductCatalog() {
super();
ProductCatalogSEClient productCatalogSEClient = new ProductCatalogSEClient();
products = productCatalogSEClient.getAllProducts();
}
//Don't you dare, no other getter there!
public void setProducts(List<Product> products) {
this.products = products;
}
}
Had you dared to generate an accessor, this would be the exception:
com.sun.xml.bind.v2.runtime.IllegalAnnotationsException:
1 counts of IllegalAnnotationExceptions
Class has two properties of the same name "products"
this problem is related to the following location:at
public java.util.List com.soacookbook.ProductCatalog.getProducts()
at com.soacookbook.ProductCatalog
this problem is related to the following location:at
public java.util.List com.soacookbook.ProductCatalog.products
at com.soacookbook.ProductCatalog
Application-managed EntityManagers, outside the Java EE container, save the day!
The first successful attempt to access the db was via the Java SE client:
package com.soacookbook.client;
import com.soacookbook.ProductCatalog;
import com.soacookbook.entities.Product;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
public class ProductCatalogSEClient {
private EntityManager entityManager;
private EntityManagerFactory entityManagerFactory;
private Hashtable emProps = new Hashtable();
public ProductCatalogSEClient() {
super();
}
public static void main(String[] args) {
ProductCatalogSEClient productCatalogSEClient = new ProductCatalogSEClient();
List<Product> products = productCatalogSEClient.getAllProducts();
Iterator i = products.iterator();
while (i.hasNext())
{
Product product = (Product) i.next();
System.out.println("Id:"+ product.getId() +" Name:"+product.getName()
+ " price " + product.getPrice());
}
}
public List<Product> getAllProducts(){
List<Product> products= null;
try {
entityManagerFactory =
Persistence.createEntityManagerFactory("JavaSEClient");
// not the same with example8-1 !
entityManager = entityManagerFactory.createEntityManager(emProps);
Query query = entityManager.createNamedQuery("Product.findAll");
products=query.getResultList();
} catch (Exception e) {
// TODO: Add catch code
e.printStackTrace();
} finally {
entityManager.close();
entityManagerFactory.close();
}
return products;
}
}
A second introduction to EE is superfluous: no more user credentials please!
However, if one copied the working properties for the SE client and pasted to the EE edition unit:
Internal Exception: java.sql.SQLException: User: fusionEJB3, failed to be authenticated.
Error Code: 0
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:309)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:138)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:94)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
The correct persistence.xml has no user credentials for the EJB client, unlike the java SE one:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="1.0">
<persistence-unit name="example8-1">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/fusionEJB3</jta-data-source>
<class>com.soacookbook.entities.Product</class>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="eclipselink.target-database" value="Oracle"/>
<property name="eclipselink.logging.level" value="ALL"/>
</properties>
</persistence-unit>
<persistence-unit name="JavaSEClient" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.soacookbook.entities.Product</class>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="eclipselink.target-database" value="Oracle"/>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
<property name="javax.persistence.jdbc.password" value="fusionEJB3"/>
<property name="javax.persistence.jdbc.user" value="fusionEJB3"/>
<property name="eclipselink.logging.level" value="ALL"/>
<property name="eclipselink.orm.validate.schema" value="true"/>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@hera:1521:orcl"/>
</properties>
</persistence-unit>
</persistence>
Finally, if one types: http://localhost:7101/example8-1/Products
the XML datagram appears:
<productCatalog>
<products><id>GermanBonds</id><name>Euro BRD Bonds</name><price>50</price></products>
<products><id>USShares </id><name>US dollar mutual fund common shares</name><price>20</price></products>
</productCatalog>
Making use of EJB 3.1 features via Netbeans 7.0.1
If one has the option of using the latest jdk 1.7, things can be far less complicated:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.soacookbook.facade;
import com.soacookbook.entities.Product;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Nick
*/
@XmlRootElement
@Stateless
@LocalBean
public class ProductCatalog implements Serializable {
private static final long serialVersionUID = 1L;
@PersistenceContext(unitName="chapter8-1-ejbPU")
private EntityManager em;
private List<Product> products;
public List<Product> getProducts() {
return products;
}
public void setProducts(List<Product> products) {
this.products = products;
}
public List<Product> getAllProducts() {
Query query = em.createNamedQuery("Product.findAll");
products = new ArrayList<Product>();
//logger.info("Query max results: "+ query.getMaxResults());
products = query.getResultList();
return products;
}
}
As far as the servlet is concerned, one may now use dependency injection:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.soacookbook.web;
import com.soacookbook.facade.ProductCatalog;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
/**
* @date Aug 26, 2011
* @author Nick
*/
public class SimpleRestServlet extends HttpServlet {
@EJB
private ProductCatalog catalog;
public void init(ServletConfig config) throws ServletException {
//try {
super.init(config);
/*Context context = new InitialContext();
catalog =
(ProductCatalog) context.lookup("java:global/chapter8-1/chapter8-1-ejb/ProductCatalog");*/
catalog.getAllProducts();
/* } catch (NamingException ex) {
Logger.getLogger(SimpleRestServlet.class.getName()).log(Level.SEVERE, null, ex);
}*/
}
public SimpleRestServlet() {
super();
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
try {
System.out.println("DoGet invoked on RESTful service.");
Source xmlSource = asXml(catalog);
ServletOutputStream out = response.getOutputStream();
response.setContentType("text/xml");
StreamResult st = new StreamResult(out);
try {
javax.xml.transform.Transformer t = TransformerFactory.newInstance().newTransformer();
t.transform(xmlSource, st);
} catch (Exception e) {
throw new ServletException(e);
}
System.out.println("All done.");
} catch (Exception ex) {
Logger.getLogger(SimpleRestServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
private static Source asXml(ProductCatalog pc) throws ServletException {
System.out.println("Marshalling...");
Source source = null;
Document doc = null;
try {
JAXBContext ctx = JAXBContext.newInstance(ProductCatalog.class);
Marshaller m = ctx.createMarshaller();
DocumentBuilder parser =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = parser.newDocument();
System.out.println("Products=" + pc);
m.marshal(pc, doc);
System.out.println("Marshalled catalog to XML.");
} catch (JAXBException je) {
throw new ServletException(je);
} catch (ParserConfigurationException pce) {
throw new ServletException(pce);
}
source = new DOMSource(doc);
System.out.println("Returning XML source.");
return source;
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
doGet(request, response);
}
}
The morale of the story
Automatically generated code is not certain to be error free! It could cause run time exceptions in one IDE and specific application servers, ie Weblogic 10.3.5. In addition, migration to newer jdk versions are advantageous in most cases.
Even though some resources, excellent books, or tutorials such as those from the open source or Sun Netbeans community, are highly advanced, demonstrating the latest technology quite well, some are still incomplete. Given that oracle bred java EE developers have a different philosophy, i.e. are accustomed to setup db access as a first step, it is obvious that there is a huge gap in the way of thinking, between the two communities. This gap is for Sun Oracle press, university, marketing, or whatever other department to bridge. Until then, all incomplete open source recipes are candidates for some kind of integration coding exercise, or maybe not?
Automatically generated code is not certain to be error free! It could cause run time exceptions in one IDE and specific application servers, ie Weblogic 10.3.5. In addition, migration to newer jdk versions are advantageous in most cases.
Thursday, 28 July 2011
Processing XML with JDeveloper 11g, by Deepak Vohra
On the bright side, the text is well written, showing step by step instructions how to proceed with coding in each autonomous chapter. Each code snippet is explained line by line. Some basics of xpath and xquery are presented as well. What is surprising is an introduction to Berkeley DB XML in chapter 13: Storing XML in Oracle Berkeley DB XML. One can find more information on the internet documentation. For a comparison of Oracle Berkeley DB and relational database systems, refer to 'A Comparison of Oracle Berkeley DB and Relational Database Management Systems'. As far as trying the book source code is concerned, in chapter 6 about JSTL XML tag library, the code example runs in the Glassfish, but not in the Weblogic application server; probably due to an older library version than xalan-j_2_7_1 jar. Needless to say there were incompatibilities found: the windows version does not run as is, in windows 7 64 bit, it needs rebuilding via a C++ IDE such as .Net; the embebded weblogic server does not start after setting up the Berkeley DB XML: I quote:
Berkeley DB XML requires some Windows environment variables (CLASSPATH and PATH) to be modified. The following Oracle Berkeley DB XML JAR files get added to the CLASSPATH environment variable:
C:\Program Files\Oracle\Berkeley DB XML 2.4.13\jar\dbxmlexamples.jar;
C:\Program Files\Oracle\Berkeley DB XML 2.4.13\jar\dbxml.jar;
C:\Program Files\Oracle\Berkeley DB XML 2.4.13\jar\db.jar
The following bin directory gets added to the PATH environment variable:
C:\Program Files\Oracle\Berkeley DB XML 2.4.13\bin
On the dark side, the book is rather old, some code about converting XML to excel spreadsheets via poi in chapter12 for example, is deprecated, the version of the Oracle Berkeley DB mentioned is 2.4.13 and so on. No errata page is available on the internet. Moreover, it is unusual to find in a java class source file, two or more classes defined together, as in the following code snippet for DOM3Filter.java:
package dom3ls;
import org.w3c.dom.*;
import org.w3c.dom.ls.*;
import oracle.xml.parser.v2.*;
import org.w3c.dom.traversal.*;
import java.io.*;
public class DOM3Filter {
public void filter() {
try {
DOMImplementationLS impl = new XMLDOMImplementation();
LSParser parser =
impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS,
null);
InputFilter inputFilter = new InputFilter();
parser.setFilter(inputFilter);
Document document =
parser.parseURI("file://c:/DOM3.0/catalog.xml");
LSSerializer domWriter = impl.createLSSerializer();
OutputFilter outputFilter = new OutputFilter();
domWriter.setFilter(outputFilter);
LSOutput lsOutput = impl.createLSOutput();
OutputStream outputStream =
new FileOutputStream(new File("filter-output.xml"));
lsOutput.setByteStream(outputStream);
domWriter.write(document, lsOutput);
} catch (IOException e) {
System.out.println("IOException " + e.getMessage());
}
catch (DOMException e) {
System.out.println("DOMException " + e.getMessage());
}
}
public static void main(String[] args) {
DOM3Filter dom3Filter = new DOM3Filter();
dom3Filter.filter();
}
private class InputFilter implements LSParserFilter {
public short acceptNode(Node node) {
return NodeFilter.FILTER_ACCEPT;
}
public int getWhatToShow() {
return NodeFilter.SHOW_ALL;
}
public short startElement(Element element) {
System.out.println("Element Parsed " + element.getTagName());
return NodeFilter.FILTER_ACCEPT;
}
}
private class OutputFilter implements LSSerializerFilter {
public short acceptNode(Node node) {
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
if (element.getTagName().equals("journal"))
if (element.getAttribute("date").equals("May-June 2008"))
return NodeFilter.FILTER_REJECT;
}
return NodeFilter.FILTER_ACCEPT;
}
public int getWhatToShow() {
return NodeFilter.SHOW_ALL;
}
}
}
All in all, the book is rather old, but its structured, step by step approach makes it a good introduction to processing XML. The vast majority of its source code is more or less reusable.Thus, it could serve well as an introduction to XML.
Thursday, 30 June 2011
Vacation in Agioi Apostoloi, Kalamos
In this new post a destination near to Athens will be briefly presented as an alternative to a daily excursion to the provinces of Attica; far away of the hectic life and the demonstrations of the busy city centre.
The place is called Kalamos, its port Ag.Apostoloi (the greek for Saint Apostles) and its distance from Athens centre is less than 50 Km, roughly an hour's journey by private car or public, fully air conditioned, KTEL bus. You can find more about the geographical position here:
http://www.panoramio.com/photo/8841766 I think the images of the sea speak for themselves.
As far as accommodation is concerned, there are two hotels in the Agona area by the beach: the newer and therefore more expensive Delphinia (Greek for dolphins) and the older but cheaper Kalamos Beach, which now mostly hosts tourists groups from Russia and the eastern Europe. There also are plenty of rooms, or flats to let by the seaside, in addition to whole houses for rent. Prices are as low as 270 euros per month for a 100 square meters house. Many German pensioners live in the Agona area all the year round.
During the winter, there might be so heavy snowfall that the landscape resembles that of the Swiss alps. That might happen once in five years. In such case, no traffic is allowed due to bad weather, one must have made beforehand food, fuel provisions to last for a period of a few days. Having a power generator in case of a power outage or some extra wood logs for the fireplace is always a good idea. I am sure the locals will be suitable to offer you advice or help during the winter season.
When the weather is good, besides swimming, fishing or chatting with the anglers, sailing, sunbathing and enjoying the clean sea, one could visit the woods, the vineyards to consult with the expert wine makers, go sightseeing to the nearby site of Amphiarion which once served as an oracle, the monasteries, Oropos town or the island of Evia and so on. Finally, a word of caution: during the hot weekends, especially on Sundays; it is very crowded, there is difficulty in driving a private car in such narrow streets. Thus, during the weekend getting the bus is the ideal suggestion, for trouble free amusement. It is fully recommended to visit this place during working week days, for having your share of carefree fun in the sun!
Further references:
http://www.athensguide.org/blog/2008/11/ktel.html
A view of the sea from the Panorama area |
The place is called Kalamos, its port Ag.Apostoloi (the greek for Saint Apostles) and its distance from Athens centre is less than 50 Km, roughly an hour's journey by private car or public, fully air conditioned, KTEL bus. You can find more about the geographical position here:
http://www.panoramio.com/photo/8841766 I think the images of the sea speak for themselves.
A view from Kalamos Beach hotel |
As far as accommodation is concerned, there are two hotels in the Agona area by the beach: the newer and therefore more expensive Delphinia (Greek for dolphins) and the older but cheaper Kalamos Beach, which now mostly hosts tourists groups from Russia and the eastern Europe. There also are plenty of rooms, or flats to let by the seaside, in addition to whole houses for rent. Prices are as low as 270 euros per month for a 100 square meters house. Many German pensioners live in the Agona area all the year round.
During the winter, there might be so heavy snowfall that the landscape resembles that of the Swiss alps. That might happen once in five years. In such case, no traffic is allowed due to bad weather, one must have made beforehand food, fuel provisions to last for a period of a few days. Having a power generator in case of a power outage or some extra wood logs for the fireplace is always a good idea. I am sure the locals will be suitable to offer you advice or help during the winter season.
Landscape during winter |
When the weather is good, besides swimming, fishing or chatting with the anglers, sailing, sunbathing and enjoying the clean sea, one could visit the woods, the vineyards to consult with the expert wine makers, go sightseeing to the nearby site of Amphiarion which once served as an oracle, the monasteries, Oropos town or the island of Evia and so on. Finally, a word of caution: during the hot weekends, especially on Sundays; it is very crowded, there is difficulty in driving a private car in such narrow streets. Thus, during the weekend getting the bus is the ideal suggestion, for trouble free amusement. It is fully recommended to visit this place during working week days, for having your share of carefree fun in the sun!
Further references:
http://www.athensguide.org/blog/2008/11/ktel.html
Friday, 10 June 2011
Comments on EJB 3.0 Database Persistence with Oracle Fusion Middleware 11g, by Deepak Vohra
On the bright side, the text is well written, providing a brief synopsis of the ejb 3, (not 3.01 which is the current) background and following a block by block explanation of each snippet of source code used. Apart from using the oracle db, the text presents an example of MySql db server and Eclipse too. The applications are usually tested and deployed to the Weblogic server version 10.1.x.x. g via ant scripts.
On the dark side the source code consists of orphan files, neither ears, nor whole JDeveloper workspaces; as it is usual in oracle university courses solutions. Moreover, the code seems to be what is printed in the text and has some errors. For example: in chapter 2, on page 33 the modified ejb-jar.xml deployment descriptor reads like this:
<ejb-ql>
<![CDATA[SELECT OBJECT(a) FROM CatalogBean AS a WHERE a.catalogId = ?1
</ejb-ql>
meaning that the <![CDATA[ tag is not closed properly, as it is easily understood when these lines are pasted to the editor window. In chapter 4,in CatalogTestSessionEJBBean the method is not persistEntity(catalog), but persistCatalog(catalog) and so on. After some investigation or debugging, one persistent reader will probably end up with a working application. A mistake which occurs numerous times is the number 2 missing from any sql statement with a VARCHAR2 datatype. Therefore, it seems that gathering the source code of the book was maybe only an afterthought. Furthermore, some screenshots and relevant text instructions, apply only to older versions of JDeveloper, other than the current 11.1.2. More advanced topics such as tuning, are beyond the scope of this book.
All in all, the text could be a valuable introduction to combining ejb 3 and fusion for JDeveloper funs. This is recommended for zealots of ADF business components, in order to compare both model tier technologies, especially performance. As it was written back in 2010, ejb technology has somehow superceded it. Thus, if you are a Netbeans fun, you will probably think that is an obsolete book. However, the current JDeveloper version does not seem to support ejb 3.01, so to loyal JDevepoper fanatics, it won't make any difference at all!
On the dark side the source code consists of orphan files, neither ears, nor whole JDeveloper workspaces; as it is usual in oracle university courses solutions. Moreover, the code seems to be what is printed in the text and has some errors. For example: in chapter 2, on page 33 the modified ejb-jar.xml deployment descriptor reads like this:
<ejb-ql>
<![CDATA[SELECT OBJECT(a) FROM CatalogBean AS a WHERE a.catalogId = ?1
</ejb-ql>
meaning that the <![CDATA[ tag is not closed properly, as it is easily understood when these lines are pasted to the editor window. In chapter 4,in CatalogTestSessionEJBBean the method is not persistEntity(catalog), but persistCatalog(catalog) and so on. After some investigation or debugging, one persistent reader will probably end up with a working application. A mistake which occurs numerous times is the number 2 missing from any sql statement with a VARCHAR2 datatype. Therefore, it seems that gathering the source code of the book was maybe only an afterthought. Furthermore, some screenshots and relevant text instructions, apply only to older versions of JDeveloper, other than the current 11.1.2. More advanced topics such as tuning, are beyond the scope of this book.
All in all, the text could be a valuable introduction to combining ejb 3 and fusion for JDeveloper funs. This is recommended for zealots of ADF business components, in order to compare both model tier technologies, especially performance. As it was written back in 2010, ejb technology has somehow superceded it. Thus, if you are a Netbeans fun, you will probably think that is an obsolete book. However, the current JDeveloper version does not seem to support ejb 3.01, so to loyal JDevepoper fanatics, it won't make any difference at all!
Monday, 30 May 2011
Comments on Oracle Performance Survival Guide: A Systematic Approach to Database Optimization, by Guy Harrison
On the bright side, this is one of the easiest review for me to write, since there are so many readers of the several editions of the book, that I shall mainly copy and paste some lines of reviews I agree to. Thus, I quote: " This book is an encyclopedic overview of all aspects of Oracle performance. Mr. Harrison takes a layered approach, starting at the top with application and data model design where the focus is minimizing the demand for database resources. He then moves down into database code internals, where the focus is maximizing concurrency through reduction of lock, latch, and mutex contention. The next step is to optimize memory usage to minimize the need for physical IO. Finally, he moves to the bottom layer, where the focus is on optimizing physical IO at the disk layer.
Each of these layers is worthy of its own book, so to combine all these topics in a single book is an ambitious goal. Indeed, experienced readers will often want a bit more detail, or wonder why their favorite optimization was not mentioned. However, Mr. Harrison strikes a very good balance between depth and coverage. He also provides a very useful bibliography, including the Oracle documentation, books, and Internet sites and blogs.
For each chapter, Mr. Harrison provides extraordinarily clear, concise, and helpful introductions and summaries. He also uses boxed borders to highlights particularly important points within the text. One can learn a great deal by simply reading these summaries and boxed items, and these can also be used to help the reader find relevant sections, which is especially valuable in a book of this length.
This book is not the last word on SQL tuning, optimizer internals, Oracle troubleshooting, the SGA, nor latch contention. However, its coherent approach, useful summaries and highlights, and efficient organization, make it a valuable and essential guide to anyone wishing to expand their Oracle performance skill set.
The target audience includes both application developers and DBAs. It covers 10g, 11g, 11gR2, with context from 8i and 9i ." The latter is true for the newest edition of course! Furthermore, the full source code is available, as well as an errata page on the author's site.
Each of these layers is worthy of its own book, so to combine all these topics in a single book is an ambitious goal. Indeed, experienced readers will often want a bit more detail, or wonder why their favorite optimization was not mentioned. However, Mr. Harrison strikes a very good balance between depth and coverage. He also provides a very useful bibliography, including the Oracle documentation, books, and Internet sites and blogs.
For each chapter, Mr. Harrison provides extraordinarily clear, concise, and helpful introductions and summaries. He also uses boxed borders to highlights particularly important points within the text. One can learn a great deal by simply reading these summaries and boxed items, and these can also be used to help the reader find relevant sections, which is especially valuable in a book of this length.
This book is not the last word on SQL tuning, optimizer internals, Oracle troubleshooting, the SGA, nor latch contention. However, its coherent approach, useful summaries and highlights, and efficient organization, make it a valuable and essential guide to anyone wishing to expand their Oracle performance skill set.
The target audience includes both application developers and DBAs. It covers 10g, 11g, 11gR2, with context from 8i and 9i ." The latter is true for the newest edition of course! Furthermore, the full source code is available, as well as an errata page on the author's site.
On the dark side, there are extensive sections of the text promoting the products Mr. Harrison and his company create, which although humorously introduced ("Full disclosure..."), are a waste of time to read, for open source funs or anyone who is not interested in buying the software.
All in all, the book is highly recommended and I am looking forward to reading each new edition. Congratulations to the author. Well done, indeed!
Friday, 27 May 2011
Comments on Oracle PL/SQL by Example (4th Edition) by Benjamin Rosenzweig, Elena Silvestrova Rakhimov
On the bright side, the text is easy to follow and understand with only a few spelling errors. It follows a structured approach with worked out examples to teach the basics to the beginner, offering many clarifications and new methods also useful to the intermediate developer in the same time. For example, the method for timing the execution of pl sql code block for performance comparison is original, not mentioned in the oracle university classes notes. The db schema is small and simple, about instructors and students attending the classes taught. In addition, there are solutions at the back of the book for the unsolved lab exercises and projects.
On the dark side, there is little for 11g db version, less than a handful of pages. Furthermore, some scripts about using the RESTRICT_REFERENCES pragma instruction in your pl sql code did not run in the current 11g db version. Obtaining the errors page and the source code scripts was something of an adventure, since there was nothing on the publisher's, but everything on the informIT site. The companion Web site is located at: http://www.informit.com/title/9780137144228
The last chapters of the book about web development via pl sql is mostly targeted to forms developers, discussing about the currently obsolete Oracle Application Server.
All in all, the book is suitable for those who would like to learn pl sql, or old developers who need brushing up their memory, but find that the fees for the oracle university classes are exorbitant, i.e. more than 1080 € for less than 40 hours; in a country where a mean hourly rate for a programmer is 10 € gross!
On the dark side, there is little for 11g db version, less than a handful of pages. Furthermore, some scripts about using the RESTRICT_REFERENCES pragma instruction in your pl sql code did not run in the current 11g db version. Obtaining the errors page and the source code scripts was something of an adventure, since there was nothing on the publisher's, but everything on the informIT site. The companion Web site is located at: http://www.informit.com/title/9780137144228
The last chapters of the book about web development via pl sql is mostly targeted to forms developers, discussing about the currently obsolete Oracle Application Server.
All in all, the book is suitable for those who would like to learn pl sql, or old developers who need brushing up their memory, but find that the fees for the oracle university classes are exorbitant, i.e. more than 1080 € for less than 40 hours; in a country where a mean hourly rate for a programmer is 10 € gross!
Tuesday, 17 May 2011
Migrating an EJB 3 application to the new JDeveloper version
This new post discusses several exceptions which have occurred because of migration to the current version of JDev. As far as I can remember the application was working well with the previous version. It seems that code rots!
The first has to do with populating a primary key field with a sequence in an entity EJB:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BID_SEQUENCE" )
@SequenceGenerator(name = "BID_SEQUENCE", sequenceName = "BID_SEQUENCE",
allocationSize = 10)
If you get an:
Exception Description: The sequence named [YOUR_SEQUENCE_NAME] is setup incorrectly. Its increment does not match its pre-allocation size.
A way to avoid the exception is to use 100 as a start value in sql create sequence statement. That will resolve the problem: by default the start value is 1, when Eclipselink attempts to use the first allocated sequence value it's negative 1 - 100 + 1, that causes the exception.
The second is more subtle to resolve, as the error message does not appear at once. If you get a mysterious error about a missing table which does not belong to the application db schema:
Eclipse Persistence Services - 2.1.3.v20110304-r9073):
org.eclipse.persistence.exceptions.DatabaseException Internal Exception:
java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
Error Code: 942 Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
bind => [50, SEQ_GEN] Query: DataModifyQuery
(sql="UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?")
a way to get rid of the exception is editing the persistense.xml as follows:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="Model">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/ActionBazaarDS</jta-data-source>
<class>actionbazaar.persistence.Category</class>
<class>actionbazaar.persistence.BillingInfo</class>
<class>actionbazaar.persistence.Order</class>
<class>actionbazaar.persistence.User</class>
<class>actionbazaar.persistence.Bid</class>
<class>actionbazaar.persistence.Bidder</class>
<class>actionbazaar.persistence.Seller</class>
<class>actionbazaar.persistence.Item</class>
<class>actionbazaar.persistence.ContactInfo</class>
<class>actionbazaar.persistence.ShippingInfo</class>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="javax.persistence.jtaDataSource"
value="jdbc/ActionBazaarDS"/>
<property name="eclipselink.target-database" value="Oracle11"/>
<!--Addon in case of
Eclipse Persistence Services - 2.1.3.v20110304-r9073):
org.eclipse.persistence.exceptions.DatabaseException Internal Exception:
java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
Error Code: 942 Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
bind => [50, SEQ_GEN] Query: DataModifyQuery
(sql="UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?")>
-->
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
Thus, the new SEQUENCE table will be automatically created and the application will at last commit the insert successfully.
The morale of the story is that frequent migrations due to upgrades can cause trouble. Perhaps, applying gradual patches instead, i.e. via the jdev online extensions way and waiting for a new full release would be safer. Otherwise you might spend hours searching about solutions on the internet, experimenting with each one and certainly overheating the computer. Always make sure you are in a well ventilated room, with full air conditioning when trying to migrate, or else high temperatures will cause your code to decay so much faster! Certain laptops such as Hewlett Packard Pavilion, overheat and power off immediately without prompting for save, very frequently at warm climates. After all, you don't want your code to go rot, do you?
The first has to do with populating a primary key field with a sequence in an entity EJB:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BID_SEQUENCE" )
@SequenceGenerator(name = "BID_SEQUENCE", sequenceName = "BID_SEQUENCE",
allocationSize = 10)
If you get an:
Exception Description: The sequence named [YOUR_SEQUENCE_NAME] is setup incorrectly. Its increment does not match its pre-allocation size.
A way to avoid the exception is to use 100 as a start value in sql create sequence statement. That will resolve the problem: by default the start value is 1, when Eclipselink attempts to use the first allocated sequence value it's negative 1 - 100 + 1, that causes the exception.
The second is more subtle to resolve, as the error message does not appear at once. If you get a mysterious error about a missing table which does not belong to the application db schema:
Eclipse Persistence Services - 2.1.3.v20110304-r9073):
org.eclipse.persistence.exceptions.DatabaseException Internal Exception:
java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
Error Code: 942 Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
bind => [50, SEQ_GEN] Query: DataModifyQuery
(sql="UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?")
a way to get rid of the exception is editing the persistense.xml as follows:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="Model">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/ActionBazaarDS</jta-data-source>
<class>actionbazaar.persistence.Category</class>
<class>actionbazaar.persistence.BillingInfo</class>
<class>actionbazaar.persistence.Order</class>
<class>actionbazaar.persistence.User</class>
<class>actionbazaar.persistence.Bid</class>
<class>actionbazaar.persistence.Bidder</class>
<class>actionbazaar.persistence.Seller</class>
<class>actionbazaar.persistence.Item</class>
<class>actionbazaar.persistence.ContactInfo</class>
<class>actionbazaar.persistence.ShippingInfo</class>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="javax.persistence.jtaDataSource"
value="jdbc/ActionBazaarDS"/>
<property name="eclipselink.target-database" value="Oracle11"/>
<!--Addon in case of
Eclipse Persistence Services - 2.1.3.v20110304-r9073):
org.eclipse.persistence.exceptions.DatabaseException Internal Exception:
java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
Error Code: 942 Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
bind => [50, SEQ_GEN] Query: DataModifyQuery
(sql="UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?")>
-->
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
Thus, the new SEQUENCE table will be automatically created and the application will at last commit the insert successfully.
The morale of the story is that frequent migrations due to upgrades can cause trouble. Perhaps, applying gradual patches instead, i.e. via the jdev online extensions way and waiting for a new full release would be safer. Otherwise you might spend hours searching about solutions on the internet, experimenting with each one and certainly overheating the computer. Always make sure you are in a well ventilated room, with full air conditioning when trying to migrate, or else high temperatures will cause your code to decay so much faster! Certain laptops such as Hewlett Packard Pavilion, overheat and power off immediately without prompting for save, very frequently at warm climates. After all, you don't want your code to go rot, do you?
Monday, 11 April 2011
JDeveloper 11g: Setting up the newest java development kit
This new post is about users who would like to update to the newest jdk, without having to waste time or hard disk space, by setting up from scratch JDeveloper 11g, each time a new jdk is available. Moreover, people who still use older versions of the database such as 9, may also find handy the jdbc connection localization properties hint which follows. If you 'd like to jump to it at once, please search for connecting to Oracle. A full sample of jdev.conf file is presented as a reference for your convenience. So let's get started!
First, you need first to setup the Sun 64bit jdk, then you need to edit the
C:\Oracle\Middleware\jdev_11114\jdeveloper\jdev\bin\jdev.conf file:
#
# Directive SetJavaHome is not required by default, except for the base
# install, since the launcher will determine the JAVA_HOME. On Windows
# it looks in ..\..\jdk, on UNIX it first looks in ../../jdk. If no JDK
# is found there, it looks in the PATH.
#
#SetJavaHome C:\Oracle\Middleware\jdev_11114\jdk160_21
SetJavaHome C:\Program Files\Java\jdk1.6.0_24
...
and you might get the following message the next time you start JDev
Finally the integrated weblogic server C:\Users\name\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\DefaultDomain\bin\setDomainEnv.cmd script:
@ECHO OFF
@REM WARNING: This file is created by the Configuration Wizard.
@REM Any changes to this script may be lost when adding extensions to this configuration.
@REM *************************************************************************
@REM This script is used to setup the needed environment to be able to start Weblogic Server in this domain.
@REM
@REM This script initializes the following variables before calling commEnv to set other variables:
@REM
@REM WL_HOME - The BEA home directory of your WebLogic installation.
@REM JAVA_VM - The desired Java VM to use. You can set this environment variable before calling
@REM this script to switch between Sun or BEA or just have the default be set.
@REM JAVA_HOME - Location of the version of Java used to start WebLogic
@REM Server. Depends directly on which JAVA_VM value is set by default or by the environment.
@REM USER_MEM_ARGS - The variable to override the standard memory arguments
@REM passed to java.
@REM PRODUCTION_MODE - The variable that determines whether Weblogic Server is started in production mode.
@REM DOMAIN_PRODUCTION_MODE
@REM - The variable that determines whether the workshop related settings like the debugger,
@REM testconsole or iterativedev should be enabled. ONLY settable using the
@REM command-line parameter named production
@REM NOTE: Specifying the production command-line param will force
@REM the server to start in production mode.
@REM
@REM Other variables used in this script include:
@REM SERVER_NAME - Name of the weblogic server.
@REM JAVA_OPTIONS - Java command-line options for running the server. (These
@REM will be tagged on to the end of the JAVA_VM and
@REM MEM_ARGS)
@REM
@REM For additional information, refer to "Managing Server Startup and Shutdown for Oracle WebLogic Server"
@REM (http://download.oracle.com/docs/cd/E17904_01/web.1111/e13708/overview.htm).
@REM *************************************************************************
set COMMON_COMPONENTS_HOME=C:\Oracle\Middleware\jdev_11114\oracle_common
for %%i in ("%COMMON_COMPONENTS_HOME%") do set COMMON_COMPONENTS_HOME=%%~fsi
set WL_HOME=C:\Oracle\Middleware\jdev_11114\wlserver_10.3
for %%i in ("%WL_HOME%") do set WL_HOME=%%~fsi
set BEA_JAVA_HOME=
@REM On 16.3.2011 added C:\Program Files\Java\jdk1.6.0_24 instead of C:\Oracle\Middleware\jdev_11114\jdk160_21
set SUN_JAVA_HOME= C:\Program Files\Java\jdk1.6.0_24
if "%JAVA_VENDOR%"=="Oracle" (
set JAVA_HOME=%BEA_JAVA_HOME%
) else (
if "%JAVA_VENDOR%"=="Sun" (
set JAVA_HOME=%SUN_JAVA_HOME%
) else (
set JAVA_VENDOR=Sun
@REM On 16.3.2011 added C:\Program Files\Java\jdk1.6.0_24 instead of C:\Oracle\Middleware\jdev_11114\jdk160_21
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_24
)
)
@REM We need to reset the value of JAVA_HOME to get it shortened AND
@REM we can not shorten it above because immediate variable expansion will blank it
set JAVA_HOME=%JAVA_HOME%
for %%i in ("%JAVA_HOME%") do set JAVA_HOME=%%~fsi
set SAMPLES_HOME=%WL_HOME%\samples
set DOMAIN_HOME=C:\Users\Nick\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\DefaultDomain
for %%i in ("%DOMAIN_HOME%") do set DOMAIN_HOME=%%~fsi
set LONG_DOMAIN_HOME=C:\Users\Nick\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\DefaultDomain
if "%DEBUG_PORT%"=="" (
set DEBUG_PORT=8453
)
if "%SERVER_NAME%"=="" (
set SERVER_NAME=DefaultServer
)
set DERBY_FLAG=false
set enableHotswapFlag=
set PRODUCTION_MODE=
set doExitFlag=false
set verboseLoggingFlag=false
for %%p in (%*) do call :SET_PARAM %%p
GOTO :CMD_LINE_DONE
:SET_PARAM
for %%q in (%1) do set noQuotesParam=%%~q
if /i "%noQuotesParam%" == "nodebug" (
set debugFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "production" (
set DOMAIN_PRODUCTION_MODE=true
GOTO :EOF
)
if /i "%noQuotesParam%" == "notestconsole" (
set testConsoleFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "noiterativedev" (
set iterativeDevFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "noLogErrorsToConsole" (
set logErrorsToConsoleFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "noderby" (
set DERBY_FLAG=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "doExit" (
set doExitFlag=true
GOTO :EOF
)
if /i "%noQuotesParam%" == "noExit" (
set doExitFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "verbose" (
set verboseLoggingFlag=true
GOTO :EOF
)
if /i "%noQuotesParam%" == "enableHotswap" (
set enableHotswapFlag=-javaagent:%WL_HOME%\server\lib\diagnostics-agent.jar
GOTO :EOF
) else (
set PROXY_SETTINGS=%PROXY_SETTINGS% %1
)
GOTO :EOF
:CMD_LINE_DONE
set MEM_DEV_ARGS=
if "%DOMAIN_PRODUCTION_MODE%"=="true" (
set PRODUCTION_MODE=%DOMAIN_PRODUCTION_MODE%
)
if "%PRODUCTION_MODE%"=="true" (
set debugFlag=false
set testConsoleFlag=false
set iterativeDevFlag=false
set logErrorsToConsoleFlag=false
)
@REM If you want to override the default Patch Classpath, Library Path and Path for this domain,
@REM Please uncomment the following lines and add a valid value for the environment variables
@REM set PATCH_CLASSPATH=[myPatchClasspath] (windows)
@REM set PATCH_LIBPATH=[myPatchLibpath] (windows)
@REM set PATCH_PATH=[myPatchPath] (windows)
@REM PATCH_CLASSPATH=[myPatchClasspath] (unix)
@REM PATCH_LIBPATH=[myPatchLibpath] (unix)
@REM PATCH_PATH=[myPatchPath] (unix)
call "%WL_HOME%\common\bin\commEnv.cmd"
set WLS_HOME=%WL_HOME%\server
set XMS_SUN_64BIT=256
set XMS_SUN_32BIT=256
set XMX_SUN_64BIT=512
set XMX_SUN_32BIT=512
set XMS_JROCKIT_64BIT=256
set XMS_JROCKIT_32BIT=256
set XMX_JROCKIT_64BIT=512
set XMX_JROCKIT_32BIT=512
if "%JAVA_VENDOR%"=="Sun" (
set WLS_MEM_ARGS_64BIT=-Xms256m -Xmx512m
set WLS_MEM_ARGS_32BIT=-Xms256m -Xmx512m
) else (
set WLS_MEM_ARGS_64BIT=-Xms512m -Xmx512m
set WLS_MEM_ARGS_32BIT=-Xms512m -Xmx512m
)
if "%JAVA_VENDOR%"=="Oracle" (
set CUSTOM_MEM_ARGS_64BIT=-Xms%XMS_JROCKIT_64BIT%m -Xmx%XMX_JROCKIT_64BIT%m
set CUSTOM_MEM_ARGS_32BIT=-Xms%XMS_JROCKIT_32BIT%m -Xmx%XMX_JROCKIT_32BIT%m
) else (
set CUSTOM_MEM_ARGS_64BIT=-Xms%XMS_SUN_64BIT%m -Xmx%XMX_SUN_64BIT%m
set CUSTOM_MEM_ARGS_32BIT=-Xms%XMS_SUN_32BIT%m -Xmx%XMX_SUN_32BIT%m
)
set MEM_ARGS_64BIT=%CUSTOM_MEM_ARGS_64BIT%
set MEM_ARGS_32BIT=%CUSTOM_MEM_ARGS_32BIT%
if "%JAVA_USE_64BIT%"=="true" (
set MEM_ARGS=%MEM_ARGS_64BIT%
) else (
set MEM_ARGS=%MEM_ARGS_32BIT%
)
set MEM_PERM_SIZE_64BIT=-XX:PermSize=128m
set MEM_PERM_SIZE_32BIT=-XX:PermSize=128m
if "%JAVA_USE_64BIT%"=="true" (
set MEM_PERM_SIZE=%MEM_PERM_SIZE_64BIT%
) else (
set MEM_PERM_SIZE=%MEM_PERM_SIZE_32BIT%
)
set MEM_MAX_PERM_SIZE_64BIT=-XX:MaxPermSize=512m
set MEM_MAX_PERM_SIZE_32BIT=-XX:MaxPermSize=512m
if "%JAVA_USE_64BIT%"=="true" (
set MEM_MAX_PERM_SIZE=%MEM_MAX_PERM_SIZE_64BIT%
) else (
set MEM_MAX_PERM_SIZE=%MEM_MAX_PERM_SIZE_32BIT%
)
if "%JAVA_VENDOR%"=="Sun" (
if "%PRODUCTION_MODE%"=="" (
set MEM_DEV_ARGS=-XX:CompileThreshold=8000 %MEM_PERM_SIZE%
)
)
@REM Had to have a separate test here BECAUSE of immediate variable expansion on windows
if "%JAVA_VENDOR%"=="Sun" (
set MEM_ARGS=%MEM_ARGS% %MEM_DEV_ARGS% %MEM_MAX_PERM_SIZE%
)
if "%JAVA_VENDOR%"=="HP" (
set MEM_ARGS=%MEM_ARGS% %MEM_MAX_PERM_SIZE%
)
if "%JAVA_VENDOR%"=="Apple" (
set MEM_ARGS=%MEM_ARGS% %MEM_MAX_PERM_SIZE%
)
@REM IF USER_MEM_ARGS the environment variable is set, use it to override ALL MEM_ARGS values
if NOT "%USER_MEM_ARGS%"=="" (
set MEM_ARGS=%USER_MEM_ARGS%
)
set ORACLE_DOMAIN_CONFIG_DIR=%DOMAIN_HOME%\config\fmwconfig
for %%i in ("%ORACLE_DOMAIN_CONFIG_DIR%") do set ORACLE_DOMAIN_CONFIG_DIR=%%~fsi
set WLS_JDBC_REMOTE_ENABLED=-Dweblogic.jdbc.remoteEnabled=false
set JAVA_PROPERTIES=-Dplatform.home=%WL_HOME% -Dwls.home=%WLS_HOME% -Dweblogic.home=%WLS_HOME%
set ALT_TYPES_DIR=%COMMON_COMPONENTS_HOME%\modules\oracle.ossoiap_11.1.1,%COMMON_COMPONENTS_HOME%\modules\oracle.oamprovider_11.1.1
set PROTOCOL_HANDLERS=oracle.mds.net.protocol
set PROTOCOL_HANDLERS=%PROTOCOL_HANDLERS:;="|"%
@REM To use Java Authorization Contract for Containers (JACC) in this domain,
@REM please uncomment the following section. If there are multiple machines in
@REM your domain, be sure to edit the setDomainEnv in the associated domain on
@REM each machine.
@REM
@REM -Djava.security.manager
@REM -Djava.security.policy=location of weblogic.policy
@REM -Djavax.security.jacc.policy.provider=weblogic.security.jacc.simpleprovider.SimpleJACCPolicy
@REM -Djavax.security.jacc.PolicyConfigurationFactory.provider=weblogic.security.jacc.simpleprovider.PolicyConfigurationFactoryImpl
@REM -Dweblogic.security.jacc.RoleMapperFactory.provider=weblogic.security.jacc.simpleprovider.RoleMapperFactoryImpl
set EXTRA_JAVA_PROPERTIES=-Dwsm.repository.path=%DOMAIN_HOME%\oracle\store\gmds %EXTRA_JAVA_PROPERTIES%
set EXTRA_JAVA_PROPERTIES=-Dcommon.components.home=%COMMON_COMPONENTS_HOME% -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=%DOMAIN_HOME% -Djrockit.optfile=%COMMON_COMPONENTS_HOME%\modules\oracle.jrf_11.1.1\jrocket_optfile.txt -Doracle.server.config.dir=%ORACLE_DOMAIN_CONFIG_DIR%\servers\%SERVER_NAME% -Doracle.domain.config.dir=%ORACLE_DOMAIN_CONFIG_DIR% -Digf.arisidbeans.carmlloc=%ORACLE_DOMAIN_CONFIG_DIR%\carml -Digf.arisidstack.home=%ORACLE_DOMAIN_CONFIG_DIR%\arisidprovider -Doracle.security.jps.config=%DOMAIN_HOME%\config\fmwconfig\jps-config.xml -Doracle.deployed.app.dir=%DOMAIN_HOME%\servers\%SERVER_NAME%\tmp\_WL_user -Doracle.deployed.app.ext=\- -Dweblogic.alternateTypesDirectory=%ALT_TYPES_DIR% -Djava.protocol.handler.pkgs=%PROTOCOL_HANDLERS% %WLS_JDBC_REMOTE_ENABLED% %EXTRA_JAVA_PROPERTIES%
set EXTRA_JAVA_PROPERTIES=-Djps.app.credential.overwrite.allowed=true %EXTRA_JAVA_PROPERTIES%
set JAVA_PROPERTIES=%JAVA_PROPERTIES% %EXTRA_JAVA_PROPERTIES%
set ARDIR=%WL_HOME%\server\lib
pushd %LONG_DOMAIN_HOME%
@REM Clustering support (edit for your cluster!)
if "%ADMIN_URL%"=="" (
@REM The then part of this block is telling us we are either starting an admin server OR we are non-clustered
set CLUSTER_PROPERTIES=-Dweblogic.management.discover=true
) else (
set CLUSTER_PROPERTIES=-Dweblogic.management.discover=false -Dweblogic.management.server=%ADMIN_URL%
)
if NOT "%LOG4J_CONFIG_FILE%"=="" (
set JAVA_PROPERTIES=%JAVA_PROPERTIES% -Dlog4j.configuration=file:%LOG4J_CONFIG_FILE%
)
set JAVA_PROPERTIES=%JAVA_PROPERTIES% %CLUSTER_PROPERTIES%
set JAVA_DEBUG=
if "%debugFlag%"=="true" (
set JAVA_DEBUG=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=%DEBUG_PORT%,server=y,suspend=n -Djava.compiler=NONE
set JAVA_OPTIONS=%JAVA_OPTIONS% %enableHotswapFlag% -ea -da:com.bea... -da:javelin... -da:weblogic... -ea:com.bea.wli... -ea:com.bea.broker... -ea:com.bea.sbconsole...
) else (
set JAVA_OPTIONS=%JAVA_OPTIONS% %enableHotswapFlag% -da
)
if NOT exist %JAVA_HOME%\lib (
echo The JRE was not found in directory %JAVA_HOME%. ^(JAVA_HOME^)
echo Please edit your environment and set the JAVA_HOME
echo variable to point to the root directory of your Java installation.
popd
pause
GOTO :EOF
)
if "%DERBY_FLAG%"=="true" (
set DATABASE_CLASSPATH=%DERBY_CLASSPATH%
) else (
set DATABASE_CLASSPATH=%DERBY_CLIENT_CLASSPATH%
)
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%COMMON_COMPONENTS_HOME%\modules\oracle.jrf_11.1.1\jrf.jar;%POST_CLASSPATH%
) else (
set POST_CLASSPATH=%COMMON_COMPONENTS_HOME%\modules\oracle.jrf_11.1.1\jrf.jar
)
if NOT "%PRE_CLASSPATH%"=="" (
set PRE_CLASSPATH=%COMMON_COMPONENTS_HOME%\modules\oracle.jdbc_11.1.1\ojdbc6dms.jar;%PRE_CLASSPATH%
) else (
set PRE_CLASSPATH=%COMMON_COMPONENTS_HOME%\modules\oracle.jdbc_11.1.1\ojdbc6dms.jar
)
if NOT "%DATABASE_CLASSPATH%"=="" (
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%POST_CLASSPATH%;%DATABASE_CLASSPATH%
) else (
set POST_CLASSPATH=%DATABASE_CLASSPATH%
)
)
if NOT "%ARDIR%"=="" (
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%POST_CLASSPATH%;%ARDIR%\xqrl.jar
) else (
set POST_CLASSPATH=%ARDIR%\xqrl.jar
)
)
@REM PROFILING SUPPORT
set JAVA_PROFILE=
set SERVER_CLASS=weblogic.Server
set JAVA_PROPERTIES=%JAVA_PROPERTIES% %WLP_JAVA_PROPERTIES%
set JAVA_OPTIONS=%JAVA_OPTIONS% %JAVA_PROPERTIES% -Dwlw.iterativeDev=%iterativeDevFlag% -Dwlw.testConsole=%testConsoleFlag% -Dwlw.logErrorsToConsole=%logErrorsToConsoleFlag%
if "%PRODUCTION_MODE%"=="true" (
set JAVA_OPTIONS= -Dweblogic.ProductionModeEnabled=true %JAVA_OPTIONS%
)
@REM -- Setup properties so that we can save stdout and stderr to files
if NOT "%WLS_STDOUT_LOG%"=="" (
echo Logging WLS stdout to %WLS_STDOUT_LOG%
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.Stdout=%WLS_STDOUT_LOG%
)
if NOT "%WLS_STDERR_LOG%"=="" (
echo Logging WLS stderr to %WLS_STDERR_LOG%
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.Stderr=%WLS_STDERR_LOG%
)
@REM ADD EXTENSIONS TO CLASSPATHS
if NOT "%EXT_PRE_CLASSPATH%"=="" (
if NOT "%PRE_CLASSPATH%"=="" (
set PRE_CLASSPATH=%EXT_PRE_CLASSPATH%;%PRE_CLASSPATH%
) else (
set PRE_CLASSPATH=%EXT_PRE_CLASSPATH%
)
)
if NOT "%EXT_POST_CLASSPATH%"=="" (
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%POST_CLASSPATH%;%EXT_POST_CLASSPATH%
) else (
set POST_CLASSPATH=%EXT_POST_CLASSPATH%
)
)
if NOT "%WEBLOGIC_EXTENSION_DIRS%"=="" (
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.ext.dirs=%WEBLOGIC_EXTENSION_DIRS%
)
set JAVA_OPTIONS=%JAVA_OPTIONS%
@REM SET THE CLASSPATH
if NOT "%WLP_POST_CLASSPATH%"=="" (
if NOT "%CLASSPATH%"=="" (
set CLASSPATH=%WLP_POST_CLASSPATH%;%CLASSPATH%
) else (
set CLASSPATH=%WLP_POST_CLASSPATH%
)
)
if NOT "%POST_CLASSPATH%"=="" (
if NOT "%CLASSPATH%"=="" (
set CLASSPATH=%POST_CLASSPATH%;%CLASSPATH%
) else (
set CLASSPATH=%POST_CLASSPATH%
)
)
if NOT "%WEBLOGIC_CLASSPATH%"=="" (
if NOT "%CLASSPATH%"=="" (
set CLASSPATH=%WEBLOGIC_CLASSPATH%;%CLASSPATH%
) else (
set CLASSPATH=%WEBLOGIC_CLASSPATH%
)
)
if NOT "%PRE_CLASSPATH%"=="" (
set CLASSPATH=%PRE_CLASSPATH%;%CLASSPATH%
)
if NOT "%JAVA_VENDOR%"=="BEA" (
set JAVA_VM=%JAVA_VM% %JAVA_DEBUG% %JAVA_PROFILE%
) else (
set JAVA_VM=%JAVA_VM% %JAVA_DEBUG% %JAVA_PROFILE%
)
Although the paths are from a win7 machine, I think one can get the general idea in order to proceed. For unix or linux users, one can find help here. Thus, one can avoid the risk of losing one's application or database server connections imposed by setting up JDev from scratch and migrating.
Finally, I don't know, does Oracle support officially certify jdev to work right, after a user has altered the default jdev jdk? That's why keeping the old default jdk entries as comments, is safer; in case the built in 32 bit jdk needs to be used once more.
A recent finding would be my attempt to use the profiler of JDeveloper which only works with the built in 32 bit jdk, provided one installs the 32 bit visual studio 2010 C++ redistributable file .When I tried to use the Microsoft Visual C++ 2010 Redistributable Package (x64) I got:
Error occurred during initialization of VM
Could not find agent library C:\Oracle\Middleware\jdev_11115\jdeveloper\jdev\lib\profiler_x64.dll in absolute path, with error: Can't load IA 32-bit .dll on a AMD 64-bit platform
Process exited.
So remember before you start swearing at me, that you were warned!
Having problems connecting to Oracle 9i? Try tweaking once more the configuration files
Speaking of database connections, I recently noticed that when one attempts to connect to an Oracle 9i database with Greek regional settings, one receives:
Test failed: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found
Having heard of a similar solution working for SQL Developer, a similar method crosses one's mind. One needs to edit:
C:\Oracle\Middleware\jdev_11114\jdeveloper\jdev\bin\jdev.conf
as shown below:
##############################################################################
#
# Oracle JDeveloper Launcher Configuration File
# Copyright 2000-2008 Oracle Corporation.
# All Rights Reserved.
#
##############################################################################
IncludeConfFile ../../ide/bin/ide.conf
#
# Directive SetJavaHome is not required by default, except for the base
# install, since the launcher will determine the JAVA_HOME. On Windows
# it looks in ..\..\jdk, on UNIX it first looks in ../../jdk. If no JDK
# is found there, it looks in the PATH.
#
#SetJavaHome C:\Oracle\Middleware\jdev_11114\jdk160_21
SetJavaHome C:\Program Files\Java\jdk1.6.0_24
#
# MaxPermSize is required to run JDeveloper with Sun Microsystems virtual
# machine (-client and -server). The default value is 64M, which isn't
# enough to run JDeveloper successfully. With the default value, JDeveloper
# will end up running out of memory at some point in time. For technical
# details, see: http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
#
AddVMOption -XX:MaxPermSize=256M
#
#added on 10/04/2011 to connect to oracle 9 with Greek regional settings
AddVMOption -Duser.timezone=UTC+02:00
#
# Replace heavyweight AWT controls with lightweight implementations.
#
AddVMOption -Xbootclasspath/p:../lib/lwawt.jar
#
# Don't swap the entire JDev process out of memory when minimizing the main window.
#
AddVMOption -Dsun.awt.keepWorkingSetOnMinimize=true
#
# Prevent Swing painting issues and hangs on some graphics cards and/or
# multiple monitor setups and/or Windows 7.
#
AddVMOption -Dsun.java2d.noddraw=true
#
# Automatically dump heap on OutOfMemoryError.
# The heap dump is in HPROF binary format, and so it can be analyzed using
# any tools that can import this format. Examples are jhat, NetBeans and YourKit.
# By default the heap dump is created in a file called java_pid.hprof in the
# working directory of the VM.
#
AddVMOption -XX:+HeapDumpOnOutOfMemoryError
#
# Option to enable OWSM policy types RM and Management on the policy configuration
# dialog for a web service.
# The same option, if set to true, also shows the policy configuration dialog for
# web service client as well.
# This flag exists so that when OWSM support for RM and Management policy
# types for WLS becomes available in the server module, removing this flag or
# setting it to 'true' will bring those options in JDev WS policy configuration.
#
AddVMOption -Doracle.jdeveloper.webservice.showAllOwsmPolicyTypes=false
#
# Controls the acess to OWSM policy property override dialog from the client policy
# configuration dialog.
#
AddVMOption -Doracle.jdeveloper.webservice.hidePropertyOverride=false
#
# Prevents the desktop hanging when debugging JDev on Linux and hitting a breakpoint with a popup open.
# See Sun Bug: 6714678 (http://bugs.sun.com/view_bug.do?bug_id=6714678)
# Note: This only prevents the hang when debugging JDev itself. To prevent hanging with other
# projects add this flag to the java options for the process to be debugged.
#
AddVMOption -Dsun.awt.disablegrab=true
....
What worries me most, is when each newer version of the I.D.E. or Sun jdk becomes available, if one is forced to setup from scratch, might not remember all the necessary steps to edit properly the new configuration files and continue with the current project. So backing up the jdev configuration files sounds like a good, proactive idea!
First, you need first to setup the Sun 64bit jdk, then you need to edit the
C:\Oracle\Middleware\jdev_11114\jdeveloper\jdev\bin\jdev.conf file:
#
# Directive SetJavaHome is not required by default, except for the base
# install, since the launcher will determine the JAVA_HOME. On Windows
# it looks in ..\..\jdk, on UNIX it first looks in ../../jdk. If no JDK
# is found there, it looks in the PATH.
#
#SetJavaHome C:\Oracle\Middleware\jdev_11114\jdk160_21
SetJavaHome C:\Program Files\Java\jdk1.6.0_24
...
and you might get the following message the next time you start JDev
Do not overdo it! |
Finally the integrated weblogic server C:\Users\name\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\DefaultDomain\bin\setDomainEnv.cmd script:
@ECHO OFF
@REM WARNING: This file is created by the Configuration Wizard.
@REM Any changes to this script may be lost when adding extensions to this configuration.
@REM *************************************************************************
@REM This script is used to setup the needed environment to be able to start Weblogic Server in this domain.
@REM
@REM This script initializes the following variables before calling commEnv to set other variables:
@REM
@REM WL_HOME - The BEA home directory of your WebLogic installation.
@REM JAVA_VM - The desired Java VM to use. You can set this environment variable before calling
@REM this script to switch between Sun or BEA or just have the default be set.
@REM JAVA_HOME - Location of the version of Java used to start WebLogic
@REM Server. Depends directly on which JAVA_VM value is set by default or by the environment.
@REM USER_MEM_ARGS - The variable to override the standard memory arguments
@REM passed to java.
@REM PRODUCTION_MODE - The variable that determines whether Weblogic Server is started in production mode.
@REM DOMAIN_PRODUCTION_MODE
@REM - The variable that determines whether the workshop related settings like the debugger,
@REM testconsole or iterativedev should be enabled. ONLY settable using the
@REM command-line parameter named production
@REM NOTE: Specifying the production command-line param will force
@REM the server to start in production mode.
@REM
@REM Other variables used in this script include:
@REM SERVER_NAME - Name of the weblogic server.
@REM JAVA_OPTIONS - Java command-line options for running the server. (These
@REM will be tagged on to the end of the JAVA_VM and
@REM MEM_ARGS)
@REM
@REM For additional information, refer to "Managing Server Startup and Shutdown for Oracle WebLogic Server"
@REM (http://download.oracle.com/docs/cd/E17904_01/web.1111/e13708/overview.htm).
@REM *************************************************************************
set COMMON_COMPONENTS_HOME=C:\Oracle\Middleware\jdev_11114\oracle_common
for %%i in ("%COMMON_COMPONENTS_HOME%") do set COMMON_COMPONENTS_HOME=%%~fsi
set WL_HOME=C:\Oracle\Middleware\jdev_11114\wlserver_10.3
for %%i in ("%WL_HOME%") do set WL_HOME=%%~fsi
set BEA_JAVA_HOME=
@REM On 16.3.2011 added C:\Program Files\Java\jdk1.6.0_24 instead of C:\Oracle\Middleware\jdev_11114\jdk160_21
set SUN_JAVA_HOME= C:\Program Files\Java\jdk1.6.0_24
if "%JAVA_VENDOR%"=="Oracle" (
set JAVA_HOME=%BEA_JAVA_HOME%
) else (
if "%JAVA_VENDOR%"=="Sun" (
set JAVA_HOME=%SUN_JAVA_HOME%
) else (
set JAVA_VENDOR=Sun
@REM On 16.3.2011 added C:\Program Files\Java\jdk1.6.0_24 instead of C:\Oracle\Middleware\jdev_11114\jdk160_21
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_24
)
)
@REM We need to reset the value of JAVA_HOME to get it shortened AND
@REM we can not shorten it above because immediate variable expansion will blank it
set JAVA_HOME=%JAVA_HOME%
for %%i in ("%JAVA_HOME%") do set JAVA_HOME=%%~fsi
set SAMPLES_HOME=%WL_HOME%\samples
set DOMAIN_HOME=C:\Users\Nick\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\DefaultDomain
for %%i in ("%DOMAIN_HOME%") do set DOMAIN_HOME=%%~fsi
set LONG_DOMAIN_HOME=C:\Users\Nick\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\DefaultDomain
if "%DEBUG_PORT%"=="" (
set DEBUG_PORT=8453
)
if "%SERVER_NAME%"=="" (
set SERVER_NAME=DefaultServer
)
set DERBY_FLAG=false
set enableHotswapFlag=
set PRODUCTION_MODE=
set doExitFlag=false
set verboseLoggingFlag=false
for %%p in (%*) do call :SET_PARAM %%p
GOTO :CMD_LINE_DONE
:SET_PARAM
for %%q in (%1) do set noQuotesParam=%%~q
if /i "%noQuotesParam%" == "nodebug" (
set debugFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "production" (
set DOMAIN_PRODUCTION_MODE=true
GOTO :EOF
)
if /i "%noQuotesParam%" == "notestconsole" (
set testConsoleFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "noiterativedev" (
set iterativeDevFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "noLogErrorsToConsole" (
set logErrorsToConsoleFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "noderby" (
set DERBY_FLAG=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "doExit" (
set doExitFlag=true
GOTO :EOF
)
if /i "%noQuotesParam%" == "noExit" (
set doExitFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "verbose" (
set verboseLoggingFlag=true
GOTO :EOF
)
if /i "%noQuotesParam%" == "enableHotswap" (
set enableHotswapFlag=-javaagent:%WL_HOME%\server\lib\diagnostics-agent.jar
GOTO :EOF
) else (
set PROXY_SETTINGS=%PROXY_SETTINGS% %1
)
GOTO :EOF
:CMD_LINE_DONE
set MEM_DEV_ARGS=
if "%DOMAIN_PRODUCTION_MODE%"=="true" (
set PRODUCTION_MODE=%DOMAIN_PRODUCTION_MODE%
)
if "%PRODUCTION_MODE%"=="true" (
set debugFlag=false
set testConsoleFlag=false
set iterativeDevFlag=false
set logErrorsToConsoleFlag=false
)
@REM If you want to override the default Patch Classpath, Library Path and Path for this domain,
@REM Please uncomment the following lines and add a valid value for the environment variables
@REM set PATCH_CLASSPATH=[myPatchClasspath] (windows)
@REM set PATCH_LIBPATH=[myPatchLibpath] (windows)
@REM set PATCH_PATH=[myPatchPath] (windows)
@REM PATCH_CLASSPATH=[myPatchClasspath] (unix)
@REM PATCH_LIBPATH=[myPatchLibpath] (unix)
@REM PATCH_PATH=[myPatchPath] (unix)
call "%WL_HOME%\common\bin\commEnv.cmd"
set WLS_HOME=%WL_HOME%\server
set XMS_SUN_64BIT=256
set XMS_SUN_32BIT=256
set XMX_SUN_64BIT=512
set XMX_SUN_32BIT=512
set XMS_JROCKIT_64BIT=256
set XMS_JROCKIT_32BIT=256
set XMX_JROCKIT_64BIT=512
set XMX_JROCKIT_32BIT=512
if "%JAVA_VENDOR%"=="Sun" (
set WLS_MEM_ARGS_64BIT=-Xms256m -Xmx512m
set WLS_MEM_ARGS_32BIT=-Xms256m -Xmx512m
) else (
set WLS_MEM_ARGS_64BIT=-Xms512m -Xmx512m
set WLS_MEM_ARGS_32BIT=-Xms512m -Xmx512m
)
if "%JAVA_VENDOR%"=="Oracle" (
set CUSTOM_MEM_ARGS_64BIT=-Xms%XMS_JROCKIT_64BIT%m -Xmx%XMX_JROCKIT_64BIT%m
set CUSTOM_MEM_ARGS_32BIT=-Xms%XMS_JROCKIT_32BIT%m -Xmx%XMX_JROCKIT_32BIT%m
) else (
set CUSTOM_MEM_ARGS_64BIT=-Xms%XMS_SUN_64BIT%m -Xmx%XMX_SUN_64BIT%m
set CUSTOM_MEM_ARGS_32BIT=-Xms%XMS_SUN_32BIT%m -Xmx%XMX_SUN_32BIT%m
)
set MEM_ARGS_64BIT=%CUSTOM_MEM_ARGS_64BIT%
set MEM_ARGS_32BIT=%CUSTOM_MEM_ARGS_32BIT%
if "%JAVA_USE_64BIT%"=="true" (
set MEM_ARGS=%MEM_ARGS_64BIT%
) else (
set MEM_ARGS=%MEM_ARGS_32BIT%
)
set MEM_PERM_SIZE_64BIT=-XX:PermSize=128m
set MEM_PERM_SIZE_32BIT=-XX:PermSize=128m
if "%JAVA_USE_64BIT%"=="true" (
set MEM_PERM_SIZE=%MEM_PERM_SIZE_64BIT%
) else (
set MEM_PERM_SIZE=%MEM_PERM_SIZE_32BIT%
)
set MEM_MAX_PERM_SIZE_64BIT=-XX:MaxPermSize=512m
set MEM_MAX_PERM_SIZE_32BIT=-XX:MaxPermSize=512m
if "%JAVA_USE_64BIT%"=="true" (
set MEM_MAX_PERM_SIZE=%MEM_MAX_PERM_SIZE_64BIT%
) else (
set MEM_MAX_PERM_SIZE=%MEM_MAX_PERM_SIZE_32BIT%
)
if "%JAVA_VENDOR%"=="Sun" (
if "%PRODUCTION_MODE%"=="" (
set MEM_DEV_ARGS=-XX:CompileThreshold=8000 %MEM_PERM_SIZE%
)
)
@REM Had to have a separate test here BECAUSE of immediate variable expansion on windows
if "%JAVA_VENDOR%"=="Sun" (
set MEM_ARGS=%MEM_ARGS% %MEM_DEV_ARGS% %MEM_MAX_PERM_SIZE%
)
if "%JAVA_VENDOR%"=="HP" (
set MEM_ARGS=%MEM_ARGS% %MEM_MAX_PERM_SIZE%
)
if "%JAVA_VENDOR%"=="Apple" (
set MEM_ARGS=%MEM_ARGS% %MEM_MAX_PERM_SIZE%
)
@REM IF USER_MEM_ARGS the environment variable is set, use it to override ALL MEM_ARGS values
if NOT "%USER_MEM_ARGS%"=="" (
set MEM_ARGS=%USER_MEM_ARGS%
)
set ORACLE_DOMAIN_CONFIG_DIR=%DOMAIN_HOME%\config\fmwconfig
for %%i in ("%ORACLE_DOMAIN_CONFIG_DIR%") do set ORACLE_DOMAIN_CONFIG_DIR=%%~fsi
set WLS_JDBC_REMOTE_ENABLED=-Dweblogic.jdbc.remoteEnabled=false
set JAVA_PROPERTIES=-Dplatform.home=%WL_HOME% -Dwls.home=%WLS_HOME% -Dweblogic.home=%WLS_HOME%
set ALT_TYPES_DIR=%COMMON_COMPONENTS_HOME%\modules\oracle.ossoiap_11.1.1,%COMMON_COMPONENTS_HOME%\modules\oracle.oamprovider_11.1.1
set PROTOCOL_HANDLERS=oracle.mds.net.protocol
set PROTOCOL_HANDLERS=%PROTOCOL_HANDLERS:;="|"%
@REM To use Java Authorization Contract for Containers (JACC) in this domain,
@REM please uncomment the following section. If there are multiple machines in
@REM your domain, be sure to edit the setDomainEnv in the associated domain on
@REM each machine.
@REM
@REM -Djava.security.manager
@REM -Djava.security.policy=location of weblogic.policy
@REM -Djavax.security.jacc.policy.provider=weblogic.security.jacc.simpleprovider.SimpleJACCPolicy
@REM -Djavax.security.jacc.PolicyConfigurationFactory.provider=weblogic.security.jacc.simpleprovider.PolicyConfigurationFactoryImpl
@REM -Dweblogic.security.jacc.RoleMapperFactory.provider=weblogic.security.jacc.simpleprovider.RoleMapperFactoryImpl
set EXTRA_JAVA_PROPERTIES=-Dwsm.repository.path=%DOMAIN_HOME%\oracle\store\gmds %EXTRA_JAVA_PROPERTIES%
set EXTRA_JAVA_PROPERTIES=-Dcommon.components.home=%COMMON_COMPONENTS_HOME% -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=%DOMAIN_HOME% -Djrockit.optfile=%COMMON_COMPONENTS_HOME%\modules\oracle.jrf_11.1.1\jrocket_optfile.txt -Doracle.server.config.dir=%ORACLE_DOMAIN_CONFIG_DIR%\servers\%SERVER_NAME% -Doracle.domain.config.dir=%ORACLE_DOMAIN_CONFIG_DIR% -Digf.arisidbeans.carmlloc=%ORACLE_DOMAIN_CONFIG_DIR%\carml -Digf.arisidstack.home=%ORACLE_DOMAIN_CONFIG_DIR%\arisidprovider -Doracle.security.jps.config=%DOMAIN_HOME%\config\fmwconfig\jps-config.xml -Doracle.deployed.app.dir=%DOMAIN_HOME%\servers\%SERVER_NAME%\tmp\_WL_user -Doracle.deployed.app.ext=\- -Dweblogic.alternateTypesDirectory=%ALT_TYPES_DIR% -Djava.protocol.handler.pkgs=%PROTOCOL_HANDLERS% %WLS_JDBC_REMOTE_ENABLED% %EXTRA_JAVA_PROPERTIES%
set EXTRA_JAVA_PROPERTIES=-Djps.app.credential.overwrite.allowed=true %EXTRA_JAVA_PROPERTIES%
set JAVA_PROPERTIES=%JAVA_PROPERTIES% %EXTRA_JAVA_PROPERTIES%
set ARDIR=%WL_HOME%\server\lib
pushd %LONG_DOMAIN_HOME%
@REM Clustering support (edit for your cluster!)
if "%ADMIN_URL%"=="" (
@REM The then part of this block is telling us we are either starting an admin server OR we are non-clustered
set CLUSTER_PROPERTIES=-Dweblogic.management.discover=true
) else (
set CLUSTER_PROPERTIES=-Dweblogic.management.discover=false -Dweblogic.management.server=%ADMIN_URL%
)
if NOT "%LOG4J_CONFIG_FILE%"=="" (
set JAVA_PROPERTIES=%JAVA_PROPERTIES% -Dlog4j.configuration=file:%LOG4J_CONFIG_FILE%
)
set JAVA_PROPERTIES=%JAVA_PROPERTIES% %CLUSTER_PROPERTIES%
set JAVA_DEBUG=
if "%debugFlag%"=="true" (
set JAVA_DEBUG=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=%DEBUG_PORT%,server=y,suspend=n -Djava.compiler=NONE
set JAVA_OPTIONS=%JAVA_OPTIONS% %enableHotswapFlag% -ea -da:com.bea... -da:javelin... -da:weblogic... -ea:com.bea.wli... -ea:com.bea.broker... -ea:com.bea.sbconsole...
) else (
set JAVA_OPTIONS=%JAVA_OPTIONS% %enableHotswapFlag% -da
)
if NOT exist %JAVA_HOME%\lib (
echo The JRE was not found in directory %JAVA_HOME%. ^(JAVA_HOME^)
echo Please edit your environment and set the JAVA_HOME
echo variable to point to the root directory of your Java installation.
popd
pause
GOTO :EOF
)
if "%DERBY_FLAG%"=="true" (
set DATABASE_CLASSPATH=%DERBY_CLASSPATH%
) else (
set DATABASE_CLASSPATH=%DERBY_CLIENT_CLASSPATH%
)
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%COMMON_COMPONENTS_HOME%\modules\oracle.jrf_11.1.1\jrf.jar;%POST_CLASSPATH%
) else (
set POST_CLASSPATH=%COMMON_COMPONENTS_HOME%\modules\oracle.jrf_11.1.1\jrf.jar
)
if NOT "%PRE_CLASSPATH%"=="" (
set PRE_CLASSPATH=%COMMON_COMPONENTS_HOME%\modules\oracle.jdbc_11.1.1\ojdbc6dms.jar;%PRE_CLASSPATH%
) else (
set PRE_CLASSPATH=%COMMON_COMPONENTS_HOME%\modules\oracle.jdbc_11.1.1\ojdbc6dms.jar
)
if NOT "%DATABASE_CLASSPATH%"=="" (
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%POST_CLASSPATH%;%DATABASE_CLASSPATH%
) else (
set POST_CLASSPATH=%DATABASE_CLASSPATH%
)
)
if NOT "%ARDIR%"=="" (
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%POST_CLASSPATH%;%ARDIR%\xqrl.jar
) else (
set POST_CLASSPATH=%ARDIR%\xqrl.jar
)
)
@REM PROFILING SUPPORT
set JAVA_PROFILE=
set SERVER_CLASS=weblogic.Server
set JAVA_PROPERTIES=%JAVA_PROPERTIES% %WLP_JAVA_PROPERTIES%
set JAVA_OPTIONS=%JAVA_OPTIONS% %JAVA_PROPERTIES% -Dwlw.iterativeDev=%iterativeDevFlag% -Dwlw.testConsole=%testConsoleFlag% -Dwlw.logErrorsToConsole=%logErrorsToConsoleFlag%
if "%PRODUCTION_MODE%"=="true" (
set JAVA_OPTIONS= -Dweblogic.ProductionModeEnabled=true %JAVA_OPTIONS%
)
@REM -- Setup properties so that we can save stdout and stderr to files
if NOT "%WLS_STDOUT_LOG%"=="" (
echo Logging WLS stdout to %WLS_STDOUT_LOG%
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.Stdout=%WLS_STDOUT_LOG%
)
if NOT "%WLS_STDERR_LOG%"=="" (
echo Logging WLS stderr to %WLS_STDERR_LOG%
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.Stderr=%WLS_STDERR_LOG%
)
@REM ADD EXTENSIONS TO CLASSPATHS
if NOT "%EXT_PRE_CLASSPATH%"=="" (
if NOT "%PRE_CLASSPATH%"=="" (
set PRE_CLASSPATH=%EXT_PRE_CLASSPATH%;%PRE_CLASSPATH%
) else (
set PRE_CLASSPATH=%EXT_PRE_CLASSPATH%
)
)
if NOT "%EXT_POST_CLASSPATH%"=="" (
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%POST_CLASSPATH%;%EXT_POST_CLASSPATH%
) else (
set POST_CLASSPATH=%EXT_POST_CLASSPATH%
)
)
if NOT "%WEBLOGIC_EXTENSION_DIRS%"=="" (
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.ext.dirs=%WEBLOGIC_EXTENSION_DIRS%
)
set JAVA_OPTIONS=%JAVA_OPTIONS%
@REM SET THE CLASSPATH
if NOT "%WLP_POST_CLASSPATH%"=="" (
if NOT "%CLASSPATH%"=="" (
set CLASSPATH=%WLP_POST_CLASSPATH%;%CLASSPATH%
) else (
set CLASSPATH=%WLP_POST_CLASSPATH%
)
)
if NOT "%POST_CLASSPATH%"=="" (
if NOT "%CLASSPATH%"=="" (
set CLASSPATH=%POST_CLASSPATH%;%CLASSPATH%
) else (
set CLASSPATH=%POST_CLASSPATH%
)
)
if NOT "%WEBLOGIC_CLASSPATH%"=="" (
if NOT "%CLASSPATH%"=="" (
set CLASSPATH=%WEBLOGIC_CLASSPATH%;%CLASSPATH%
) else (
set CLASSPATH=%WEBLOGIC_CLASSPATH%
)
)
if NOT "%PRE_CLASSPATH%"=="" (
set CLASSPATH=%PRE_CLASSPATH%;%CLASSPATH%
)
if NOT "%JAVA_VENDOR%"=="BEA" (
set JAVA_VM=%JAVA_VM% %JAVA_DEBUG% %JAVA_PROFILE%
) else (
set JAVA_VM=%JAVA_VM% %JAVA_DEBUG% %JAVA_PROFILE%
)
Although the paths are from a win7 machine, I think one can get the general idea in order to proceed. For unix or linux users, one can find help here. Thus, one can avoid the risk of losing one's application or database server connections imposed by setting up JDev from scratch and migrating.
Finally, I don't know, does Oracle support officially certify jdev to work right, after a user has altered the default jdev jdk? That's why keeping the old default jdk entries as comments, is safer; in case the built in 32 bit jdk needs to be used once more.
A recent finding would be my attempt to use the profiler of JDeveloper which only works with the built in 32 bit jdk, provided one installs the 32 bit visual studio 2010 C++ redistributable file .When I tried to use the Microsoft Visual C++ 2010 Redistributable Package (x64) I got:
Error occurred during initialization of VM
Could not find agent library C:\Oracle\Middleware\jdev_11115\jdeveloper\jdev\lib\profiler_x64.dll in absolute path, with error: Can't load IA 32-bit .dll on a AMD 64-bit platform
Process exited.
So remember before you start swearing at me, that you were warned!
Having problems connecting to Oracle 9i? Try tweaking once more the configuration files
Speaking of database connections, I recently noticed that when one attempts to connect to an Oracle 9i database with Greek regional settings, one receives:
Test failed: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found
Having heard of a similar solution working for SQL Developer, a similar method crosses one's mind. One needs to edit:
C:\Oracle\Middleware\jdev_11114\jdeveloper\jdev\bin\jdev.conf
as shown below:
##############################################################################
#
# Oracle JDeveloper Launcher Configuration File
# Copyright 2000-2008 Oracle Corporation.
# All Rights Reserved.
#
##############################################################################
IncludeConfFile ../../ide/bin/ide.conf
#
# Directive SetJavaHome is not required by default, except for the base
# install, since the launcher will determine the JAVA_HOME. On Windows
# it looks in ..\..\jdk, on UNIX it first looks in ../../jdk. If no JDK
# is found there, it looks in the PATH.
#
#SetJavaHome C:\Oracle\Middleware\jdev_11114\jdk160_21
SetJavaHome C:\Program Files\Java\jdk1.6.0_24
#
# MaxPermSize is required to run JDeveloper with Sun Microsystems virtual
# machine (-client and -server). The default value is 64M, which isn't
# enough to run JDeveloper successfully. With the default value, JDeveloper
# will end up running out of memory at some point in time. For technical
# details, see: http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
#
AddVMOption -XX:MaxPermSize=256M
#
#added on 10/04/2011 to connect to oracle 9 with Greek regional settings
AddVMOption -Duser.timezone=UTC+02:00
#
# Replace heavyweight AWT controls with lightweight implementations.
#
AddVMOption -Xbootclasspath/p:../lib/lwawt.jar
#
# Don't swap the entire JDev process out of memory when minimizing the main window.
#
AddVMOption -Dsun.awt.keepWorkingSetOnMinimize=true
#
# Prevent Swing painting issues and hangs on some graphics cards and/or
# multiple monitor setups and/or Windows 7.
#
AddVMOption -Dsun.java2d.noddraw=true
#
# Automatically dump heap on OutOfMemoryError.
# The heap dump is in HPROF binary format, and so it can be analyzed using
# any tools that can import this format. Examples are jhat, NetBeans and YourKit.
# By default the heap dump is created in a file called java_pid
# working directory of the VM.
#
AddVMOption -XX:+HeapDumpOnOutOfMemoryError
#
# Option to enable OWSM policy types RM and Management on the policy configuration
# dialog for a web service.
# The same option, if set to true, also shows the policy configuration dialog for
# web service client as well.
# This flag exists so that when OWSM support for RM and Management policy
# types for WLS becomes available in the server module, removing this flag or
# setting it to 'true' will bring those options in JDev WS policy configuration.
#
AddVMOption -Doracle.jdeveloper.webservice.showAllOwsmPolicyTypes=false
#
# Controls the acess to OWSM policy property override dialog from the client policy
# configuration dialog.
#
AddVMOption -Doracle.jdeveloper.webservice.hidePropertyOverride=false
#
# Prevents the desktop hanging when debugging JDev on Linux and hitting a breakpoint with a popup open.
# See Sun Bug: 6714678 (http://bugs.sun.com/view_bug.do?bug_id=6714678)
# Note: This only prevents the hang when debugging JDev itself. To prevent hanging with other
# projects add this flag to the java options for the process to be debugged.
#
AddVMOption -Dsun.awt.disablegrab=true
....
What worries me most, is when each newer version of the I.D.E. or Sun jdk becomes available, if one is forced to setup from scratch, might not remember all the necessary steps to edit properly the new configuration files and continue with the current project. So backing up the jdev configuration files sounds like a good, proactive idea!
Subscribe to:
Posts (Atom)