Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Spring in Equinox/Tomcat

  1. #1
    Join Date
    Mar 2010
    Posts
    5

    Default Spring in Equinox/Tomcat

    Hello,

    I am trying to deploy a Spring Mvc web-app inside an Equinox deployed on Tomcat (using the Eclipse bridge.war).

    In my bundle activator I do:
    Code:
    Hashtable<String, String> params = new Hashtable<String, String>();
    params.put("contextConfigLocation", "/WEB-INF/Osgi-servlet.xml");
    params.put("contextClass","org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext");
    httpService.registerServlet("/*.htm", new DispatcherServlet(), params, null);
    And whenever I try to start my bundle I get:

    java.lang.ClassNotFoundException: org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicationContext

    My Spring Osgi bundles are resolved fine, the class is there. I've tried specifying org.springframework.osgi.web.context.support as an Import-Package in my bundle but this didn't help. Any ideas ?

    Thanks.

  2. #2
    Join Date
    Mar 2010
    Posts
    16

    Default Same problem here

    I have the same scenario in mind but no clear understanding on how to do it.
    I am confused.
    Documentation assumes spring-dm powered WARs can be deployed on non-OSGI web containers.
    However, it seems that design requires OSGI web container (dm server).
    Perhaps this is why I cannot find any related examples

    See also
    http://forum.springsource.org/showthread.php?p=291542

  3. #3
    Join Date
    Mar 2010
    Posts
    16

    Default Finally

    I finally understood how this works.

    Here is a related piece from documentation that explains it all

    9.6.1. Deploying Web Containers As OSGi Bundles
    Spring DM web support expects the web containers to be installed as OSGi services.

    Web container is expected to run inside the OSGI not the other way around. This is why Spring-DM provides bundles for Tomcat and Jetty out of the box. Documentation suggests that bundles for other servlet/J2EE containers can be "easily" created. However, something tells me that this is not going be that easy.

    Here is another related piece from documentation

    9.1. Supported Web Containers
    Currently, Spring DM supports Apache Tomcat 5.5.x/6.0.x and Jetty 6.1.8+/6.2.x out of the box (other containers can be easily plugged in)

  4. #4
    Join Date
    Mar 2010
    Posts
    5

    Default Same issue

    I tried the other way around too. I've deployed a Spring MVC app on top of Equinox with embedded Tomcat installed. I did this starting from the simple-web-app example that comes with Spring DM.

    I get the same thing. Same ClassNotFoundException. I'm sure it's a OSGi dependency resolution issue but still haven't figured it out.

    Any ideas anyone ? I'm running out of things to try.

  5. #5
    Join Date
    Mar 2010
    Posts
    16

    Default

    use

    Import-Package: org.springframework.osgi.web.context.support

    in your bundle's manifest
    (plus any other package dependency discovered on the way)

    Also, you have to properly install a web container deployer however before being able to successfully start the web bundle
    (considering DM-Server best candidate for learning, but not only. why not production as well)

  6. #6
    Join Date
    Mar 2010
    Posts
    5

    Default Did that !

    Thanks for your response!

    As I said in my original post I tried that (bundle Import-Package) with no effect.

    Thanks.

  7. #7
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    To clarify a bit the confusion:
    1. Spring DM supports web applications when the the container is deployed as an OSGi bundle. See the samples for this (they are self sufficient).
    2. One can use dmServer whoever it superseeds the functionality in Spring DM (which is fairly basic). That is, ignore what you read in Spring DM and apply what the dmServer documentation tells you to.
    3. Spring DM web support is unlikely to work with the servlet bridge as that exposes only the http service. Take a look at the documentation on what are the benefits of using Spring DM web support (or dmServer for that matter) - in short, full Servlet 2.5 functionality including filters as opposed to servlet bridge which supports only servlet 2.0/2.1.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  8. #8
    Join Date
    Mar 2010
    Posts
    5

    Default

    Hello and thanks for your response.

    I've tried that also. I've tried to run a simple Spring MVC app on top of Tomcat (that itself is deployed as a bundle in Equinox). What I have now is an Equinox config.ini that looks like this

    Code:
    eclipse.ignoreApp=true
    osgi.noShutdown=true
    osgi.console=
    osgi.clean=true
    
    osgi.bundles=com.springsource.slf4j.api.jar@start,\
    com.springsource.slf4j.org.apache.commons.logging.jar@start,\
    com.springsource.slf4j.log4j.jar,\
    log4j.configuration-1.2.1.jar,\
    log4j.osgi.jar@start,\
    com.springsource.org.aopalliance.jar@start,\
    com.springsource.net.sf.cglib.jar@start,\
    org.springframework.aop.jar@start,\
    org.springframework.beans.jar@start,\
    org.springframework.core.jar@start,\
    org.springframework.context.jar@start,\
    org.springframework.web.jar@start,\
    org.springframework.web.servlet.jar@start,\
    com.springsource.javax.servlet.jar@start,\
    jsp-api.osgi.jar@start,\
    commons-el.osgi.jar@start,\
    jstl.osgi.jar@start,\
    jasper.osgi.jar@start,\
    com.springsource.mx4j.jar@start,\
    catalina.osgi.jar@start,\
    catalina.start.osgi.jar@start,\
    spring-osgi-io.jar@start,\
    spring-osgi-core.jar@start,\
    spring-osgi-extender.jar@start,\
    spring-osgi-web.jar@start,\
    spring-osgi-web-extender.jar@start,\
    webapps/helloosgi.war@start
    My war file has in it's manifest file:
    Code:
    Import-Package: org.springframework.stereotype,org.springframework.web
     .bind.annotation,org.springframework.web.servlet,org.springframework.osgi.web
    And in my war's web.xml the servlet element is:

    Code:
    	<servlet>
    		<servlet-name>HelloOsgi</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    		<init-param>
    			<param-name>contextClass</param-name>
    			<param-value>org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext</param-value>		
    		</init-param>
    	</servlet>
    In this scenario I get the same thing when I try to start the bundle. Class not found exception (OsgiBundleXmlWebApplicationContext). So it's definitely a dependency issue. I haven't tried with Spring DM 2, but I have a hunch I will get the same thing. I think the problem is in my configuration.

    Thank you,
    Mihai

  9. #9
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Mihai, there are so many setup variants mentioned in this thread that I don't know which one you are using. When using Spring DM, one doesn't need an Activator or the HttpService.
    Just take a look at the samples, look at the readme, follow the instructions and you should be all set. There are two web samples in the Spring DM 1.2.x distro - one with annotations and one w/o.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  10. #10
    Join Date
    Mar 2010
    Posts
    5

    Default

    Sorry about the confusion. To set things straight: the setup I am using now is a small modification of the simple-web-app sample that comes with spring DM 1.2.x.

    My last post is the only one that counts.

    The change to the simple-web-app setup is that I try to start a war file of my own (the last line in config.ini - helloosgi.war - a simple Spring MVC app).

    However, regardless of my context, what I don't understand is why doesn't spring find the OsgiBundleXmlWebApplicationContext.class when it tries to instantiate it through reflection as a context class in the dispatcher servlet ?

    Anyway, I thought this (ClassNotFound) was a common Spring DM beginner error and I'll find a quick answer here. It seems it isn't. It's probably something I missed in my setup. I'll try to start all over again

    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •