I am trying the following code (replaces web.xml) in embedded Jetty 9.0.6 and
onStartup method is being invoked and the Spring context xml is being
loaded/parsed.  

When I deploy in karaf 3.0.0 onStartup is not invoked.  Any idea why?  There
are no exceptions in the karaf log.

public class MyWebAppInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext container) {
        System.out.println("*************************** in onStartup()
*****************************");
      XmlWebApplicationContext appContext = new XmlWebApplicationContext();
     
appContext.setConfigLocation("/WEB-INF/classes/workflow-ws-context.xml");

      ServletRegistration.Dynamic dispatcher =
container.addServlet("dispatcher", new DispatcherServlet(appContext));
      dispatcher.setLoadOnStartup(1);
      dispatcher.addMapping("/");
    }

 }

"Implementations of this SPI will be detected automatically by
SpringServletContainerInitializer, which itself is bootstrapped
automatically by any Servlet 3.0 container.  This class will be loaded and
instantiated and have its onStartup method invoked by any Servlet
3.0-compliant container during container startup assuming that the
spring-web module JAR is present on the classpath."

http://docs.spring.io/spring/docs/3.1.x/javadoc-api/org/springframework/web/WebApplicationInitializer.html
<http://docs.spring.io/spring/docs/3.1.x/javadoc-api/org/springframework/web/WebApplicationInitializer.html>
  

I have the following in my bundle-classpath:

Bundle-ClassPath: .,WEB-INF/classes,WEB-INF/lib/activation-1.1.jar,WEB
 -INF/lib/activiti-engine-5.10.jar,WEB-INF/lib/activiti-spring-5.10.ja
 r,WEB-INF/lib/AMUserService-8.2.jar,WEB-INF/lib/aopalliance-1.0.jar,W
 EB-INF/lib/commons-codec-1.3.jar,WEB-INF/lib/commons-dbcp-1.4.jar,WEB
 -INF/lib/commons-email-1.2.jar,WEB-INF/lib/commons-io-2.0.1.jar,WEB-I
 NF/lib/commons-lang-2.6.jar,WEB-INF/lib/commons-logging-1.0.4.jar,WEB
 -INF/lib/commons-pool-1.5.4.jar,WEB-INF/lib/groovy-all-1.8.9.jar,WEB-
 INF/lib/httpclient-4.1.3.jar,WEB-INF/lib/httpcore-4.1.4.jar,WEB-INF/l
 ib/index-ws-client-1.0.0-SNAPSHOT.jar,WEB-INF/lib/livetribe-jsr223-2.
 0.6.jar,WEB-INF/lib/mail-1.4.jar,WEB-INF/lib/mybatis-3.1.1.jar,WEB-IN
 F/lib/mybatis-spring-1.2.2.jar,WEB-INF/lib/spring-aop-3.1.3.RELEASE.j
 ar,WEB-INF/lib/spring-asm-3.1.1.RELEASE.jar,WEB-INF/lib/spring-beans-
 3.1.1.RELEASE.jar,WEB-INF/lib/spring-context-3.1.1.RELEASE.jar,WEB-IN
 F/lib/spring-core-3.1.3.RELEASE.jar,WEB-INF/lib/spring-expression-3.1
 .1.RELEASE.jar,WEB-INF/lib/spring-jdbc-3.1.1.RELEASE.jar,WEB-INF/lib/
 spring-orm-3.1.1.RELEASE.jar,WEB-INF/lib/spring-test-3.1.1.RELEASE.ja
 r,WEB-INF/lib/spring-tx-3.1.1.RELEASE.jar,WEB-INF/lib/workflow-engine
 -1.0.0-SNAPSHOT.jar,WEB-INF/lib/spring-web-3.2.4.RELEASE.jar,WEB-INF/
 lib/spring-webmvc-3.2.4.RELEASE.jar

And the following in export-package:

Export-Package: WEB-INF.lib;version="1.0.0.SNAPSHOT",WEB-INF;version="
 1.0.0.SNAPSHOT",WEB-INF.lib.classes;version="1.0.0.SNAPSHOT"



--
View this message in context: 
http://karaf.922171.n3.nabble.com/Using-Spring-WebApplicationInitializer-in-karaf-tp4033004.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to