Summary: | ClassLoader's don't handle CORBA or EJB lookups within a plug-in | ||
---|---|---|---|
Product: | [Eclipse Project] Platform | Reporter: | Jason Weiss <weissj> |
Component: | Resources | Assignee: | DJ Houghton <dj.houghton> |
Status: | RESOLVED WONTFIX | QA Contact: | |
Severity: | blocker | ||
Priority: | P1 | CC: | david_williams, mcope-ebay7318, teva.lautier, vgusev |
Version: | 1.0 | Keywords: | readme |
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows NT | ||
Whiteboard: |
Description
Jason Weiss
2002-02-01 00:29:29 EST
By any chance are you running Eclipse with a different security policy set? That is, are you starting up with Eclipse with -Djava.security.manager or -Djava.security.policy=... specified? This can affect what classes a URLClassLoader has permission to load. I have not knowingly changed any security policy. In fact, here is the batch file (running on Windows) used to start eclipse: ============================= @echo off echo Setting up the Eclipse environment... SET JAVA_HOME=D:\jdk13 SET J2EE_HOME=d:\j2ee1_3 SET PATH=d:\eclipse;%JAVA_HOME%\bin;%J2EE_HOME%\bin;%SYSTEMROOT%;%SYSTEMROOT% \system32;. REM ************** REM * Environment Variables in Use REM ************** SET CLASSPATH=. echo Launching Eclipse Now... eclipse.exe -consolelog -debug I had same problem with ant plugin and I was able to trace it down. Following two code snippets show the problem ==> this one works fine in plugin Object o; o = new my.test.pkg.TestClass(); o = Class.forName("my.test.pkg.TestClass").newInstance(); ==> this one throws java.lang.ClassNotFoundException: my.test.pkg.TestClass ClassLoader cl = Thread.currentThread().getContextClassLoader(); o = cl.loadClass("my.test.pkg.TestClass").newInstance(); I’ve checked that com.sun.naming.internal.VersionHelper12#loadClass(String) uses context class loader, so does sun’s implementation of Trax API. Hope this helps. -- Sincerely, Igor Fedorenko PS: this behaviour was observed in Eclipse 2.0 build 20020226. Try the following: 1. Create a thread in which to run your code. 2. send yourThread.setContextClassLoader(yourClassLoader); // you can find your classloader by grabbing a class it loaded (YourPluginClass.class.getClassLoader()) 3. run your code in the created thread. If you set the context class loader for the current thread, you are competing with other users of the thread (all of eclipse) so the results will be unpredictable. John has provided a work-around. Include in README or ISV doc. RE my comment "If you set the context class loader for the current thread, you are competing with other users of the thread (all of eclipse) so the results will be unpredictable.": In practice this will not be a problem, provided you reset the context class loader back to its original value when your use in the current thread is complete. *** Bug 40975 has been marked as a duplicate of this bug. *** *** Bug 21299 has been marked as a duplicate of this bug. *** |