Announcement Announcement Module
Collapse

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
Spring in Equinox/Tomcat Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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)

      Comment


      • #4
        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.

        Comment


        • #5
          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)

          Comment


          • #6
            Did that !

            Thanks for your response!

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

            Thanks.

            Comment


            • #7
              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.

              Comment


              • #8
                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

                Comment


                • #9
                  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.

                  Comment


                  • #10
                    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.

                    Comment


                    • #11
                      Try doing small steps - first run the sample (untouched), get familiar with its content and setup then add your war.
                      From what you are saying your war doesn't import the necessary packages (in this case the org.springframework.osgi.web.support). The packages you refer to, in your import files do not contain the OBXWAC class which means the bundle cannot see this class which triggers the CNFE.

                      Comment

                      Working...
                      X