Bug 64097

Summary: Service loader implementation incomplete
Product: Tomcat 9 Reporter: Mark Thomas <markt>
Component: ELAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 9.0.x   
Target Milestone: -----   
Hardware: PC   
OS: Linux   

Description Mark Thomas 2020-01-25 08:25:37 UTC
The custom service loader implementation used by the EL API is incomplete. It does not skip comments causing it to use a comment line as a class name. This means it often fails to load a valid EL implementation present on the class path.

I suspect the issues are not limited to comment handling but I haven't dug further.

Switching to using ServiceLoader rather than a custom implementation looks to be the best solution.
Comment 1 Mark Thomas 2020-01-27 12:31:47 UTC
Fixed in:
- master for 10.0.0.0-M1 onwards
- 9.0.x for 9.0.31 onwards
- 8.5.x for 8.5.51 onwards
- 7.0.x for 7.0.100 onwards
Comment 2 Peer Heijnen 2020-03-02 21:34:08 UTC
In Tomcat 8.5.51 we now have a regression when compiling JSP's in Maven (using io.leonard.maven.plugins:jspc-maven-plugin:2.4.5) that might be related to this fix:

javax.el.ELException: Unable to find ExpressionFactory of type: # Licensed to the Apache Software Foundation (ASF) under one or more
 	at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:154)
 	at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:93)
 	at org.apache.jasper.compiler.PageInfo.<init>(PageInfo.java:79)
 	at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:114)
 	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:372)
 	at org.apache.jasper.JspC.processFile(JspC.java:1263)
 	at org.apache.jasper.JspC.execute(JspC.java:1415)
 	at io.leonard.maven.plugins.jspc.JspcWorker.call(JspcWorker.java:27)
 	at io.leonard.maven.plugins.jspc.JspcWorker.call(JspcWorker.java:9)
 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 	at java.lang.Thread.run(Thread.java:745)
 Caused by: java.lang.ClassNotFoundException: # Licensed to the Apache Software Foundation (ASF) under one or more
 	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
 	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
 	at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:147)
 	... 12 more

This seems to be the direct opposite of what was intended.

Reverting to Tomcat 8.5.50 fixes the issue.

Related Google search result: https://forum.axelor.com/t/error-when-trying-to-start-the-demo-app-on-tomcat-com-axelor-internal-javax-el-elexception-unable-to-find-expressionfactory-of-type-licensed-to-the-apache-software-foundation-asf-under-one-or-more/2625
Comment 3 Mark Thomas 2020-03-02 21:47:50 UTC
You aren't using 8.5.51. That stack trace is from 8.5.50. Looks like you have a strange combination of versions. The users list is the place to see further help.
Comment 4 Peer Heijnen 2020-03-02 22:01:34 UTC
You are absolutely right. Thanks for your quick and correct analysis!

Problem was caused by the depedency of the Maven plugin on an older Tomcat version. Fixed by updating its dependency.
Comment 5 Josh V 2020-03-04 08:33:29 UTC
(In reply to Peer Heijnen from comment #4)
> You are absolutely right. Thanks for your quick and correct analysis!
> 
> Problem was caused by the depedency of the Maven plugin on an older Tomcat
> version. Fixed by updating its dependency.

May I ask exactly what you changed? I am getting a similar issue and cannot find a maven plugin in my project with a tomcat dependency. Thanks!
Comment 6 Mark Thomas 2020-03-04 08:56:06 UTC
Restore the correct resolution. If you have questions, please use the users mailing list.
Comment 7 sandeepiitcs 2020-03-09 07:15:39 UTC
Hi Mark, 

I recently upgraded it to tomcat 8.5.51. And observing this error stack trace

Servlet.service() for servlet [jsp] in context with path [/my-app] threw exception [Unable to compile class for JSP] with root cause java.lang.ClassNotFoundException: # Licensed to the Apache Software Foundation (ASF) under one or more
 at org.eclipse.gemini.web.tomcat.internal.loader.BundleWebappClassLoader.loadClass(BundleWebappClassLoader.java:318)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
 at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:147)
 at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:93)
 at org.apache.jasper.compiler.PageInfo.<init>(PageInfo.java:79)
 at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:116)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:375)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:351)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:335)
 at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:597)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:399)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
 at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
 at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
 at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
 at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)

Can you please let me know, why i am getting this error after upgrading to 8.5.51 version ?
As i havent faced this issue while upgrading it to 8.5.50
Comment 8 Mark Thomas 2020-03-09 07:52:15 UTC
You aren't using the EL API from 8.5.51. The EL API you are using suffers from this bug. The users list is the place to see help.
Comment 9 sandeepiitcs 2020-07-01 10:05:22 UTC

(In reply to Mark Thomas from comment #8)
> You aren't using the EL API from 8.5.51. The EL API you are using suffers
> from this bug. The users list is the place to see help.

Hi Mark, Thanks for your reply. Can you please let me know how can i check that i am not using EL API from 8.5.51 and so i can update it.