|
Re: Using JNDI in a plugin project [message #272703 is a reply to message #272667] |
Sun, 26 September 2004 12:10 |
Eclipse User |
|
|
|
Originally posted by: igorf.ca.ibm.com
You need to set thread context classloader before calling JNDI. It's
been a while since I looked at eclipse classloading, but I believe it
creates separate classloader for each plugin and uses delegation to load
classes from required plugins.
Ian Phillips wrote:
> I'm trying to write a plugin which uses JNDI (to get at JMS administered
> objects), the ClassLoader seems to be doing wierd things which prevent
> it from working.
>
> I have 2 plugins: one is just a container for a vendor supplied JAR
> file, the other is my project. At first I thought that maybe I'd screwed
> up my manifest (using OSGi style plugins) but now I'm not sure. I've
> tried this code:
>
> try {
> Class a =
> Class.forName("com.evermind.server.ApplicationClientInitialContextFactory ");
>
>
>
> Object o = a.newInstance();
> System.out.println("o: " + o);
> System.out.println("a loader: " + a.getClassLoader());
> System.out.println("b loader: " +
> this.getClass().getClassLoader());
> } catch (Exception e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> try {
> context = new InitialContext(props);
> System.out.println("context: " + context);
> return context;
> } catch (NamingException e) {
> e.printStackTrace();
> throw new RuntimeException(e);
> }
>
> and get this result:
>
> o: com.evermind.server.ApplicationClientInitialContextFactory@7ab1ba
> a loader: org.eclipse.core.runtime.adaptor.EclipseClassLoader@8e31e
> b loader: org.eclipse.core.runtime.adaptor.EclipseClassLoader@f08d6f
> javax.naming.NoInitialContextException: Cannot instantiate class:
> com.evermind.server.ApplicationClientInitialContextFactory [Root
> exception is java.lang.ClassNotFoundException:
> com.evermind.server.ApplicationClientInitialContextFactory]
> at
> javax.naming.spi.NamingManager.getInitialContext(NamingManag er.java:652)
>
>
> I'm confused as to why 2 different ClassLoaders are being used, if
> anybody has any pointers or suggestions I'd be grateful.
>
> Ian.
>
|
|
|
Powered by
FUDForum. Page generated in 0.07177 seconds