users@glassfish.java.net

Re: Glassfish V3 + Standalone client lookup session bean JNDI

From: <glassfish_at_javadesktop.org>
Date: Mon, 11 Oct 2010 05:52:05 PDT

I avoid the same problem by put following code:

            Class<?> clazz = Class.forName(this.getClass().getName());
            Thread thread = Thread.currentThread();
            ClassLoader classLoaderThread = thread.getContextClassLoader();
            System.out.println("ClassLoader for Thread : " + classLoaderThread);
            ClassLoader classLoaderClass = clazz.getClassLoader();
            System.out.println("ClassLoader for Class : " + classLoaderClass);
            thread.setContextClassLoader(classLoaderClass);

before the "context.lookup".
This change:
ClassLoader for Thread : org.eclipse.core.runtime.internal.adaptor.ContextFinder_at_1970ae0
to:
ClassLoader for Class : org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader_at_d19bc8
and works (at least in my case).

Best regards
Piotrek
[Message sent by forum member 'pichur']

http://forums.java.net/jive/thread.jspa?messageID=484879