I am trying to perform a JNDI-lookup from within the GWT devmode.
I have a local glassfishv3 running the EJBs I want to look up. If i deploy the GWT-Webapp into said glassfish everything works as expected. But if I try to look up the EJBs from within devmode I get this Exception:
javax.naming.NamingException: Lookup failed for 'myBean' in SerialContext [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext [Root exception is java.lang.NullPointerException]] ... Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext [Root exception is java.lang.NullPointerException]
at com.sun.e开发者_高级运维nterprise.naming.impl.SerialContext.getProvider (SerialContext.java:276)
at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:430)
... 22 more Caused by: java.lang.NullPointerException
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider (SerialContext.java:297)
at com.sun.enterprise.naming.impl.SerialContext.getProvider (SerialContext.java:271)
... 23 more
It seems that the embedded jetty can't find the class "SerialContextProvider" in the classpath.
I tried adding gf-client.jar and glassfish-naming.jar to the classpath (in addition to adding glassfish v3 to the target runtimes in eclipse), but to no avail.
I even put together a small sample (found here: http://satansoft.de/jnditest/jnditest.tgz) containing a simple EJB project as well as a GWT project that performs the lookup. The archive also contains a small CLI client that works perfectly fine when run with gf-client.jar in the classpath.
I also asked this question on the official gwt mailing list, but nobody on there was able to help me.
So: has anybody been able to perform JNDI lookups from within GWT devmode into glassfish v3?
Add all jars from the Glassfish modules directory into the war/WEB-INF/lib directory of your Eclipse GWT project.
I didn't check that but I'm not sure that Jetty will pick up all the jars that are referenced in the manifest of gf-client.jar
(refer to the GlassFish EJB FAQ or this previous answer for more details on that). So, while I'm sure that this JAR works well when using a standalone client (because I tested this), I didn't try with an embedded Jetty.
So, please try to add the following JARs manually: glassfish-naming.jar
, internal-api.jar
, javax.ejb.jar
, hk2-core.jar
, auto-depends.jar
, glassfish-api.jar
.
I don't understand your setup. Either you run in Glassfish or you run in the embedded Jetty. If you are running in Jetty it will not work since you are running in the wrong server.
I am also using session beans and other J2EE technology in combination with GWT and it works very well.
The only thing you need to do is to NOT run the Jetty server. I start the dev mode with -noserver and run on Glassfish. If you set this up correctly you can use DevMode and the server code is running fine in glassfish. Deployment is a bit more difficult since you need to make sure that the glassfish server is uptodate.
精彩评论