Re: 'for each' statements are only available if source level is 1.5 or greater
Fabian Hahn <[email protected]>
| Newsgroups | gmane.comp.jakarta.tomcat.user |
|---|---|
| Message-ID | <[email protected]> |
> Am 12.12.2025 um 06:17 schrieb Mark Foley <[email protected]>: > > On Thu Dec 11 23:42:52 2025 Thu, 11 Dec 2025 22:40:39 Chuck Caldarale <[email protected]> >> >>> On 2025 Dec 11, at 22:10, Mark Foley <[email protected]> wrote: >>> >>> On Thu, 11 Dec 2025 16:25:07 Christopher Schultz <[email protected]> wrote: >>>> >>>> Mark, >>>> >>>> On 12/11/25 4:19 PM, Mark Foley wrote: >>>>> On Thu, 11 Dec 2025 20:17:30 Mark Thomas <[email protected]> wrote: >>>>>> >>>>>> On 11/12/2025 17:49, Mark Foley wrote: >>>>>>> I've upgraded 2 systems from Tomcat 8.5.11 to Tomcat 10.1.13. The first system >>>>>>> was done a couple of years ago and runs just fine. >>>>>>> >>>>>>> I've just upgraded the 2nd system which is not running just fine. I've been working >>>>>>> on this for a week. When I run it I get numerous errors related to "source level >>>>>>> is 1.5 or greater." >>>>>>> >>>>>>> when I run tomcat I get: >>>>>>> >>>>>>> Using CATALINA_HOME: /srv/tomcat >>>>>>> Using CATALINA_TMPDIR: /srv/tomcat/temp >>>>>>> Using JRE_HOME: /user/util/src/jdk-17.0.8 >>>>>>> Using CLASSPATH: /srv/tomcat/bin/bootstrap.jar:/srv/tomcat/bin/tomcat-juli.jar >>>>>>> >>>>>>> The libs on the non-running system are basically the same as on the running >>>>>>> system except some are newer versions. I can post the differences if that would >>>>>>> help. >>>>>>> >>>>>>> I've compared the $CATALINA_HOME/conf files between systems and I don't see any >>>>>>> meaningful differences. >>>>>>> >>>>>>> I've tried changing https://www.google.com/url?q=https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd&source=gmail-imap&ust=1766121536000000&usg=AOvVaw2ha1pCx3H8WaAjmJ1GvUPV to >>>>>>> https://www.google.com/url?q=https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd&source=gmail-imap&ust=1766121536000000&usg=AOvVaw3QgsGqR5YgA_93FLLbUB-A (which is one difference). >>>>>>> That didn't help. >>>>>>> >>>>>>> I've tried explicitly setting the compilerSourceVM to 11. That didn't help. >>>>>>> >>>>>>> What can I look at to find this problem and fix it? >>>>>> >>>>>> Please clear out the logs, start the Tomcat instance then provide >>>>>> complete error message(s) including any stack traces you get on the >>>>>> console / in the logs / in the browser and tell us where you see them. >>>>>> >>>>>> If there are lots of errors, the first ones are very likely to be the >>>>>> most useful. >>>>>> >>>>>> Mark >>>>> >>>>> No errors in log ($CATALINA_HOME/logs/catalina.out). Lots of WARNINGs and INFOs. >>>>> >>>>> Do you really want me to post the complete log? There are 3100+ entries. >>>> >>>> How about the first dozen or so errors? >>>> >>>> -chris >>>> >>> >>> Not a dozen, but here are the first few. Lots of repetition of these. >>> >>> 08-Dec-2025 03:25:13.513 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine/Host] failed to set property [xmlValidation] to [false] >>> 08-Dec-2025 03:25:13.515 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine/Host] failed to set property [xmlNamespaceAware] to [false] >>> 08-Dec-2025 03:25:13.516 WARNING [main] org.apache.tomcat.util.digester.Digester.endElement No rules found matching [Server/Service/Engine/Host/Logger] >>> 08-Dec-2025 03:25:13.529 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine/Host/Context] failed to set property [allowLinking] to [true] >>> 08-Dec-2025 03:25:13.533 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine/Host] failed to set property [xmlValidation] to [false] >>> 08-Dec-2025 03:25:13.533 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine/Host] failed to set property [xmlNamespaceAware] to [false] >>> 08-Dec-2025 03:25:13.533 WARNING [main] org.apache.tomcat.util.digester.Digester.endElement No rules found matching [Server/Service/Engine/Host/Logger] >>> 08-Dec-2025 03:25:13.534 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine/Host/Context] failed to set property [allowLinking] to [true] >>> 08-Dec-2025 03:25:13.534 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine/Host] failed to set property [xmlValidation] to [false] >>> 08-Dec-2025 03:25:13.534 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine/Host] failed to set property [xmlNamespaceAware] to [false] >>> >>> I don't know about the link warnings. context.xml has: <Resources allowLinking="true" /> >>> and each <Host> entry in server.xml has: >>> >>> <Context path="" docBase="horeb-wright3" reloadable="false" allowLinking="true"> >>> >>> and the index.jsp file it's choking on is symlinked, but it is trying to run it -- >>> but I also tried all this with non-symlinked files. >> >> >> Where exactly do you see the message "source level is 1.5 or greater"? It’s certainly not in the above set of warnings. >> >> You should clean out the junk in your <Host> and <Context> configurations so that the real problem(s) might become more visible. None of the properties mentioned in the messages are permitted in those configuration elements. (<Resources> does include allowLinking, but setting it to "true" has security implications on some systems.) >> >> Hopefully, you didn’t just copy the Tomcat 8.5 config files into Tomcat 10.1 - the config items have changed noticeably over the years. >> >> - Chuck > > The "source level is 1.5 or greater" is on the web page. Here are the first > several lines: > > HTTP Status 500 - Internal Server Error > > Type Exception Report > > Message Unable to compile class for JSP: > > Description The server encountered an unexpected condition that prevented it from fulfilling the request. > > Exception > > org.apache.jasper.JasperException: Unable to compile class for JSP: > > An error occurred at line: [17] in the jsp file: [/include/homePageImage.inc] > Syntax error, 'for each' statements are only available if source level is 1.5 or greater > 14: > 15: //out.println(getServletContext().getRealPath("") + "Contents/" + "<br/>dirs: " + dirs.length + "<br/>Files: " + files.length + "</body></html>"); > 16: > 17: for (String image : scanner.getIncludedFiles()) > 18: { > 19: // out.println("<p>" + scanner.getBasedir() + ", " + image); > 20: return "Contents/" + image; // just first file for now > > > An error occurred at line: [545] in the generated java file: [/user/util/src/apache-tomcat-10.1.13/work/Catalina/www.horeb-wright3.org/ROOT/org/apache/jsp/index_jsp.java] > Syntax error, parameterized types are only available if source level is 1.5 or greater > > : > : > > An error occurred at line: [115] in the jsp file: [/index.jsp] > System.err cannot be resolved to a type > 112: > 113: if (evalParam(request.getParameter("logout")).length() > 0) > 114: { > 115: System.err.println("[hiram]: " + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date()) + > 116: " " + request.getRemoteAddr() + " LOGOUT"); > 117: session.setAttribute("personId",null); > 118: session.setAttribute("loginId",null); > > > An error occurred at line: [217] in the jsp file: [/index.jsp] > The method setAttribute(String, Object) in the type HttpSession is not applicable for the arguments (String, boolean) > 214: > 215: if (session.getAttribute("isParent") == null) // 1st time, not set. otherwise, set by re-loading or changed by actual login > 216: { > 217: session.setAttribute("isParent", ((rs.getString("cnt") != null) && (rs.getInt("cnt") > 0)) ? true : false); One of the problems seems to be that you are trying to compile the JSP-files with a very old Java version compatibility. You could improve this by defining the jsp servlet in your web.xml (or tomcat-web.xml). Here you define the Java version for compiling the JSPs. This should get rid of the "source level" messages. <web-app . . . <servlet> <servlet-name>jsp</servlet-name> <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> <init-param> <param-name>compilerSourceVM</param-name> <param-value>17</param-value> </init-param> <init-param> <param-name>compilerTargetVM</param-name> <param-value>17</param-value> </init-param> </servlet> </web-app> > > And there's more. I can stage that page for you if you want. > > No, these are not my 8.5 config files. They were mainly adapted from my running > 10.1.15 system. That system I got running by modifying the 8.5 config files > about 2 years ago with help from this list. > > I don't know that I have "junk" in the conf files. I don't tend to be inventive > with these things myself. Here's my whole server.xml file, sans comments. Please > let me know if you see anything wrong. > > <?xml version="1.0" encoding="UTF-8"?> > <Server port="8005" shutdown="SHUTDOWN"> > <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> > <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> > <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> > <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> > <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> > > <GlobalNamingResources> > <Resource name="UserDatabase" auth="Container" > type="org.apache.catalina.UserDatabase" > description="User database that can be updated and saved" > factory="org.apache.catalina.users.MemoryUserDatabaseFactory" > pathname="conf/tomcat-users.xml" /> > </GlobalNamingResources> > > <Service name="Catalina"> > > <Connector port="8080" protocol="HTTP/1.1" > connectionTimeout="20000" > redirectPort="8443" > maxParameterCount="1000" > /> > > <Connector protocol="AJP/1.3" > address="127.0.0.1" > port="8009" > redirectPort="8443" > maxParameterCount="1000" > secretRequired="false" /> > > <Engine name="Catalina" defaultHost="localhost"> > <Realm className="org.apache.catalina.realm.LockOutRealm"> > <Realm className="org.apache.catalina.realm.UserDatabaseRealm" > resourceName="UserDatabase"/> > </Realm> > > <Realm className="org.apache.catalina.realm.MemoryRealm" /> > > <Host name="localhost" appBase="webapps" > unpackWARs="true" autoDeploy="true"> > > <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" > prefix="localhost_access_log" suffix=".txt" > pattern="%h %l %u %t "%r" %s %b" /> > > </Host> > > <Host name="www.horeb-wright3.org" appBase="webapps" > unpackWARs="true" autoDeploy="true" > xmlValidation="false" xmlNamespaceAware="false"> > > <Alias>horeb-wright3.org</Alias> > <Logger className="org.apache.catalina.logger.FileLogger" directory="logs/" prefix="horeb_access_log" suffix=".log" timestamp="true"/> > > <Context path="" docBase="horeb-wright3" reloadable="false" allowLinking="true"> > <WatchedResource>/WEB-INF/web.xml</WatchedResource> > <WatchedResource>/style.css</WatchedResource> > </Context> > </Host> > > </Engine> > </Service> > </Server> > > This last <Host> tag block is repeated another 20 times, almost identically > except for the domain names, for the additional hosts on this server. Otherwise, > this server.xml file is nearly identical to the one on the running system except > this "new" one has maxParameterCount="1000" in the connector tags and the > running system server.xml does not. > > --Mark Good luck, Fabian PS: I do not understand why the default is not set to the min. required Java version. Possibly the current version, sans possible dependency restrictions. (i.e. Java 24 for Tomcat 11)