Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classloading issue in case of custom classloader usage #3227

Open
jerseyrobot opened this issue Sep 4, 2015 · 5 comments
Open

Classloading issue in case of custom classloader usage #3227

jerseyrobot opened this issue Sep 4, 2015 · 5 comments

Comments

@jerseyrobot
Copy link
Contributor

When Jersey is loaded via custom classloader it's failing with ClassNotFoundException:

**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              Caused by :java.lang.ClassNotFoundException: org.glassfish.jersey.internal.spi.AutoDiscoverable
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:335)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:302)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:180)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at java.lang.ClassLoader.defineClass1(Native Method)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:385)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:344)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:302)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:180)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at weblogic.utils.classloaders.FilteringClassLoader.findClass(FilteringClassLoader.java:106)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at weblogic.utils.classloaders.FilteringClassLoader.loadClass(FilteringClassLoader.java:91)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:180)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:43)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at java.lang.Class.forName0(Native Method)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at java.lang.Class.forName(Class.java:270)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.internal.util.ReflectionHelper$7.run(ReflectionHelper.java:403)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.internal.util.ReflectionHelper$7.run(ReflectionHelper.java:398)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at java.security.AccessController.doPrivileged(Native Method)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.internal.ServiceFinder$AbstractLazyIterator.hasNext(ServiceFinder.java:577)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.internal.ServiceFinder.toClassArray(ServiceFinder.java:418)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.internal.ServiceFinderBinder.configure(ServiceFinderBinder.java:90)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:171)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.hk2.utilities.binding.AbstractBinder.install(AbstractBinder.java:329)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.server.ServerBinder.configure(ServerBinder.java:94)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:171)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.internal.inject.Injections.bind(Injections.java:154)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:144)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:123)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:329)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:339)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
**** Error          Fri Aug 28 12:39:56 EDT 2015        1440779996519  /              at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:362)

The reason of such exception is that ServiceFinder(loaded by current custom classloader) is using current thread's context classloader for loading services and as a result such classes are not found. All those service classes are coming with current custom classloader and not available for thread's context classloader. What I'm asking for is to change such logic and do fallback to current classloader. Something like Validation library are doing - http://grepcode.com/file/repo1.maven.org/maven2/javax.validation/validation-api/1.1.0.Final/javax/validation/Validation.java?av=f
I already had email conversation with Marek Potociar regarding this clasloading issue and he agreed to look into fallback with own classloader usage.
Note, that javax.ws.rs.client.FactoryFinder is having the same problem.

Environment

Weblogic 12.1.3, Java7

Affected Versions

[2.19]

@jerseyrobot
Copy link
Contributor Author

@glassfishrobot Commented
Reported by yakimovich

@jerseyrobot
Copy link
Contributor Author

@glassfishrobot Commented
@AdamLindenthal said:
Hi, thanks for opening the issue.
If you already discussed with Marek, I guess I can but the issue to backlog.
In case you want to help us, feel free to create a small runnable reproducer test case and share it.

Regards,
Adam

@jerseyrobot
Copy link
Contributor Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JERSEY-2955

@jerseyrobot
Copy link
Contributor Author

@d0x7
Copy link
Contributor

d0x7 commented Oct 28, 2019

Soooo... this issue is still persisting for me. No comments from the authors? I need to load jersey resources from "modules" (not java 9 modules, just external JARs that are loaded at runtime), via a custom classloader for isolation (and some other reasons).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants