Discussion:
EAR/WAR class loader rules
awmurray
2017-12-12 15:38:15 UTC
Permalink
I think I have a class loader with the an EAR containing 2 WARs. This used
to
work under a much older version of TomEE but it isn't working under TomEE+
7.0.2. I see in the (limited :)) documentation that there are some changes
in the EAR/WAR class loader rules which might affect class visibility.

I have this in tomee/apps/myappEAR/webModuleOne/WEB-INF/web/xml:

<display-name>webModuleOne</display-name>
<context-param>
<param-name>resteasy.providers</param-name>
<param-value>com.widgets.CustomThrowableMapper</param-value>
</context-param>
<context-param>
<param-name>resteasy.resources</param-name>
<param-value>
[a comma separated list of classes omitted]
</param-value>
</context-param>

The exception is can't find com.widgets.CustomThrowableMapper:

java.lang.ClassNotFoundException: com.widgets.CustomThrowableMapper
at
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
at
org.apache.tomee.catalina.TomEEWebappClassLoader.loadWithDelegate(TomEEWebappClassLoader.java:211)
at
org.apache.tomee.catalina.TomEEWebappClassLoader.loadClass(TomEEWebappClassLoader.java:201)
at
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
at
org.apache.openejb.server.rest.RESTService.appProviders(RESTService.java:567)
at
org.apache.openejb.server.rest.RESTService.addAppProvidersIfNeeded(RESTService.java:296)
at
org.apache.openejb.server.rest.RESTService.afterApplicationCreated(RESTService.java:132)
at
org.apache.tomee.webservices.TomeeJaxRsService.afterApplicationCreated(TomeeJaxRsService.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


EDIT: Also, the class it is looking for is here:
tomee/apps/myappEAR/webModuleOne/WEB-INF/classes/com/widgets/CustomThrowableMapper.class.
I have attempted to somehow list this class in the
myappEAR/META-INF/MANIFEST.MF file to give the EAR visibility but it didn't
work so I'm not sure that is the right solution.



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
awmurray
2017-12-13 16:22:55 UTC
Permalink
For the archives:

After some time in the debugger stepping through the deployment process, it
looks like the class loader for the WAR CAN see the class- but perhaps it is
having trouble when actually loading the class.

The class does have a private constructor with static initialized fields, so
I don't think this is a class loader EAR/WAR issue at all.





--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Loading...