Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » plugin NoClassDefFoundException during client/server communication
plugin NoClassDefFoundException during client/server communication [message #77558] Wed, 18 June 2003 07:39 Go to next message
Eclipse UserFriend
Originally posted by: Frank_van_den_Beuken.programmingresearch.com

Hi,
I'm trying to plug an existing J2EE client application into Eclipse and am
getting a NoClassDefFoundError.
Originally, I didn't have the runtime tab of the plugin.xml set correctly,
but after correctly adding all required jars there, I still get the
following exception when I try to execute an action of the plug-in (which
compiles and launches correctly):

javax.naming.NoInitialContextException in class
com.qasystems.qstudio.java.license.License@1fc4b8

javax.naming.NoInitialContextException: Cannot instantiate class:
org.jnp.interfaces.NamingContextFactory. Root exception is
java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory

at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:297)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286 )

at java.lang.ClassLoader.loadClass(ClassLoader.java:253)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313 )

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:195)

at
com.sun.naming.internal.VersionHelper12.loadClass(VersionHel per12.java:45)

at javax.naming.spi.NamingManager.getInitialContext(NamingManag er.java:652)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext .java:246)

at javax.naming.InitialContext.init(InitialContext.java:222)

at javax.naming.InitialContext.<init>(InitialContext.java:198)

....


The jar that contains class NamingContextFactory is on the runtime tab of
the plugin.xml and other jars on there are found correctly.
The code causing the problem is attempting to comunicate with a J2EE server.
Is there some conflict between the eclipse classloading mechanism and the
J2EE use of it?
Any suggestions?

Thanks in advance,
Frank
Re: plugin NoClassDefFoundException during client/server communication [message #77603 is a reply to message #77558] Wed, 18 June 2003 08:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: joaocm.ideais.com.br

I had the same problem. The solution is change the classloader of de current
thread.

Try :

Thread.currentThread().setContextClassLoader(ThePlugin.class .getClassLoader(
));

For me it worked well.

Let me know if this stuff helped you too.

[]'s,

Joao

"Frank van den Beuken" <Frank_van_den_Beuken@programmingresearch.com> wrote
in message news:bcpj0u$es6$1@rogue.oti.com...
> Hi,
> I'm trying to plug an existing J2EE client application into Eclipse and am
> getting a NoClassDefFoundError.
> Originally, I didn't have the runtime tab of the plugin.xml set correctly,
> but after correctly adding all required jars there, I still get the
> following exception when I try to execute an action of the plug-in (which
> compiles and launches correctly):
>
> javax.naming.NoInitialContextException in class
> com.qasystems.qstudio.java.license.License@1fc4b8
>
> javax.naming.NoInitialContextException: Cannot instantiate class:
> org.jnp.interfaces.NamingContextFactory. Root exception is
> java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
>
> at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>
> at java.security.AccessController.doPrivileged(Native Method)
>
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
>
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286 )
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
>
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313 )
>
> at java.lang.Class.forName0(Native Method)
>
> at java.lang.Class.forName(Class.java:195)
>
> at
> com.sun.naming.internal.VersionHelper12.loadClass(VersionHel per12.java:45)
>
> at
javax.naming.spi.NamingManager.getInitialContext(NamingManag er.java:652)
>
> at javax.naming.InitialContext.getDefaultInitCtx(InitialContext .java:246)
>
> at javax.naming.InitialContext.init(InitialContext.java:222)
>
> at javax.naming.InitialContext.<init>(InitialContext.java:198)
>
> ...
>
>
> The jar that contains class NamingContextFactory is on the runtime tab of
> the plugin.xml and other jars on there are found correctly.
> The code causing the problem is attempting to comunicate with a J2EE
server.
> Is there some conflict between the eclipse classloading mechanism and the
> J2EE use of it?
> Any suggestions?
>
> Thanks in advance,
> Frank
>
>
Re: plugin NoClassDefFoundException during client/server communication [message #77684 is a reply to message #77603] Wed, 18 June 2003 10:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Frank_van_den_Beuken.programmingresearch.com

Many thanks Joao, it works for me also.
I must still have a better look at this to understand what is going on with
the classloaders, and why this works.

Thanks again,
Frank

"Joao Machado" <joaocm@ideais.com.br> wrote in message
news:bcpm2t$i4v$1@rogue.oti.com...
> I had the same problem. The solution is change the classloader of de
current
> thread.
>
> Try :
>
>
Thread.currentThread().setContextClassLoader(ThePlugin.class .getClassLoader(
> ));
>
> For me it worked well.
>
> Let me know if this stuff helped you too.
>
> []'s,
>
> Joao
>
> "Frank van den Beuken" <Frank_van_den_Beuken@programmingresearch.com>
wrote
> in message news:bcpj0u$es6$1@rogue.oti.com...
> > Hi,
> > I'm trying to plug an existing J2EE client application into Eclipse and
am
> > getting a NoClassDefFoundError.
> > Originally, I didn't have the runtime tab of the plugin.xml set
correctly,
> > but after correctly adding all required jars there, I still get the
> > following exception when I try to execute an action of the plug-in
(which
> > compiles and launches correctly):
> >
> > javax.naming.NoInitialContextException in class
> > com.qasystems.qstudio.java.license.License@1fc4b8
> >
> > javax.naming.NoInitialContextException: Cannot instantiate class:
> > org.jnp.interfaces.NamingContextFactory. Root exception is
> > java.lang.ClassNotFoundException:
org.jnp.interfaces.NamingContextFactory
> >
> > at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> >
> > at java.security.AccessController.doPrivileged(Native Method)
> >
> > at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> >
> > at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
> >
> > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286 )
> >
> > at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
> >
> > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313 )
> >
> > at java.lang.Class.forName0(Native Method)
> >
> > at java.lang.Class.forName(Class.java:195)
> >
> > at
> >
com.sun.naming.internal.VersionHelper12.loadClass(VersionHel per12.java:45)
> >
> > at
> javax.naming.spi.NamingManager.getInitialContext(NamingManag er.java:652)
> >
> > at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext .java:246)
> >
> > at javax.naming.InitialContext.init(InitialContext.java:222)
> >
> > at javax.naming.InitialContext.<init>(InitialContext.java:198)
> >
> > ...
> >
> >
> > The jar that contains class NamingContextFactory is on the runtime tab
of
> > the plugin.xml and other jars on there are found correctly.
> > The code causing the problem is attempting to comunicate with a J2EE
> server.
> > Is there some conflict between the eclipse classloading mechanism and
the
> > J2EE use of it?
> > Any suggestions?
> >
> > Thanks in advance,
> > Frank
> >
> >
>
>
Re: plugin NoClassDefFoundException during client/server communication [message #79422 is a reply to message #77684] Fri, 20 June 2003 14:54 Go to previous message
Eclipse UserFriend
Originally posted by: John_Arthorne.oti.com_

Some applications make the assumption that the current thread's context
class loader will have access to all the classes it needs to load. This
is not the case in Eclipse (and in many other environments), because
each plugin has its own class loader, and the default application class
loader doesn't know how to load any plugin classes. By default, a
thread's context class loader inherits from its parent thread, and
ultimately from the application class loader. Since the application
class loader doesn't have access to your plugin JARs, it won't be able
to load anything.

Since many plugins may access a given thread, Eclipse cannot assign a
reasonable thread context class loader, which is why you run into this
problem. The only known work-arounds are to manually slam the context
class loader as suggested by Joao, or to put the JARs on the boot class
path where the application class loader can see them. Manually setting
the context classloader seems to be the better of these two options.

If you do this, it would be polite to change it back to the original
value when you're done:

ClassLoader original = Thread.currentThread().getContextClassLoader();
try {
ClassLoader newLoader = getClass().getClassLoader();
Thread.currentThread.setContextClassLoader(newLoader);
//code to access the library that needs the context loader
} finally {
Thread.currentThread().setContextClassLoader(original);
}
--


Frank van den Beuken wrote:
> Many thanks Joao, it works for me also.
> I must still have a better look at this to understand what is going on with
> the classloaders, and why this works.
>
> Thanks again,
> Frank
>
> "Joao Machado" <joaocm@ideais.com.br> wrote in message
> news:bcpm2t$i4v$1@rogue.oti.com...
>
>>I had the same problem. The solution is change the classloader of de
>
> current
>
>>thread.
>>
>>Try :
>>
>>
>
> Thread.currentThread().setContextClassLoader(ThePlugin.class .getClassLoader(
>
>>));
>>
>>For me it worked well.
>>
>>Let me know if this stuff helped you too.
>>
>>[]'s,
>>
>>Joao
>>
>>"Frank van den Beuken" <Frank_van_den_Beuken@programmingresearch.com>
>
> wrote
>
>>in message news:bcpj0u$es6$1@rogue.oti.com...
>>
>>>Hi,
>>>I'm trying to plug an existing J2EE client application into Eclipse and
>>
> am
>
>>>getting a NoClassDefFoundError.
>>>Originally, I didn't have the runtime tab of the plugin.xml set
>>
> correctly,
>
>>>but after correctly adding all required jars there, I still get the
>>>following exception when I try to execute an action of the plug-in
>>
> (which
>
>>>compiles and launches correctly):
>>>
>>>javax.naming.NoInitialContextException in class
>>>com.qasystems.qstudio.java.license.License@1fc4b8
>>>
>>>javax.naming.NoInitialContextException: Cannot instantiate class:
>>>org.jnp.interfaces.NamingContextFactory. Root exception is
>>>java.lang.ClassNotFoundException:
>>
> org.jnp.interfaces.NamingContextFactory
>
>>>at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>>
>>>at java.security.AccessController.doPrivileged(Native Method)
>>>
>>>at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>
>>>at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
>>>
>>>at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286 )
>>>
>>>at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
>>>
>>>at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313 )
>>>
>>>at java.lang.Class.forName0(Native Method)
>>>
>>>at java.lang.Class.forName(Class.java:195)
>>>
>>>at
>>>
>>
> com.sun.naming.internal.VersionHelper12.loadClass(VersionHel per12.java:45)
>
>>>at
>>
>> javax.naming.spi.NamingManager.getInitialContext(NamingManag er.java:652)
>>
>>>at
>>
> javax.naming.InitialContext.getDefaultInitCtx(InitialContext .java:246)
>
>>>at javax.naming.InitialContext.init(InitialContext.java:222)
>>>
>>>at javax.naming.InitialContext.<init>(InitialContext.java:198)
>>>
>>>...
>>>
>>>
>>>The jar that contains class NamingContextFactory is on the runtime tab
>>
> of
>
>>>the plugin.xml and other jars on there are found correctly.
>>>The code causing the problem is attempting to comunicate with a J2EE
>>
>>server.
>>
>>>Is there some conflict between the eclipse classloading mechanism and
>>
> the
>
>>>J2EE use of it?
>>>Any suggestions?
>>>
>>>Thanks in advance,
>>>Frank
>>>
>>>
>>
>>
>
>
Previous Topic:Need option to replace tab characters with spaces
Next Topic:Double click -> open file
Goto Forum:
  


Current Time: Mon Jun 09 16:42:49 EDT 2025

Powered by FUDForum. Page generated in 0.06372 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top