Well scanning has a lighter classloader and TomEEWebappClassLoader has some workaround for ears scanning dont use which can explain why you have this behavior. About the trainling slash I guess jersey should fix it - we should just reuse tomcat one there.
Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber <http://www.tomitribe.com> | JavaEE Factory <https://javaeefactory-rmannibucau.rhcloud.com> 2016-06-20 10:05 GMT+02:00 rvinjamu <[email protected]>: > While i work on creating a sample application that shows the PARENT FIRST > class-loading of TomEE Plus, I was able to figure out some extent as to why > Jersey does not work with TomEE when packaged in > EAR/WAR-MODULE/WEB-INF/lib. > I removed all the Jar conflicts and ensured that Jersey libraries are only > available from EAR-module/war-module/web-inf/lib. My observations are as > here under: > > I notice that my REST Application and resources are examined twice. Once by > OpenEJB container and once by the Jersey Container Servlet. So the first > time when resource uris are figured out, the classloader used is > org.apache.openejb.core.TempClassLoader and (strangely !) it is able to > locate resources from > WEB-INF/lib of my REST Web module. The getResources(String name) method > fired on this classloader returns Jar URLs - each Jar URL having URI like > this: > > file:/C:/installations/otmm-tomee/apache-tomee-plus-7.0.0/apps/myear/restapi/WEB-INF/lib/myrestresources.jar!/com/xyz/pqr/restapi. > I see that all my REST resources are properly identified. One point to > notice is that the URI has no trailing slash. > > However, the REST application is invoked second time from Jersey Servlet. > While figuring out resources, the classloader used is an instance of > "org.apache.tomee.catalina.TomEEWebappClassLoader" > and it returns each URI with a trailing slash as follows. > > > "jar:file:/C:/installations/otmm-tomee/apache-tomee-plus-7.0.0/apps/artesia/restapi/WEB-INF/lib/otmm-rest-representations.jar!/com/opentext/mediamanager/restapi/" > - Notice the trailing slash. This was not there when TempClassLoader is > used. Jersey does some substring stuff and the trailing slash upsets > Jersey's processing and it fails to identify the REST resources. Not sure > whether there is anything there in java.lang.ClassLoader contract that > getResource(String name) can/should n't list resource URIs with trailing > slash. Therefore cannot say whether the getResource implementation of > TomEEWebappClassLoader is right or wrong. But this is the reason as to why > Jersey fails to identify REST resources. > > > > -- > View this message in context: > http://tomee-openejb.979440.n4.nabble.com/Classloading-issues-integrating-Jersey-2-16-and-apache-tomee-plus-7-0-0-tp4678794p4678970.html > Sent from the TomEE Dev mailing list archive at Nabble.com. >
