异常启动过滤器struts2:NoSuchMethodError

时间:2014-11-05 09:53:33

标签: java java-ee exception struts2

我正在尝试在jboss服务器上部署Struts2应用程序,但我得到了NoSuchMethodException。但是,我已经包含了xwork2-core-2.3.14 jar,它具有异常中提到的UrlSet方法。我无法辨认出错了什么。任何人都可以建议可能出错的地方。

14:17:30,099 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/ELM]] (MSC service thread 1-3) Exception starting filter struts2: java.lang.NoSuchMethodError: com.opensymphony.xwork2.util.finder.UrlSet.<init>(Ljava/lang/ClassLoader;)V
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildUrlSet(PackageBasedActionConfigBuilder.java:322) [struts2-convention-plugin-2.1.6.jar:]
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:295) [struts2-convention-plugin-2.1.6.jar:]
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:277) [struts2-convention-plugin-2.1.6.jar:]
    at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:52) [struts2-convention-plugin-2.1.6.jar:]
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:260) [xwork-core-2.3.14.jar:2.3.14]
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67) [xwork-core-2.3.14.jar:2.3.14]
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429) [struts2-core-2.3.14.3.jar:2.3.14.3]
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:473) [struts2-core-2.3.14.3.jar:2.3.14.3]
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) [struts2-core-2.3.14.3.jar:2.3.14.3]
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) [struts2-core-2.3.14.3.jar:2.3.14.3]
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_45]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_45]

14:17:30,204 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-3) Error filterStart
14:17:30,209 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-3) Context [/ELM] startup failed due to previous errors
14:17:30,217 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.web.deployment.default-host./ELM: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ELM: JBAS018040: Failed to start context
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_45]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_45]

14:17:30,497 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "ELM.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./ELM" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ELM: JBAS018040: Failed to start context"}}
14:17:30,973 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment ELM.war in 476ms
14:17:30,979 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.web.deployment.default-host./ELM: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ELM: JBAS018040: Failed to start context

14:17:30,993 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./ELM" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ELM: JBAS018040: Failed to start context"}}}}

包含jar文件

antlr-2.7.6.jar 
asm-3.3.jar
classes12.jar
commons-beanutils-1.6.jar
commons-chain-1.2.jar
commons-collections-3.2.1.jar
commons-digester-1.7.jar
commons-fileupload-1.2.2.jar
commons-io-2.3.jar
commons-lang3-3.1.jar
commons-logging-1.1.jar
commons-logging-api-1.1.jar
commons-validator-1.3.1.jar
dom4j-1.6.1.jar
ejb3-persistence.jar
ezmorph-1.0.6.jar
freemarker-2.3.13.jar
gson-2.2.4.jar
jakarta-oro.jar
javassist-3.9.0.GA.jar
jboss-as-web-7.1.1.Final.jar
jboss-logging-3.1.0.GA.jar
jboss-msc-1.0.2.GA.jar
jboss-transaction-api_1.1_spec-1.0.0.Final.jar
jbossweb-7.0.13.Final.jar
json-lib.jar
jta-1.1.jar
junit-3.8.1.jar
log4j-1.2.16.jar
ognl-3.0.6.jar
slf4j-api-1.5.8.jar
slf4j-log4j12-1.5.8.jar
struts.jar
struts2-convention-plugin-2.1.6.jar
struts2-core-2.3.14.3.jar
struts2-json-plugin-2.1.8.1.jar
struts2-tiles-plugin-2.1.6.jar
xwork2.jar
xwork-core-2.3.14.jar

struts.xml中

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
   "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <package name="ELM" extends="struts-default,json-default">

        <action name="add" class="com.example.elm.action.Sample"
            method="process">
            <result type="json"></result>
        </action>

    </package>
</struts>

的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>ELM</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

  <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>

1 个答案:

答案 0 :(得分:2)

struts.jar
struts2-convention-plugin-2.1.6.jar
struts2-core-2.3.14.3.jar
struts2-json-plugin-2.1.8.1.jar
struts2-tiles-plugin-2.1.6.jar
xwork2.jar
xwork-core-2.3.14.jar

这超越了邪恶。由于安全问题,所有资源必须对齐(相同版本),并可能更新到最新版本。同时删除struts.jarxwork2.jar(!!)。

然后你需要

  

<击> struts.jar
  struts2-convention-plugin-2.3.16.3.jar
  struts2-core-2.3.16.3.jar
  struts2-json-plugin-2.3.16.3.jar
  struts2-tiles-plugin-2.3.16.3.jar
  <击> xwork2.jar
  xwork-core-2.3.16.3.jar

还要更新ognl.jar和freemarker.jar,因为它们已经过时了: