Just don't do it that way! I think I've already given plenty of examples on how a web application is supposed to look a like. And this is definitely not the way I told you before. So for one last time, get rid of those spring jars inside your web application, deploy all spring bundles with the according feature that is available with karaf. Embedding jars in your bundle (yes, your war is just another bundle) should be your last possibility and only if it is a really internal thing. Spring definitely isn't an internal thing. Make sure your Manifest does have the required Imports, if you fail in generating all required Imports it is usually a good practice during development to start with an dynamic-import. After that take a look of the actual required imports, a bundle:header will help you with that, and get back to your manifest where you just import the needed packages that you just learned about. And again, take a good look at the Spring-OSGi sample provided by Pax Web. YOU WILL NEED Spring-DM to have Spring working. Maybe it'll work if you switch from Aries-Blueprint to Gemini-Blueprint, too. That I never tried before.
Achim 2014-04-30 1:34 GMT+02:00 asookazian2 <[email protected]>: > 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. > -- Apache Karaf <http://karaf.apache.org/> Committer & PMC OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead blog <http://notizblog.nierbeck.de/> Software Architect / Project Manager / Scrum Master
