Hi,
I have a web-bundle that uses a custom ServletFilter. The filter class is located in:
bundle-root
xxx/yyy/Test1Filter.class
WEB-INF
META-INF
The manifest.mf contains the classpath:
Bundle-ClassPath: .,WEB-INF/lib/someJar.jar
It is a typical osgi bundle build with tycho. The problem is that during startup of virgo a ClassNotFoundException is thrown:
[2012-11-23 15:24:15.704] ERROR start-signalling-5 o.a.catalina.core.ContainerBase.[Catalina].[localhost].[/csar] Exception starting filter Test1Filter java.lang.ClassNotFoundException: xxx.yyy.Test1Filter
at org.eclipse.gemini.web.tomcat.internal.loading.BundleWebappClassLoader.loadClass(BundleWebappClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507)
First I thought I might have to put the classes under WEB-INF/classes because it is a web-bundle. So I moved the classes to:
bundle-root
WEB-INF/classes/xxx/yyy/Test1Filter.class
META-INF
This indeed works if I adjust the classpath accordingly:
Bundle-ClassPath: .,WEB-INF/classes,WEB-INF/lib/someJar.jar
The "classes" directory can also be named differently. The only matter seems to be that it is within the WEB-INF directory.
The funny thing is that classes other than filters are found in the . classpath.
For example I added a ServletRequestListener in the web.xml which I put as such:
bundle-root
xxx/yyy/TestListener.class
WEB-INF/classes/xxx/yyy/Test1Filter.class
META-INF
The listener class is resolved just fine whereas the filter class must reside somewhere within WEB-INF. The osgi specification about web-bundles says
Unlike a WAR, a WAB is not constrained to package classes and code resources in the WEB-INF/
classes/ directory or dependent JARs in WEB-INF/lib/ only. These entries can be packaged in any way
that's valid for an OSGi bundle as long as such directories and JARs are part of bundle class path as set
with the Bundle-ClassPath header and any attached fragments.
So I assume this is some kind of weird bug? Or am I missing something?
Regards,
Thorsten
[Updated on: Fri, 23 November 2012 14:53]
Report message to a moderator