Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Starting Tomcat 7 as Embedded Server in OSGI Framework
Starting Tomcat 7 as Embedded Server in OSGI Framework [message #885224] Tue, 12 June 2012 16:26 Go to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 211
Registered: February 2012
Location: Düsseldorf
Senior Member
Hi,
as stated in some of my previous posts I am trying to find a solution for lifting my current server implementation to OSGI. I tried Virgo but due to the lack of support for PDE Bundles I am currently not able to use it. I am now thinking about going for Spring DM and an embedded Tomcat server. To be as close to the current virgo release I thought it should be a good idea to extract all relevant libs from the virgo respository. So basically I have chosen the following bundles to create a target platform:

Springframework 3.0.5
Catalina 7.0.26
Spring Osgi 1.2.1
plus all the required Bundles which I have also taken from the Virgo repository

Now I have two questions:
For Tomcat 5 and Tomcat 6 there is a catalina.start.osgi bundle that starts the tomcat server. I can't find an equivalent bundle for Tomcat 7. Needless to say that the existing catalina.start.osgi bundles do not work. So how can I start the embedded Tomcat 7. If nothing exists I could probably implement it by following this example: http://www.copperykeenclaws.com/embedding-tomcat-7/
And second: Does this approach makes sense at all? (Also having in mind that the osgi server should be used for RAP in the future.)

Thanks in advance.

Regards,
Thorsten
Re: Starting Tomcat 7 as Embedded Server in OSGI Framework [message #885261 is a reply to message #885224] Tue, 12 June 2012 17:43 Go to previous messageGo to next message
Violeta Georgieva is currently offline Violeta GeorgievaFriend
Messages: 244
Registered: October 2010
Senior Member
Hi,

You can try using Gemini Web.
Gemini Web is the Reference Implementation of the Web Applications Specification from the OSGi Alliance. It is derived from SpringSource OSGi Web Container and is the OSGi Web Container used in Virgo Tomcat Server.

How you can use it as target platform is described on the wiki: http://wiki.eclipse.org/Gemini/Web

Regards
Violeta
Re: Starting Tomcat 7 as Embedded Server in OSGI Framework [message #885675 is a reply to message #885261] Wed, 13 June 2012 12:26 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 211
Registered: February 2012
Location: Düsseldorf
Senior Member
Thank you Violeta,
I had the gemini blueprint and web bundles already downloaded but I did not dare to open yet another box of bundles. Now you encouraged me to do so. I have installed a target platform for gemini web and added the really simple example from the wiki. It works as expected.
But I need to get a DispatcherServlet running. So I added some more bundles to my configuration.

Namely:
com.springsource.net.sf.cglib-2.1.3.jar
com.springsource.org.aspectj.weaver-1.6.6.RELEASE.jar
org.eclipse.virgo.medic-3.0.3.RELEASE.jar
org.eclipse.virgo.web.dm-3.0.3.RELEASE.jar
org.springframework.asm-3.0.5.RELEASE.jar
org.springframework.context.support-3.0.5.RELEASE.jar
org.springframework.expression-3.0.5.RELEASE.jar
org.springframework.web-3.0.5.RELEASE.jar
org.springframework.web.servlet-3.0.5.RELEASE.jar
spring-osgi-extender-1.2.1.jar


After a couple of hours struggling with this and that I finaly have a spring webservice up and running.

I use the following configuration in the web.xml:
<context-param>
	<param-name>contextClass</param-name>
	<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
</context-param>

<listener>
	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
	
<servlet>
	<servlet-name>dispatcher</servlet-name>
	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
	<load-on-startup>2</load-on-startup>
</servlet>


The ContextLoaderListener needs the org.springframework.asm.ClassVisitor. So I had to add the org.springframework.asm-3.0.5.RELEASE.jar. I experienced some really strange behaviour. First the class could not be resolved allthough the asm-bundle was included in the launch configuration (I checked that it was in ACTIVE state). I was even able to load that class from a SimpleServlet. So for sure the ClassVisitor was accessible. But while the context was loaded the following exception kept to occure:

SCHWERWIEGEND: Servlet /osgi-web-app threw load() exception
java.lang.ClassNotFoundException: org.springframework.asm.ClassVisitor
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)


After doing this and that (I can't really say what), all of a sudden the exception vanished. Just to come back a couple of restarts later. I have no idea what happened. Last time the exception occured, I was able to get rid of it by starting the launch configuration without my service-bundle, then stop it and restart it with the service-bundle. Do you know if this is some kind of caching problem?

Anyway, currently it works! So thanks again this saved my day!

Regards,
Thorsten

[Updated on: Wed, 13 June 2012 12:27]

Report message to a moderator

Re: Starting Tomcat 7 as Embedded Server in OSGI Framework [message #885816 is a reply to message #885675] Wed, 13 June 2012 16:45 Go to previous message
Violeta Georgieva is currently offline Violeta GeorgievaFriend
Messages: 244
Registered: October 2010
Senior Member
You may try "Clear the configuration area before launching".

See the attached screenshot.
Previous Topic:Redeployment int pickup directory does not work
Next Topic:Virgo-maven-plugin with external local maven repository
Goto Forum:
  


Current Time: Mon Nov 24 15:15:39 GMT 2014

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

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