views:

1897

answers:

7

Hi!

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.enterprise.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?

A: 

Same problem comes with the Eclipse RCP application

Shahid K.

Shahid K
how is this an answer to the problem?
fuzzy lollipop
A: 

This link might help with the JNDI lookups, it is looking up queues but EJBs should be almost the same code.

fuzzy lollipop
This isn't exactly my problem - The lookup works all right, if I either deploy the web-app to the appserver or if I perform the lookup from a CLI application. I only get this error if I try to look up from within the GWT-Devmode.
nsn
A: 

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.

Pascal Thivent
Nope, this didn't work either - i get the same error. I even tried adding all JARs in the glassfish/modules folder - the lookup still failed
nsn
A: 

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.

David Nouls
The SessionBeans themselves run on Glassfish, and as I develop using Eclipse I use the GWT-Eclipse plugin. So the GWT-Application itself is running in the embedded jetty. You suggest running the application itself on glassfish and use devmode without it's server... But don't I then need to redeploy the webapp every time I make changes to the sourcecode?
nsn
Ok, I was able to set up devmode using -noserver.The Webapp now runs on the glassfish server and I can still debug it in devmode. But I now have to redeploy the app any time I make a change to the source code, this is almost unbearable as it prolongs the development cycle.Funny thing is: using this method makes the JNDI-lookup obsolete because I could just use dependency injection to get the EJBs... ;)
nsn
Yes, you are right, you need to redeploy. But, if it is using hotdeployment you don't notice it much. For UI changes you do not need to redeploy. You just need to build once so that the bootstrap js file is available.
David Nouls
A: 

I got the same problem till I had all jars of the glassfish module directory into the war/WEB-INF/lib directory in the eclipse project of my GWT application.

  • Serge Bajda
Serge Bajda
took a while for me to get back, but: Thanks a bunch, this solution works perfectly!I had to fix my pom.xml though, as the build process included all jars in WEB-INF/lib
nsn
A: 

Add all jars from glassfish modules directory into the war/WEB-INF/lib directory of your eclipse GWT project and it would be ok. It works for me.

Serge Bajda

Serge Bajda
A: 

I got the same problem, and I solved it this way: http://code.google.com/intl/hu-HU/eclipse/docs/faq.html#gwt_in_eclipse_for_java_ee

HegiBoy