我很难让一个Spring项目在Adobe CQ5上运行,这是我的StackTrace
错误 [Timer-3] org.apache.catalina.core.ContainerBase。[Catalina]。[localhost]。[/ springws]配置org.springframework.web类的应用程序监听器时出错。 context.ContextLoaderListener java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener 在java.net.URLClassLoader $ 1.run(未知来源) 在java.net.URLClassLoader $ 1.run(未知来源) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.net.FactoryURLClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) 在org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3712) 在org.apache.catalina.core.StandardContext.start(StandardContext.java:4216) 在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760) 在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740) 在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544) 在org.springframework.osgi.web.deployer.tomcat.TomcatWarDeployer.startCatalinaContext(TomcatWarDeployer.java:144) 在org.springframework.osgi.web.deployer.tomcat.TomcatWarDeployer.startDeployment(TomcatWarDeployer.java:133) 在org.springframework.osgi.web.deployer.support.AbstractWarDeployer.deploy(AbstractWarDeployer.java:93) 在org.springframework.osgi.web.extender.internal.activator.WarLoaderListener $ DeploymentManager $ DeployTask.doRun(WarLoaderListener.java:257) 在org.springframework.osgi.web.extender.internal.activator.WarLoaderListener $ DeploymentManager $ BaseTask.run(WarLoaderListener.java:215) 在org.springframework.scheduling.timer.DelegatingTimerTask.run(DelegatingTimerTask.java:70) at java.util.TimerThread.mainLoop(Unknown Source) 在java.util.TimerThread.run(未知来源)
web.xml文件是
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/osgi-context.xml</param-value>
</context-param>
<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
POM文件
<properties>
<springdm.version>1.2.0</springdm.version>
<spring.version>2.5.6</spring.version>
<equinox.version>3.5.1.R35x_v20090827</equinox.version>
<felix.bundle.plugin.version>2.0.1</felix.bundle.plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<!-- need to fork otherwise some tests contexts are shared -->
<forkMode>always</forkMode>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${felix.bundle.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<!-- manifestLocation>META-INF</manifestLocation -->
<instructions>
<!-- <Private-Package>com.manning.sdmia.web</Private-Package> -->
<Import-Package>
org.springframework.stereotype;version="2.5.6",
org.springframework.ui;version="2.5.6",
org.springframework.web.bind.annotation;version="2.5.6",
org.springframework.web.servlet.view;version="2.5.6",
org.springframework.beans.factory.annotation;version="2.5.6",
org.springframework.osgi.web.context.support"
</Import-Package>
<Include-Resource>src/main/resources,src/main/webapp</Include-Resource>
<Web-ContextPath>springws</Web-ContextPath>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.osgi</groupId>
<artifactId>spring-osgi-annotation</artifactId>
<version>${springdm.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.web.servlet</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-support</artifactId>
<version>2.0.8</version>
在Adobe CQ5中上传了以下软件包
322 Spring AOPorg.springframework.aop 3.0.6.RELEASE Active
332 Spring ASMorg.springframework.asm 3.0.6.RELEASE Active
316 Spring Beansorg.springframework.beans 3.0.6.RELEASE Active
317 Spring Contextorg.springframework.context 3.0.6.RELEASE Active
312 Spring Coreorg.springframework.core 3.0.6.RELEASE Active
333 Spring Expression Languageorg.springframework.expression 3.0.6.RELEASE Active
339 Spring Web Servletorg.springframework.web.servlet 2.5.6.SEC01 Active
321 spring-osgi-annotationorg.springframework.osgi.extensions.annotations 1.2.1 Active
315 spring-osgi-coreorg.springframework.osgi.core 1.2.1 Active
311 spring-osgi-extenderorg.springframework.osgi.extender 1.2.1 Active
318 spring-osgi-ioorg.springframework.osgi.io 1.2.1 Active
336 spring-osgi-weborg.springframework.osgi.web 1.2.1 Active
337 spring-osgi-web-extenderorg.springframework.osgi.web.extender 1.2.1 Active
249 svnkit bundlecom.day.commons.osgi.wrapper.svnkit 1.3.0.0002 Active
我需要上传任何其他捆绑包吗? 如果您还需要完整的项目代码,请告诉我。尝试了不同的选择,但面临同样的问题
提前致谢
答案 0 :(得分:0)
我不确定您使用的是哪个版本的CQ / AEM,以及您在哪里放置web.xml。所以我假设你使用的是CQ 5.4。
您已将OS捆绑包上载到OSGi容器中,而web.xml是针对WebContainer的,默认情况下不会桥接,这意味着Web容器将无法识别OSGi容器上的任何捆绑包。
您可能必须考虑使用Spring DM / Eclipse Gemini(蓝图)来实现您的目的。请参考Spring DM Documentation或Eclipse Gemini Blueprints Documentation开始集成Spring和OSGi。
如果你在Spring DM和Eclipse Gemini之间,你也可以参考这个article。