Discussions

Web tier: servlets, JSP, Web frameworks: java.lang.NoClassDefFoundError

  1. java.lang.NoClassDefFoundError (1 messages)

    SUBJECT: java.lang.NoClassDefFoundError
    I am using Tomcat 4.1.31 on SuSE Linux 8.1 and Java 1.4

    I have my application as following:

    /local/tomcat/webapps/hari
    /local/tomcat/webapps/hari/index.html
    /local/tomcat/webapps/hari/WEB-INF/classes/util/BatchUpload1.class
    /local/tomcat/webapps/hari/WEB-INF/classes/util/*.class
    /local/tomcat/webapps/hari/WEB-INF/lib/cos.jar (this is Oreilly's predefined classes)
    /local/tomcat/webapps/hari/WEB-INF/web.xml

    I access my WEB application as http://us.hari.com/uhin/BatchUpload and get following error wonder why:
    --------------------------------------------------------------------------------
    description: The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: Error instantiating servlet class util.BatchUpload1
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:865)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:621)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:163)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)

             at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)

                at java.lang.Thread.run(Thread.java:534)

    root cause

    java.lang.NoClassDefFoundError: com/oreilly/servlet/multipart/FileRenamePolicy

                at java.lang.Class.getDeclaredConstructors0(Native Method)
                at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
                at java.lang.Class.getConstructor0(Class.java:1930)
                at java.lang.Class.newInstance0(Class.java:278)
                at java.lang.Class.newInstance(Class.java:261)
               at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:856)

    -----------------------------------------------------------------------------------

    I am using Oreilly's predefined classes which are stored in "cos.jar" file and under WEB-INF/lib/ directory... I have also added this to the CLASSPATH...


    When I un-jar my cos.jar file I get follwing files...
    com/oreilly/servlet/*.classes


    Any pointer on this would be appreciated...

    THANKS!

    HARI OM
  2. java.lang.NoClassDefFoundError[ Go to top ]

    I guess you are not implementing the servlet api's correclty, or not inheriting the servlet class correctly, cause the error is not NoClassDefFoundError actually, its actually ---- Error instantiating servlet class util.BatchUpload1 ----- which means it could not instantiate the class as a servlet as opposed to not finding it.

    Hope this helps.

    Rakesh.