| Starting Tomcat 7 as Embedded Server in OSGI Framework [message #885224] |
Tue, 12 June 2012 12:26  |
Thorsten Schlathölter Messages: 179 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 #885675 is a reply to message #885261] |
Wed, 13 June 2012 08:26   |
Thorsten Schlathölter Messages: 179 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 08:27] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.01589 seconds