3 Replies Latest reply on Feb 12, 2003 3:56 PM by Peter Doornbosch

    struts problem, NoClassDefFoundError

    Bernd Bauer Newbie


      I deploy a web application (JBoss3.0.0) in a war (struts.jar in WEB-INF\lib\) called wfadmin.war with the following login.jsp:

      <%@ page language="java" contentType="text/html" errorPage="/error.jsp"%>
      <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
      <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
      <%@ taglib uri="/WEB-INF/premioss.tld" prefix="premioss" %>
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
      <html:html locale="true">

      <bean:message key="app.title"/> - <bean:message key="login.caption"/>


      <h2><bean:message key="app.title"/></h2>

      <bean:message key="login.caption"/>

      <bean:message key="login.user"/>
      <bean:message key="login.password"/>
      <%-- <input type="submit" value="<bean:message key="login.button"/>" /> --%>



      My web.xml has a section like this:


      So when i log in with a wrong user name, jetty tries to display the login-error.jsp which is exactly the same as login.jsp,
      except for an additional line <bean:message key="error.login"/>.
      But instead of the login-error.jsp, everything i get so see is:

      HTTP ERROR: 500 org/apache/struts/action/ActionServlet

      in the browser window and

      16:11:59,546 WARN [Jetty] WARNING: Servlet Exception for /wfadmin/login-error.j
      java.lang.NoClassDefFoundError: org/apache/struts/action/ActionServlet
      at de.ipvalue.premioss.standard.ui.taglib.TestMetaTag.doStartTag(TestMet
      at org.apache.jsp.login_0002derror$jsp._jspService(login_0002derror$jsp.
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspSer
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:371
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:6
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1387)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1326)
      at org.mortbay.http.HttpServer.service(HttpServer.java:757)
      at org.jboss.jetty.Jetty.service(Jetty.java:527)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:742)
      at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:915)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:757)
      at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:287)
      at org.mortbay.util.ThreadPool$JobRunner.run(ThreadPool.java:715)
      at java.lang.Thread.run(Thread.java:484)

      as server log.
      Has anyone an idea, why the classloader can't find the struts classes?
      Thanks in advance,

        • 1. Re: struts problem, NoClassDefFoundError
          Julian Gosnell Expert

          look back through this forum. Struts an CNFE comes up all the time.

          If someone wants to write the definitive solution to the problem, I will include it in the JBoss/Jetty FAQ.


          • 2. Re: struts problem, NoClassDefFoundError
            Bernd Bauer Newbie

            I did look through this forum before posting the message, but nothing seemed to make sense to me. In the end i tried JBoss 3.0.2 and guess what? The error is gone.

            So i think that this should be part of the FAQ:

            Mistrust software with a zero as the last digit in version number. :-)

            Nevertheless JBoss is great!

            • 3. Re: struts problem, NoClassDefFoundError
              Peter Doornbosch Apprentice

              Hi Jules,

              Just ran into the same ClassNotFound exceptions with struts 1.0.2 (sigh ;-)...
              I found some posts that explain that usage of the infamous Class.forName() sooner or later causes troubles, because:
              - it loads from the system classpath only
              - it does not reload classes.
              This is exactly the behaviour i see after doing some experiments. When i put struts.jar on the classpath (lib dir that is), the CNFE disappears, but hot-deploy does not work anymore. So i replaced (some) Class.forName() calls in the struts source by context-classloader calls and everything works fine (with struts.jar in the web-inf/lib directory inside the war).
              Of course, i'm not sure whether this really resolves the issues (i've seen to many posts of people thinking they had finally found it by fiddling with classpaths and classfiles ;-), but at least it seems to make sense...