Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Deploying simple HttpServlet to virgo tomcat(Error deploying simple HttpServlet to virgo tomcat ClassNotFoundException)
Deploying simple HttpServlet to virgo tomcat [message #674036] Wed, 25 May 2011 15:47 Go to next message
Piotr Jaworowski is currently offline Piotr JaworowskiFriend
Messages: 3
Registered: May 2011
Junior Member
I'm trying to deploy simple web OSGI bundle, with simple HttpServlet on virgo-tomcat-server-3.0.0.M04 (you can find the project in the attachment).

The servlet is defined inside the web.xml file in following way:
<web-app>
	<display-name>Servlet_Test</display-name>
	<description>Servlet Test</description>
	<servlet>
		<servlet-name>welcomeServlet</servlet-name>
		<servlet-class>com.test.web.simple.servlet.WelcomeServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>welcomeServlet</servlet-name>
		<url-pattern>/welcomeServlet</url-pattern>
	</servlet-mapping>
	<session-config>
		<session-timeout>30</session-timeout>
	</session-config>
</web-app>


When I call the servlet I'm getting following error.
[b]HTTP Status 500 - [/b]
...
javax.servlet.ServletException: Wrapper cannot find servlet class com.test.web.simple.servlet.WelcomeServlet or a class it depends on
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	org.eclipse.virgo.web.tomcat.support.ApplicationNameTrackingValve.invoke(ApplicationNameTrackingValve.java:29)
	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	java.lang.Thread.run(Unknown Source)


with following error in the bundle error log:
java.lang.ClassNotFoundException: com.test.web.simple.servlet.WelcomeServlet 
	at org.eclipse.gemini.web.tomcat.internal.loading.BundleWebappClassLoader.loadClass(BundleWebappClassLoader.java:286) 
	at java.lang.ClassLoader.loadClass(Unknown Source) 
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095) 
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809) 
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129) 
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
	at org.eclipse.virgo.web.tomcat.support.ApplicationNameTrackingValve.invoke(ApplicationNameTrackingValve.java:29) 
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555) 
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) 
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) 
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) 
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) 
	at java.lang.Thread.run(Unknown Source) 
25-May-2011 12:09:31 org.apache.catalina.core.StandardWrapperValve invoke 


Note that servlet class specified in web.xml is correct.
What am i doing wrong? I it possible to expose the servlet in the way I'm doing.

Thanks in advance
Re: Deploying simple HttpServlet to virgo tomcat [message #674062 is a reply to message #674036] Wed, 25 May 2011 17:17 Go to previous messageGo to next message
rshelley  is currently offline rshelley Friend
Messages: 59
Registered: April 2010
Member
Try putting your binaries in /WEB-INF/classes

/WEB-INF/classes/com/test/web/simple/servlet/WelcomeServlet.class
Re: Deploying simple HttpServlet to virgo tomcat [message #674616 is a reply to message #674062] Fri, 27 May 2011 15:06 Go to previous messageGo to next message
Piotr Jaworowski is currently offline Piotr JaworowskiFriend
Messages: 3
Registered: May 2011
Junior Member
Thanks, this solution is working... but does it make sense?

Let's take scenario:
Bundle A: contains the HttpServlet implementation (but does not expose it)
Bundle B: imports the servlet but is not able to expose that via web.xml!

I thought that virgo's osgi based approach should allow me to do that... Any thoughts.
Re: Deploying simple HttpServlet to virgo tomcat [message #674696 is a reply to message #674616] Fri, 27 May 2011 22:45 Go to previous messageGo to next message
rshelley  is currently offline rshelley Friend
Messages: 59
Registered: April 2010
Member
It has nothing to do with OSGI. Web Archives (WARs), by default, have a classpath of "./WEB-INF/classes,./WEB-INF/lib"

You can force your the container to look for your classes at the root of your WAR (if you so desire) by setting the "Bundle-ClassPath" in the MANIFEST.MF to "Bundle-ClassPath: ." Personally, however, I wouldn't. It's expected in a WAR that the WEB-INF/classes be the location of your compiled class files.

And in your example, if BundleA contains HttpServlet but doesn't expose it, BundleB can't see it to use it. BundleA needs to export it if BundleB is going to import it.
Re: Deploying simple HttpServlet to virgo tomcat [message #675437 is a reply to message #674696] Tue, 31 May 2011 14:31 Go to previous messageGo to next message
Piotr Jaworowski is currently offline Piotr JaworowskiFriend
Messages: 3
Registered: May 2011
Junior Member
Thanks Ryan,

"Bundle-ClassPath: ." is what i was looking for. So the part I was missing is that the web components primarily are treated as WAR deployables not as OSGI bundles. As far as i know the default class path for osgi bindles is ".".

Thanks Again
Re: Deploying simple HttpServlet to virgo tomcat [message #675504 is a reply to message #675437] Tue, 31 May 2011 17:33 Go to previous message
rshelley  is currently offline rshelley Friend
Messages: 59
Registered: April 2010
Member
In my (limited) experience and opinion, the WAR could be considered a Web Bundle. You can still import/export bundles/packages and use services exported by other bundles, all from within the WAR. That's how my prototype works right now. My WAR is VERY small. It's simply URL mappings. The services that support the URL mappings are OSGI bundles that export their services to the WAR. This way I can deploy patches to the services without restarting the WAR.

Glad you got it working!
Previous Topic:Virgo OSGI lifecycle with dependencies
Next Topic:chaining Sprign's ContextRefreshedEvent to Virgo's OsgiBundleContextRefreshedEvent
Goto Forum:
  


Current Time: Fri Mar 29 11:35:15 GMT 2024

Powered by FUDForum. Page generated in 0.03211 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top