External JNDI-Lookup on Glassfish v3

419 views
Skip to first unread message

Michael Bayer

unread,
Jan 25, 2010, 8:31:54 AM1/25/10
to Google Web Toolkit
Hi there!

I recentrly upgraded to GWT 2.0 and Glasshfish v3, and now I can't
seem to get JNDI lookups to work.

I have Glassfish running on localhost and want to access EJBs deployed
there from within GWT Dev-Mode.
I did add the glassfish-runtime to my project in eclipse but I always
get this error:

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 like I don't have the necessary jars, but I get this error
even if I explicitly add glassfish-naming.jar to the classpath. I even
tried using the jetty-naming implementation, but to no avail (for
other reasons...).

When I deploy the webapp into the appserver everything works as
expected.

Did anybody manage to look up an EJB on an external appserver using
jndi from within devmode?

Any help will be greatly appreciated...

jocke eriksson

unread,
Jan 25, 2010, 3:11:53 PM1/25/10
to google-we...@googlegroups.com
Will not work because GWT Dev-Mode does not run on Glassfish. It could work if you have them as remote though, but it is not recommended.     

2010/1/25 Michael Bayer <nightspawn.com@googlemail.com>

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


jocke eriksson

unread,
Jan 25, 2010, 3:21:06 PM1/25/10
to google-we...@googlegroups.com
I'm sorry i missed that you do want to access them external, have a look here.

Michael Bayer

unread,
Jan 27, 2010, 5:15:51 AM1/27/10
to Google Web Toolkit

On Jan 25, 9:21 pm, jocke eriksson <jock...@gmail.com> wrote:
> I'm sorry i missed that you do want to access them external, have a look
> here.
>

> http://stackoverflow.com/questions/2087938/glassfish-v3-jndi-entry-ca...


Hmm... I can't seem to get it to work...
I've further isolated the problem: when I run the webapp in
development-mode gf-client.jar is not in the classpath (or some jars
it refers to are not, not sure which).
I've made a simple test setup, an EJB-Project containing a simple
hello world bean running on the local glassfish and a slightly
modified Web Application Starter Project trying to look up said bean.
Additionally I wrote a small test class, and when I add gf-client.jar
to the build path in eclipse it executes correctly.

I tar'd the workspace containing both projects and put it on my
webspace (http://satansoft.de/jnditest/jnditest.tgz , sorry for the
~70MB download) in case someone wants to try for themselves.
You might have to edit some settings, namely the GLASSFISH_HOME
variable in eclipse, or you can simply run it from the command line
(if you want to use the run.sh provided in the archive you might need
to alter some paths there too).

So:
How do I add gf-client.jar and all it's dependencies specified in the
MANIFEST.MF to the dev-mode-jetty's classpath?

Michael Bayer

unread,
Jan 28, 2010, 10:31:05 AM1/28/10
to Google Web Toolkit
All right - I've further narrowed the problem down:

A .jar file can refer to other jars in it's manifest using the Class-
Path setting, gf-client.jar does just this.

I've now created a simple test case:
http://satansoft.de/jnditest/echo.zip (~5kb)

if you run ant in builds two jars: echo.jar containing a class Echo
and ref.jar containing nothing but a reference to echo.jar.
If I now run EchoTest and just add ref.jar to the classpath everything
works as expected.
But if I try to just add ref.jar to a project build path in eclipse I
can't refer to Echo.
It seems as if eclipse just doesn't import the jars referenced in the
MANIFEST.MF's Class-Path setting.

This still doesn't explain why in my other testcase I can execute the
Test from within eclipse, but it shows that there is a problem
somewhere...


Reply all
Reply to author
Forward
0 new messages