Hi, With Tomcat 9.0.34 the JDT compiler was updated to 4.15. Since then, there is an error when Tomcat compiles the JSP at runtime when this construct is used in a JSP:
<%@ page import="java.util.List"%> <%@ page import="java.util.ArrayList"%> <% class InnerClass { // some class members } List<InnerClass> list = new ArrayList<>(); for(InnerClass elements : list) { // do sth } %> This is root cause: java.lang.ClassCastException: class org.eclipse.jdt.internal.compiler.lookup.PlainPackageBinding cannot be cast to class org.eclipse.jdt.internal.compiler.lookup.TypeBinding (org.eclipse.jdt.internal.compiler.lookup.PlainPackageBinding and org.eclipse.jdt.internal.compiler.lookup.TypeBinding are in unnamed module of loader java.net.URLClassLoader @20398b7c) org.eclipse.jdt.internal.compiler.ClassFile.getTypeBinding(ClassFile.java:5941) org.eclipse.jdt.internal.compiler.ClassFile.traverse(ClassFile.java:7011) org.eclipse.jdt.internal.compiler.ClassFile.generateStackMapTableAttribute(ClassFile.java:4826) org.eclipse.jdt.internal.compiler.ClassFile.completeCodeAttribute(ClassFile.java:1519) org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:357) org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:281) org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:579) org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:649) org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:412) org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:912) org.eclipse.jdt.internal.compiler.Compiler.processCompiledUnits(Compiler.java:575) org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:475) org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:528) org.apache.jasper.compiler.Compiler.compile(Compiler.java:392) org.apache.jasper.compiler.Compiler.compile(Compiler.java:362) org.apache.jasper.compiler.Compiler.compile(Compiler.java:346) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:605) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:400) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) If the JSP is precompiled using an ant task and the JDT compiler, the error doesn’t occur: <javac srcdir="${basedir}/work" destdir="${basedir}/work" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}" includeantruntime="false" target="${java.version}" source="${java.version}"> <classpath refid="compile.classpath"/> <compilerarg compiler="org.eclipse.jdt.core.JDTCompilerAdapter" /> </javac> I know that the error is within the JDT Stacktrace, but because this error doesn’t occur when using the JDT for compiling the generated Java file, I assume that this problem is related to a Tomcat configuration. I use the docker image tomcat:9.0.34. If required I can also provide the Java source generated from the JSP. Best regards, Markus