gpt4 book ai didi

java - NoSuchMethodError org.apache.commons.collections.ExtendedProperties.getList(Ljava/lang/String;)Ljava/util/List in Struts 2

转载 作者:行者123 更新时间:2023-11-30 11:17:00 26 4
gpt4 key购买 nike

我想将 Tiles 3 与 Strut 2 一起使用,所以我正在使用 struts2-tiles3-plugin。我在 web.xml 中定义了监听器,在 struts.xml 中定义了结果类型。当我部署 war 时,Tomcat 返回一个 java.lang.NoSuchMethodError

这是我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID"
version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

<display-name>MyProject</display-name>

<!-- tiles listener -->
<listener>
<listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>
</listener>

<!-- my listener -->
<listener>
<listener-class>com.myproject.MyListener</listener-class>
</listener>

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>

这是我的struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>


<constant name="struts.devMode" value="true"/>

<package name="default" extends="struts-default" namespace="/">

<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>

<action name="">
<result type="redirectAction">home</result>
</action>

<action name="home" class="com.myproject.action.Homepage" method="execute">
<result name="success" type="tiles">jsp/home.jsp</result>
<result name="login">jsp/Login.jsp</result>
</action>

...

</package>

</struts>

这是我的tiles.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">

<tiles-definitions>

<definition name="baseLayout" template="/jsp/layouts/base.jsp">
<put-attribute name="title" value="MyProject" />
<put-attribute name="header" value="/jsp/layouts/header.jsp" />
<put-attribute name="content" value="/jsp/layouts/content.jsp" />
<put-attribute name="footer" value="/jsp/layouts/footer.jsp" />
</definition>

<definition name="home" extends="baseLayout">
<put-attribute name="title" value="MyProject Home" />
<put-attribute name="body" value="/tiles/home-body.jsp" />
</definition>

</tiles-definitions>

这是我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<!-- General Info -->
<modelVersion>4.0.0</modelVersion>
<groupId>myproject</groupId>
<artifactId>MyProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>MyProject</name>

<!-- Properties -->
<properties>
<struts2.version>2.3.16.3</struts2.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2.version}</version>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-config-browser-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-junit-plugin</artifactId>
<version>${struts2.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>3.0.4</version>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles3-plugin</artifactId>
<version>${struts2.version}</version>
<scope>compile</scope>
</dependency>

</project>

Tomcat (v. 7.0.39) 返回此错误:

lug 06, 2014 8:16:48 PM org.apache.catalina.core.ApplicationContext log
INFORMAZIONI: No Spring WebApplicationInitializer types detected on classpath
lug 06, 2014 8:16:48 PM org.apache.catalina.core.StandardContext listenerStart
GRAVE: Exception sending context initialized event to listener instance of class org.apache.tiles.extras.complete.CompleteAutoloadTilesListener
java.lang.NoSuchMethodError: org.apache.commons.collections.ExtendedProperties.getList(Ljava/lang/String;)Ljava/util/List;
at org.apache.velocity.tools.view.VelocityView.configure(VelocityView.java:368)
at org.apache.velocity.tools.view.VelocityView.init(VelocityView.java:342)
at org.apache.velocity.tools.view.VelocityView.init(VelocityView.java:310)
at org.apache.velocity.tools.view.VelocityView.<init>(VelocityView.java:213)
at org.apache.tiles.velocity.renderer.VelocityAttributeRenderer.commit(VelocityAttributeRenderer.java:82)
at org.apache.tiles.extras.complete.CompleteAutoloadTilesContainerFactory.registerAttributeRenderers(CompleteAutoloadTilesContainerFactory.java:168)
at org.apache.tiles.factory.BasicTilesContainerFactory.createRendererFactory(BasicTilesContainerFactory.java:411)
at org.apache.tiles.factory.BasicTilesContainerFactory.createContainer(BasicTilesContainerFactory.java:111)
at org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:124)
at org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:70)
at org.apache.tiles.web.startup.AbstractTilesListener.contextInitialized(AbstractTilesListener.java:62)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:542)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1462)
at sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(Unknown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(Unknown Source)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1445)
at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:677)
at org.apache.catalina.manager.ManagerServlet.doPut(ManagerServlet.java:435)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

最佳答案

您在 velocity 和 commons-collections 之间存在版本冲突。请注意,在您使用的 struts 版本中,它需要依赖于 commons-collections 3.2.1 的 velocity 1.6.4。另一方面,tiles 插件仍然需要 commons-collections 3.2。

您可以运行 mvn dependency:tree 来查看已解析的依赖项或在 IDE 中查看有效的 POM。

关于java - NoSuchMethodError org.apache.commons.collections.ExtendedProperties.getList(Ljava/lang/String;)Ljava/util/List in Struts 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24599127/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com