Thursday, May 07, 2009

JNDI & EclipseLink in GWT 1.6.x


New version of GWT (1.6.x) comes with a new embedded web server, Jetty, rather than Tomcat. When GWT team was determining 1.6 milestone, they started this issue to discussion (here) Finally, cons and pro's of Jetty overcome Tomcat, and GWT 1.6 is shipped with a new embedded web server.

Among other sturctural changes, this change cause some issues. JNDI issue is one of them. In our legacy project we were using Tomcat and our JNDI settings was defined in context.xml. With a new jetty server, JNDI settings has to be defined in web-jetty.xml. But there is a undocumented (actually misdocumented) point, which should be kept in mind. When defining JNDI variable in jetty-web.xml, you should use full qualified name, unlike in Tomcat.

For example, in our old legacy code, Tomcat setting for our data source was defined as :
jdbc/SybaseIQ. But jetty expect full path such as: (java:comp/env/jdbc/SybaseIQ). Please note but you still need to use shorter name jdbc/SybaseIQ in your code or persistence.xml.
Otherwise you would get
"javax.naming.NameNotFoundException" exception and even lost yourself in complex advises from discussion groups.


Another point should be kept in mind, if you use another JPA implementation rather than Datanucleus, which comes with Google Application Engine, when you create your GWT project, do not select Google Application Engine option.


No comments: