Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Servlet Filter cannot be found in classpath other than WEB-INF/...(Exception starting filter Test1Filter java.lang.ClassNotFoundException:)
Servlet Filter cannot be found in classpath other than WEB-INF/... [message #987111] Fri, 23 November 2012 09:52 Go to next message
Thorsten Schlathölter is currently offline Thorsten Schlathölter
Messages: 207
Registered: February 2012
Location: Düsseldorf
Senior Member
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 09:53]

Report message to a moderator

Re: Servlet Filter cannot be found in classpath other than WEB-INF/... [message #987225 is a reply to message #987111] Sat, 24 November 2012 13:29 Go to previous messageGo to next message
Violeta Georgieva is currently offline Violeta Georgieva
Messages: 214
Registered: October 2010
Senior Member
Hi,

Can you provide some sample?

I tried one very simple application with Filter inside as your example and it is working as expected.
I tried it on Virgo Server for Apache Tomcat version 3.5.0

Regards
Violeta
Re: Servlet Filter cannot be found in classpath other than WEB-INF/... [message #987401 is a reply to message #987225] Mon, 26 November 2012 08:33 Go to previous message
Thorsten Schlathölter is currently offline Thorsten Schlathölter
Messages: 207
Registered: February 2012
Location: Düsseldorf
Senior Member
Hi Violeta,
thanks for the example. I have to admit, that I cannot reproduce the problem. Last friday/saturday it almost made me crazy but now I cannot reproduce it. My filter is an NTLM filter which extends jcifs NTLM filter which itself is provided via a bundle. The bundle was installed but while resolving my filter Virgo kept complaining about not being able to resolve javax.servlet.Filter. In this context I created a simple filter (like yours) to check if virgo could resolve the simple filter. I could swear that the simple filter was only resolved with the above class path issues.... In order to solve the real problem I ended up with copying the jcifs jar into my war bundle. And suddenly it worked. And now I am trying to step back and its simply not reproducible. I will keep an eye on it. Sry for wasting your time.

Regards,
Thorsten
Previous Topic:edit files from a staged bundle
Next Topic:SpringDM Managed Service List is not updated with new services
Goto Forum:
  


Current Time: Fri Apr 18 10:13:41 EDT 2014

Powered by FUDForum. Page generated in 0.01702 seconds