Announcement Announcement Module
No announcement yet.
DispatcherServlet cannot find classes when its used in a Bundle Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • DispatcherServlet cannot find classes when its used in a Bundle

    Hi everyone,

    I have a tricky problem. For some reasons I need to run an OSGi Container inside a web container (eg. Tomcat) for which I use the equinox servlet bridge. As I want to expose a service Interface over http, I use the HttpServiceExporter that exposes a service on the class "ModelFacade". I managed to register the DispatcherServlet (that I need for the remoting) from inside OSGi and let it read the spring configuration xml file. I did that like this:

    ServiceReference httpReference = context.getServiceReference(HttpService.class.getName());
    HttpService service = (HttpService) context.getService(httpReference);
    DispatcherServlet servlet = new DispatcherServlet();
    service.registerServlet("/remote", servlet, null, null);
    The dispatcherservlet.xml file is this:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns=""
    	xmlns:xsi="" xmlns:util=""
    	xmlns:tx="" xmlns:aop=""
    	<bean name="modelFacade" class="" scope="session">
    	<bean name="/ModelFacade" id="modelFacadeHTTPExporter"
    		scope="session" >
    		<property name="service" ref="modelFacade" />
    		<property name="serviceInterface" value="" />
    I can see on the OSGi console that the servlet is able to find the configuration and loads it, now claiming that it cannot find the classes (ModelFacade) in my bundle (in which the configuration file lies, too).
    It seems that the classloader the dispatcher servlet uses cannot see the classes in the bundle.

    Here's the Tomcat-log showing the exception:
    13.05.2009 16:56:30 org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not fou nd on the java.library.path: C:\Programme\Java\jdk1.6.0_11\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;
    13.05.2009 16:56:30 org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    13.05.2009 16:56:30 org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 451 ms
    13.05.2009 16:56:30 org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    13.05.2009 16:56:30 org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
    13.05.2009 16:56:30 org.apache.catalina.startup.HostConfig deployWAR
    INFO: Deploying web application archive bridge.war Listening on port 9999 ...
    13.05.2009 16:56:33 org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8080
    13.05.2009 16:56:33 org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /
    13.05.2009 16:56:33 org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/31  config=null
    13.05.2009 16:56:33 org.apache.catalina.startup.Catalina start
    INFO: Server startup in 3074 ms
    0    [OSGi Console] INFO  org.springframework.osgi.extender.internal.activator.ContextLoaderListener  - Starting [org.sp
    ringframework.osgi.extender] bundle v.[1.2.0]
            94   [OSGi Console] INFO  - No custom
    extender configuration detected; using defaults...
            94   [OSGi Console] INFO  org.springframework.scheduling.timer.TimerTaskExecutor  - Initializing Timer
            4358 [OSGi Console] INFO  org.springframework.web.servlet.DispatcherServlet  - FrameworkServlet 'org.springframe
    work.web.servlet.DispatcherServlet': initialization started
            4358 [OSGi Console] INFO  - Refreshing org.spr
    [email protected]: display name [WebApplicationContext for namespace 'org .springframework.web.servlet.DispatcherServlet-servlet']; startup date [Wed May 13 16:56:42 CEST 2009]; root of context hierarchy
            4405 [OSGi Console] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean defi nitions from ServletContext resource [/META-INF/dispatcherservlet.xml]
            5467 [OSGi Console] INFO  - Bean factory for a pplication context [o[email protected]97d026]: org.springframework.beans.
    [email protected]
            5482 [OSGi Console] INFO  - Pre-instantiat ing singletons in org.s[email protected]1ab2b55: defining beans [modelFac ade,modelFacadeHTTPExporter]; root of factory hierarchy
            5498 [OSGi Console] INFO  - Destroying sin gletons in org.s[email protected]1ab2b55: defining beans [modelFacade,mod elFacadeHTTPExporter]; root of factory hierarchy
            5498 [OSGi Console] ERROR org.springframework.web.servlet.DispatcherServlet  - Context initialization failed
            org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.
    servlet.handler.BeanNameUrlHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans
    .factory.CannotLoadBeanClassException: Cannot find class [] for bean with name 'modelFacade' def ined in ServletContext resource [/META-INF/dispatcherservlet.xml]; nested exception is java.lang.ClassNotFoundException:
            at Method)
            at org.springframework.web.servlet.DispatcherServlet.createDefaultStrategy(

    Any ideas?