I'm adding struts2-convention-plugin-2.3.24.1.jar into my struts2 project(simple homework), then had an error of "SEVERE: Exception starting filter [struts2] java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor". My webpage is working properly before moving into the JAR file. And when I move the JAR file, the error disappears.

I have successful imported some classes in the JAR file when i add it into project. My struts version is 2.3.24.1, here is some libs in WEB-INFO

servlet-api.jar
struts2-convention-plugin-2.3.24.1.jar
struts2-core-2.3.24.1.jar
xwork-core-2.3.24.1.jar

error code

SEVERE: Exception starting filter [struts2]
java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildClassFinder(PackageBasedActionConfigBuilder.java:416)
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:397)
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:354)
    at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:274)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967)
    ....................................................very much lines
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.ClassVisitor
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1363)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1186)
    ... 44 more

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>
  <!-- language -->
  <constant name="struts.custom.i18n.resources" value="resource" />

    <package name="mytest" namespace="/" extends="struts-default">
        <interceptors>
            <interceptor name="mytestinterceptor" class="interceptor.MyInterceptor"></interceptor>
            <interceptor-stack name="myintstack">
                <interceptor-ref name="defaultStack"/>  
                <interceptor-ref name="mytestinterceptor"></interceptor-ref>    
            </interceptor-stack>
        </interceptors>
        <action name="LoginAction"  class="action.LoginAction">
            <interceptor-ref name="myintstack"></interceptor-ref>
            <result name="success">success.jsp</result>
            <result name="input">login.jsp</result>
        </action>
    </package>
</struts>

The teacher asked us to implement the login web in two ways, one is the XML configuration method(struts.xml), and the other is the annotation method(@Action...). I had implemented XML method, and this error is encountered when I use the annotation method.

0 Answers