Re: java.lang.ClassFormatError: Truncated class file
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 <laredotornado@zipmail.com> wrote in
news:6e10c54e-be59-4b4e-b228-4633082726b0@v6g2000prd.googlegroups.com:
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)