java.lang.ClassFormatError: Truncated class file

Discussion in 'Java' started by laredotornado, Aug 25, 2010.

  1. Hi, I'm using Java 1.6 with Tomcat 6.0.26. When we are visiting
    certain JSPs, we are getting the error below. All the literature I
    have found so far pertains to applets, so I wanted to float this out
    to the group to see what advice you have about troubleshooting this
    further. Thanks, - Dave

    java.lang.ClassFormatError: Truncated class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at
    java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
    124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:
    260)
    at java.net.URLClassLoader.access$000(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.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:
    134)
    at
    org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
    at
    org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:
    598)
    at
    org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:
    144)
    at
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
    329)
    at
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
    320)
    at
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:
    803)
    at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
    290)
    at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
    206)
    at
    org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:
    654) at
    org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:
    445)
    at
    org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:
    379)
    at
    org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:
    292)
    at
    com.lvcva.servlet.generic.GenericHttpServlet.callView(GenericHttpServlet.java:
    610) at
    com.lvcva.servlet.dine.DiningServlet.details(DiningServlet.java:272)
    at sun.reflect.GeneratedMethodAccessor457.invoke(Unknown
    Source) at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
    25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
    com.lvcva.servlet.generic.GenericHttpServlet.doGet(GenericHttpServlet.java:
    587)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:
    690)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:
    803)
    at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
    290)
    at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
    206)
    at
    com.lvcva.filter.RecordPageFilter.doFilter(RecordPageFilter.java:30)
    at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
    235)
    at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
    206)
    at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
    230)
    at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
    175)
    at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
    128)
    at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
    104)
    at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
    109)
    at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
    261)
    at
    org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
    at
    org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
    at
    org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
    at
    org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:
    697)
    at org.apache.jk.common.ChannelSocket
    $SocketConnection.runIt(ChannelSocket.java:889)
    at org.apache.tomcat.util.threads.ThreadPool
    $ControlRunnable.run(ThreadPool.java:686)
    at java.lang.Thread.run(Thread.java:619)
    laredotornado, Aug 25, 2010
    #1
    1. Advertising

  2. laredotornado

    Karl Lopes Guest

    The problem is occuring in the load class method in JasperLoader. I
    suspect your jsp is not getting compiled: (method is below).
    Two things can be done here:
    1. Put a breakpoint in JasperLoader in the above class and see what
    happens.
    2. Try to precompile your JSPs and see which one fails. That should give
    you a start. (Ref: http://scriptlandia.blogspot.com/2006/04/how-to-pre-
    compile-jsp-pages-for.html)
    Karl.


    /*
    public Class loadClass(final String name, boolean resolve)
    95 throws ClassNotFoundException {
    96
    97 Class clazz = null;
    98
    99 // (0) Check our previously loaded class cache
    100 clazz = findLoadedClass(name);
    101 if (clazz != null) {
    102 if (resolve)
    103 resolveClass(clazz);
    104 return (clazz);
    105 }
    106
    107 // (.5) Permission to access this class when using a
    SecurityManager
    108 if (securityManager != null) {
    109 int dot = name.lastIndexOf('.');
    110 if (dot >= 0) {
    111 try {
    112 // Do not call the security manager since by
    default, we grant that package.
    113 if
    (!"org.apache.jasper.runtime".equalsIgnoreCase(name.substring(0,dot))){
    114 securityManager.checkPackageAccess
    (name.substring(0,dot));
    115 }
    116 } catch (SecurityException se) {
    117 String error = "Security Violation, attempt
    to use " +
    118 "Restricted Class: " + name;
    119 se.printStackTrace();
    120 throw new ClassNotFoundException(error);
    121 }
    122 }
    123 }
    124
    125 if( !name.startsWith(Constants.JSP_PACKAGE_NAME + '.') )
    {
    126 // Class is not in org.apache.jsp, therefore, have
    our
    127 // parent load it
    128 clazz = parent.loadClass(name);
    129 if( resolve )
    130 resolveClass(clazz);
    131 return clazz;
    132 }
    133
    134 return findClass(name);
    135 }

    */


    laredotornado <> wrote in
    news::

    > Hi, I'm using Java 1.6 with Tomcat 6.0.26. When we are visiting
    > certain JSPs, we are getting the error below. All the literature I
    > have found so far pertains to applets, so I wanted to float this out
    > to the group to see what advice you have about troubleshooting this
    > further. Thanks, - Dave
    >
    > java.lang.ClassFormatError: Truncated class file
    > at java.lang.ClassLoader.defineClass1(Native Method)
    > at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    > at
    > java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
    > 124)
    > at java.net.URLClassLoader.defineClass(URLClassLoader.java:
    > 260)
    > at java.net.URLClassLoader.access$000(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.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:
    > 134)
    > at
    > org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
    > at
    > org.apache.jasper.JspCompilationContext.load

    (JspCompilationContext.java
    > : 598)
    > at
    > org.apache.jasper.servlet.JspServletWrapper.getServlet

    (JspServletWrappe
    > r.java: 144)
    > at
    > org.apache.jasper.servlet.JspServletWrapper.service

    (JspServletWrapper.j
    > ava: 329)
    > at
    > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
    > 320)
    > at
    > org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    > at javax.servlet.http.HttpServlet.service(HttpServlet.java:
    > 803)
    > at
    > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter

    (Applic
    > ationFilterChain.java: 290)
    > at
    > org.apache.catalina.core.ApplicationFilterChain.doFilter

    (ApplicationFil
    > terChain.java: 206)
    > at
    > org.apache.catalina.core.ApplicationDispatcher.invoke

    (ApplicationDispat
    > cher.java: 654) at
    > org.apache.catalina.core.ApplicationDispatcher.processRequest

    (Applicati
    > onDispatcher.java: 445)
    > at
    > org.apache.catalina.core.ApplicationDispatcher.doForward

    (ApplicationDis
    > patcher.java: 379)
    > at
    > org.apache.catalina.core.ApplicationDispatcher.forward

    (ApplicationDispa
    > tcher.java: 292)
    > at
    > com.lvcva.servlet.generic.GenericHttpServlet.callView

    (GenericHttpServle
    > t.java: 610) at
    > com.lvcva.servlet.dine.DiningServlet.details(DiningServlet.java:272)
    > at sun.reflect.GeneratedMethodAccessor457.invoke(Unknown
    > Source) at
    > sun.reflect.DelegatingMethodAccessorImpl.invoke

    (DelegatingMethodAccesso
    > rImpl.java: 25)
    > at java.lang.reflect.Method.invoke(Method.java:597)
    > at
    > com.lvcva.servlet.generic.GenericHttpServlet.doGet

    (GenericHttpServlet.j
    > ava: 587)
    > at javax.servlet.http.HttpServlet.service(HttpServlet.java:
    > 690)
    > at javax.servlet.http.HttpServlet.service(HttpServlet.java:
    > 803)
    > at
    > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter

    (Applic
    > ationFilterChain.java: 290)
    > at
    > org.apache.catalina.core.ApplicationFilterChain.doFilter

    (ApplicationFil
    > terChain.java: 206)
    > at
    > com.lvcva.filter.RecordPageFilter.doFilter(RecordPageFilter.java:30)
    > at
    > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter

    (Applic
    > ationFilterChain.java: 235)
    > at
    > org.apache.catalina.core.ApplicationFilterChain.doFilter

    (ApplicationFil
    > terChain.java: 206)
    > at
    > org.apache.catalina.core.StandardWrapperValve.invoke

    (StandardWrapperVal
    > ve.java: 230)
    > at
    > org.apache.catalina.core.StandardContextValve.invoke

    (StandardContextVal
    > ve.java: 175)
    > at
    > org.apache.catalina.core.StandardHostValve.invoke

    (StandardHostValve.jav
    > a: 128)
    > at
    > org.apache.catalina.valves.ErrorReportValve.invoke

    (ErrorReportValve.jav
    > a: 104)
    > at
    > org.apache.catalina.core.StandardEngineValve.invoke

    (StandardEngineValve
    > .java: 109)
    > at
    > org.apache.catalina.connector.CoyoteAdapter.service

    (CoyoteAdapter.java:
    > 261)
    > at
    > org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
    > at
    > org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
    > at
    > org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
    > at
    > org.apache.jk.common.ChannelSocket.processConnection

    (ChannelSocket.java
    > : 697)
    > at org.apache.jk.common.ChannelSocket
    > $SocketConnection.runIt(ChannelSocket.java:889)
    > at org.apache.tomcat.util.threads.ThreadPool
    > $ControlRunnable.run(ThreadPool.java:686)
    > at java.lang.Thread.run(Thread.java:619)
    >
    Karl Lopes, Dec 16, 2010
    #2
    1. Advertising

  3. laredotornado

    Mittal Guest

    Thanks. I had some problem in my tag file so it was giving this error. It got solved now.

    On Thursday, December 16, 2010 11:42:44 AM UTC+5:30, Karl Lopes wrote:
    > The problem is occuring in the load class method in JasperLoader. I
    > suspect your jsp is not getting compiled: (method is below).
    > Two things can be done here:
    > 1. Put a breakpoint in JasperLoader in the above class and see what
    > happens.
    > 2. Try to precompile your JSPs and see which one fails. That should give
    > you a start. (Ref: http://scriptlandia.blogspot.com/2006/04/how-to-pre-
    > compile-jsp-pages-for.html)
    > Karl.
    >
    >
    > /*
    > public Class loadClass(final String name, boolean resolve)
    > 95 throws ClassNotFoundException {
    > 96
    > 97 Class clazz = null;
    > 98
    > 99 // (0) Check our previously loaded class cache
    > 100 clazz = findLoadedClass(name);
    > 101 if (clazz != null) {
    > 102 if (resolve)
    > 103 resolveClass(clazz);
    > 104 return (clazz);
    > 105 }
    > 106
    > 107 // (.5) Permission to access this class when using a
    > SecurityManager
    > 108 if (securityManager != null) {
    > 109 int dot = name.lastIndexOf('.');
    > 110 if (dot >= 0) {
    > 111 try {
    > 112 // Do not call the security manager since by
    > default, we grant that package.
    > 113 if
    > (!"org.apache.jasper.runtime".equalsIgnoreCase(name.substring(0,dot))){
    > 114 securityManager.checkPackageAccess
    > (name.substring(0,dot));
    > 115 }
    > 116 } catch (SecurityException se) {
    > 117 String error = "Security Violation, attempt
    > to use " +
    > 118 "Restricted Class: " + name;
    > 119 se.printStackTrace();
    > 120 throw new ClassNotFoundException(error);
    > 121 }
    > 122 }
    > 123 }
    > 124
    > 125 if( !name.startsWith(Constants.JSP_PACKAGE_NAME + '.') )
    > {
    > 126 // Class is not in org.apache.jsp, therefore, have
    > our
    > 127 // parent load it
    > 128 clazz = parent.loadClass(name);
    > 129 if( resolve )
    > 130 resolveClass(clazz);
    > 131 return clazz;
    > 132 }
    > 133
    > 134 return findClass(name);
    > 135 }
    >
    > */
    >
    >
    > laredotornado <> wrote in
    > news::
    >
    > > Hi, I'm using Java 1.6 with Tomcat 6.0.26. When we are visiting
    > > certain JSPs, we are getting the error below. All the literature I
    > > have found so far pertains to applets, so I wanted to float this out
    > > to the group to see what advice you have about troubleshooting this
    > > further. Thanks, - Dave
    > >
    > > java.lang.ClassFormatError: Truncated class file
    > > at java.lang.ClassLoader.defineClass1(Native Method)
    > > at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    > > at
    > > java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
    > > 124)
    > > at java.net.URLClassLoader.defineClass(URLClassLoader.java:
    > > 260)
    > > at java.net.URLClassLoader.access$000(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.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:
    > > 134)
    > > at
    > > org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
    > > at
    > > org.apache.jasper.JspCompilationContext.load

    > (JspCompilationContext.java
    > > : 598)
    > > at
    > > org.apache.jasper.servlet.JspServletWrapper.getServlet

    > (JspServletWrappe
    > > r.java: 144)
    > > at
    > > org.apache.jasper.servlet.JspServletWrapper.service

    > (JspServletWrapper.j
    > > ava: 329)
    > > at
    > > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
    > > 320)
    > > at
    > > org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:
    > > 803)
    > > at
    > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter

    > (Applic
    > > ationFilterChain.java: 290)
    > > at
    > > org.apache.catalina.core.ApplicationFilterChain.doFilter

    > (ApplicationFil
    > > terChain.java: 206)
    > > at
    > > org.apache.catalina.core.ApplicationDispatcher.invoke

    > (ApplicationDispat
    > > cher.java: 654) at
    > > org.apache.catalina.core.ApplicationDispatcher.processRequest

    > (Applicati
    > > onDispatcher.java: 445)
    > > at
    > > org.apache.catalina.core.ApplicationDispatcher.doForward

    > (ApplicationDis
    > > patcher.java: 379)
    > > at
    > > org.apache.catalina.core.ApplicationDispatcher.forward

    > (ApplicationDispa
    > > tcher.java: 292)
    > > at
    > > com.lvcva.servlet.generic.GenericHttpServlet.callView

    > (GenericHttpServle
    > > t.java: 610) at
    > > com.lvcva.servlet.dine.DiningServlet.details(DiningServlet.java:272)
    > > at sun.reflect.GeneratedMethodAccessor457.invoke(Unknown
    > > Source) at
    > > sun.reflect.DelegatingMethodAccessorImpl.invoke

    > (DelegatingMethodAccesso
    > > rImpl.java: 25)
    > > at java.lang.reflect.Method.invoke(Method.java:597)
    > > at
    > > com.lvcva.servlet.generic.GenericHttpServlet.doGet

    > (GenericHttpServlet.j
    > > ava: 587)
    > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:
    > > 690)
    > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:
    > > 803)
    > > at
    > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter

    > (Applic
    > > ationFilterChain.java: 290)
    > > at
    > > org.apache.catalina.core.ApplicationFilterChain.doFilter

    > (ApplicationFil
    > > terChain.java: 206)
    > > at
    > > com.lvcva.filter.RecordPageFilter.doFilter(RecordPageFilter.java:30)
    > > at
    > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter

    > (Applic
    > > ationFilterChain.java: 235)
    > > at
    > > org.apache.catalina.core.ApplicationFilterChain.doFilter

    > (ApplicationFil
    > > terChain.java: 206)
    > > at
    > > org.apache.catalina.core.StandardWrapperValve.invoke

    > (StandardWrapperVal
    > > ve.java: 230)
    > > at
    > > org.apache.catalina.core.StandardContextValve.invoke

    > (StandardContextVal
    > > ve.java: 175)
    > > at
    > > org.apache.catalina.core.StandardHostValve.invoke

    > (StandardHostValve.jav
    > > a: 128)
    > > at
    > > org.apache.catalina.valves.ErrorReportValve.invoke

    > (ErrorReportValve.jav
    > > a: 104)
    > > at
    > > org.apache.catalina.core.StandardEngineValve.invoke

    > (StandardEngineValve
    > > .java: 109)
    > > at
    > > org.apache.catalina.connector.CoyoteAdapter.service

    > (CoyoteAdapter.java:
    > > 261)
    > > at
    > > org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
    > > at
    > > org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
    > > at
    > > org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
    > > at
    > > org.apache.jk.common.ChannelSocket.processConnection

    > (ChannelSocket.java
    > > : 697)
    > > at org.apache.jk.common.ChannelSocket
    > > $SocketConnection.runIt(ChannelSocket.java:889)
    > > at org.apache.tomcat.util.threads.ThreadPool
    > > $ControlRunnable.run(ThreadPool.java:686)
    > > at java.lang.Thread.run(Thread.java:619)
    > >
    Mittal, Sep 28, 2012
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page