In my project I found this exception org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException. How to resolve it?
Asked Answered
H

13

27
org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException
    at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:372)
    at org.apache.jasper.compiler.JDTCompiler$1.findType(JDTCompiler.java:232)
    at org.apache.jasper.compiler.JDTCompiler$1.findType(JDTCompiler.java:188)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:113)
    at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49)
    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:122)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(LookupEnvironment.java:1335)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromVariantTypeSignature(LookupEnvironment.java:1391)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeArgumentsFromSignature(LookupEnvironment.java:1172)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(LookupEnvironment.java:1340)
    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethod(BinaryTypeBinding.java:550)
    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethods(BinaryTypeBinding.java:630)
    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:365)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:688)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:667)
    at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:296)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:118)
    at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49)
    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:122)
    at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:168)
    at org.eclipse.jdt.internal.compiler.lookup.Scope.getPackage(Scope.java:2379)
    at org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference.internalResolveLeafType(ParameterizedQualifiedTypeReference.java:138)
    at org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference.internalResolveType(ParameterizedQualifiedTypeReference.java:132)
    at org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference.resolveType(ParameterizedQualifiedTypeReference.java:351)
    at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypeFor(SourceTypeBinding.java:1374)
    at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.fields(SourceTypeBinding.java:699)
    at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.faultInTypesForFieldsAndMethods(SourceTypeBinding.java:677)
    at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes(CompilationUnitScope.java:469)
    at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:756)
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:468)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:459)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:931)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

I am using Apache Tomcat/7.0.33, eclipse-jee-kepler-SR1-RC3-win32

Hyalite answered 18/2, 2014 at 11:22 Comment(2)
looks like a tomcat problem. what tomcat version, eclipse version and jvm version are you using?Placia
Tomcat now uses the bundled Eclipse compiler to compile JSPs - it's not related to the IDE being used, per se. The question I do have is: What version of the JDK are you using?Halftrack
E
28

Thanks much for the tips! Ran into same ClassFormatException error on Tomcat 6.0.20 and JDK1.8. Replaced the jasper-jdt.jar with ecj-4.2.2.jar and all the JSPs compiling/working again.

Epode answered 21/10, 2016 at 17:15 Comment(6)
This should be commentLelandleler
Solved the problem for me !Americanize
add this jar ecj-4.2.2.jar file into your tomcat_install_folder/lib/ecj-4.2.2.jar and stop tomcat server and delete or rename the old version of the ecj like old_ecj-3.6.jar and start your tomcat server it work for me without touching the jasper-jdt.jar bcz it was not there in the lib folder for meTheorize
Solved my problem, didn't noticed I changed the JRE_HOME path.Palisade
Phew, this one saved my day!Alec
This just made some of our tests a lot easier. No need to migrate old servers to Tomcat 9 just before decommissionning them, and that's good.Ramonaramonda
G
13

The problem is related to ecj version (ecj-3.7.2.jar), you have to use a more recent version of tomcat compatible with jdk8 (apache-tomcat-7.0.68 works fine for me )

Groceryman answered 9/3, 2016 at 17:50 Comment(0)
C
11

I hope the following steps will solve your problem.

1) Stop the tomcat.

2) Download ecj-4.2.2.jar in this link

3) Copy ecj-4.2.2.jar under tomcat's lib folder (example - C:\apache-tomcat-6.0.36\lib).

4) Rename ecj-3.7.2.jar to old_ecj-3.7.2.jar.

5) Start the tomcat.

Cariole answered 23/5, 2018 at 8:19 Comment(0)
E
5

If you use maven and jdk8 to start tomcat7, make sure that the version of the tomcat7-maven-plugin is at least 2.2

Estaminet answered 16/1, 2016 at 14:3 Comment(0)
N
2

Remove existing localhost servers and add new server. This will solve your problem.

Normally answered 23/9, 2014 at 7:33 Comment(0)
C
2

Check Your Tomcat Version.If your tomcat version 7.0.29 and below then Remove your Old Tomcat and Download latest one . And run the project https://tomcat.apache.org/download-90.cgi

Charil answered 21/6, 2016 at 12:13 Comment(0)
K
1

If you is using java 8 maybe you should update your eclipse version.

Eclipse doc

Kaja answered 27/10, 2014 at 11:41 Comment(0)
R
1

Going by the information in the stack trace, it seems that there is a compilation problem with the built in eclipse compiler which it uses rather than javac. All the Luna builds of Eclipse have support for jdk 8 but as you have mentioned that you are using Eclipse Kepler, you would have to download a feature patch from the eclipse community itself in order to support jdk 8.

Meanwhile you can you use jdk 7 and recompile your project. See if the error goes away. Apart from that the code looks fine to me. I hope it helps. Happy to help.

Rexanne answered 16/11, 2015 at 9:41 Comment(0)
M
1

I had the same problem using Tomcat 6 with Java 8. I solved it by configuring Tomcat to use Java 7 instead of 8: Add export JAVA_HOME=/usr/lib/jvm/java-7-oracle in your {tomcat-home}/bin/catalina.sh or your custom startup script.

Mousey answered 6/6, 2016 at 7:41 Comment(0)
D
0

Note that 1. We cannot update the version of ECJ included with Tomcat 6, as Tomcat 6 must be able to run on Java 1.5, but current ECJ releases require minimum of Java 6.

  1. You may replace ecj-*.jar with a later version that you may download from http://www.eclipse.org/

See archives of Tomcat Users mailing list, and ask on the mailing list if you have questions. (Bugzilla is not a support forum).

  1. Tomcat can be configured to use Java javac compiler instead of Eclipse
Dosage answered 25/6, 2016 at 19:15 Comment(0)
D
0

i also faced same problem after searching many article i could found this solution

which version of Tomcat you are using.

Second, for Java 8 you have to use a version of Eclipse ECJ compiler that supports Java 8.

The "ClassFormatException" probably means that your version of ECJ does not know about Java 8 at all.

change the jre new version to old version because it doesn't support to this tomcat version

Dosage answered 25/6, 2016 at 19:21 Comment(0)
R
0

This Problem is caused due to compatibility issue with jdk, tomcat and Eclipse. For resolving this problem use jdk ver 1.8 with apache tomcat 8.0 and updated Eclipse Mars 2.0.

I have the same problem with Apache Tomcat 7.0.

Reconfigure all and your problem will be solved.

Rockhampton answered 29/8, 2016 at 6:57 Comment(0)
C
0

If you got here using something a little more modern (I was updating a project from java8 to java17), upgrading jasper, itext and poi from the old version to the new version did the trick for me.

Carolincarolina answered 2/8, 2022 at 18:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.