2

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?

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
nsn
  • 138
  • 2
  • 9
  • 1
    This doc may be useful: http://docs.sun.com/app/docs/doc/820-7695/beanv?l=en&a=view. It seems like there is a fair bit of configuration that has to happen for the Jetty server to access the bean on the remote GF. The most likely problem is the possibility that you skipped one, or configured the GWT app, not the server. – vkraemer Feb 04 '10 at 16:22

3 Answers3

1

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.

Community
  • 1
  • 1
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • 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 Feb 02 '10 at 13:38
1

Add all jars from the Glassfish modules directory into the war/WEB-INF/lib directory of your Eclipse GWT project.

Jamal
  • 763
  • 7
  • 22
  • 32
0

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
  • 1,895
  • 12
  • 21
  • 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 Feb 02 '10 at 14:05
  • 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 Feb 02 '10 at 15:03
  • 1
    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 Feb 03 '10 at 14:38