2 Replies Latest reply on Jul 13, 2002 1:49 AM by marc fleury

    java.lang.NoClassDefFoundError: org/apache/struts/action/Act

    Tom Baeyens Master

      Hi !

      I'm using jboss-3.0.0_tomcat-4.0.3 & the struts framework.
      When I request a the index.jsp directly, all works well (including the struts tags).
      I get the error the when I invoke a request for the ActionServlet.
      The strange thing about this NoClassDefFoundError is that in the stacktrace, there are classes of the struts-framework.

      Layout of wy war file
      root
      + index.jsp
      + template.jsp
      + WEB-INF
      + + classes --> my classes
      + + lib
      + + + commons-*.jar
      + + + log4j-1.2.4.jar
      + + + struts.jar
      + + struts*.tld
      + + web.xml
      + + jboss-web.xml

      Exception message:
      12:09:13,505 INFO Processing a 'GET' for path '/locale'
      12:09:13,875 ERROR No action instance for path /locale could be created
      java.lang.NoClassDefFoundError: org/apache/struts/action/Action
          at java.lang.ClassLoader.defineClass0(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:493)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
          at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
          at org.jboss.mx.loading.UnifiedClassLoader.findClass(UnifiedClassLoader.java:227)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
          at org.jboss.mx.loading.UnifiedClassLoader.loadClassLocally(UnifiedClassLoader.java:235)
          at org.jboss.mx.loading.UnifiedLoaderRepository.loadClassFromRepository(UnifiedLoaderRepository.java:387)
          at org.jboss.mx.loading.UnifiedLoaderRepository.loadClass(UnifiedLoaderRepository.java:146)
          at org.jboss.mx.loading.UnifiedClassLoader.loadClass(UnifiedClassLoader.java:285)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:292)
          at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:553)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
          at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1343)
          at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1243)
          at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
          at java.lang.ClassLoader.defineClass0(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:493)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
          at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1631)
          at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:926)
          at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
          at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1243)
          at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:190)
          at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:216)
          at org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcessor.java:314)
          at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:258)
          at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1109)
          at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:452)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)

      Servlet configuration in web.xml

        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
          <param-name>application</param-name>
          <param-value>MyResources</param-value>
        </init-param>
        <init-param>
          <param-name>debug</param-name>
          <param-value>2</param-value>
        </init-param>
        <init-param>
          <param-name>detail</param-name>
          <param-value>2</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>


      Struts configuration file
      <struts-config>
        <form-beans>
        </form-beans>
        <action-mappings>
          
        </action-mappings>
      </struts-config>

        • 1. Re: java.lang.NoClassDefFoundError: org/apache/struts/action
          Tom Baeyens Master

          OK, I found the solution.

          It was a problem caused by bad arrangement of my classes in my .war and .jar modules.

          My classes in my .war file were put in the root instead of the WEB-INF/classes dir.

          Another thing I changed was the elimination of double classes. Meaning classes that were present in both .war and .jar. But I don't think that was the cause. What does JBoss do in that case anyhow ?

          ... now for the next bug :-)

          • 2. Re: java.lang.NoClassDefFoundError: org/apache/struts/action
            marc fleury Master

            Depends on the version you are using.

            in the 2.x series there is no class visibility across packages so you need to duplicate classes everywhere. In doing so you would get ClassCastException as the 2 classes would be loaded by different classloaders. You would certainly NOT see "NoClassDefFoundError".

            in 3.x we share classes across deployment units so we strongly recommend putting a class in one package only as you can run in maintenance problems if you keep duplicate classes running around, as the first class loaded is the one used for all deployment units. You would still not get "NoClassDefFoundError".

            That error just seems to indicate that he couldn't find the class meaning you are using 2.x and it wasn't in WEB-INF/classes.


            The reason is that