Announcement Announcement Module

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
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring in Equinox/Tomcat


    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:
    Hashtable<String, String> params = new Hashtable<String, String>();
    params.put("contextConfigLocation", "/WEB-INF/Osgi-servlet.xml");
    httpService.registerServlet("/*.htm", new DispatcherServlet(), params, null);
    And whenever I try to start my bundle I get:

    java.lang.ClassNotFoundException: undleXmlWebApplicationContext

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


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


    • #3

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


          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
            Did that !

            Thanks for your response!

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



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


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

                My war file has in it's manifest file:
                Import-Package: org.springframework.stereotype,org.springframework.web
                And in my war's web.xml the servlet element is:

                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,


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


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


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