ElException when migrating from tomcat 8.0 to 8.5 - java

We are currently migrating our apps from tomcat 8.0 to tomcat 8.5.
In these apps, we have a very simple spring JEE app which uses JSPs and spring controllers.
When deployed on a Tomcat 8.0, the jsp pages are correctly served, while it produces an error on tomcat 8.5 :
javax.el.ELException: The class [com.orange.gvw.acd.controllers.ApiConnectionController] could not be imported as it could not be found
javax.el.ImportHandler.importClass(ImportHandler.java:114)
org.apache.jasper.runtime.PageContextImpl.getELContext(PageContextImpl.java:962)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:935)
org.apache.jsp.WEB_002dINF.views.manageConnections_jsp._jspService(manageConnections_jsp.java:192)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
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:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1243)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:965)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:856)
javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:841)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
We found out that this issue happens when our jsp page is including an el, e.g. ${toto}. When we remove this el, it works.
Is there something to be fixed or configured in order to serve jsp that includes el ?

Answering to myself, the issue was on the platform side : We had the package libservlet3.1-java version 8.0.14-1+deb8u11 installed, whereas the version 8.5.14-1~bpo8+1 was required for tomcat 8.5.

Related

Reading of project.properties file in jsp in hybris

I have a key in my project.properties as userKey=value
I wanna read the value in jsp with using configservice in java. Is there a possibility to do it?
I tried to use
<%# taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<spring:message code="label.username"/>
<spring:message code="label.password"/>
but it failed with below error :
WARN [hybrisHTTP30] [DefaultCMSComponentRendererRegistry] Error
processing component tag. currentComponent
[MerchGenericMediaComponentModel (8800615040060#15)] exception:
javax.serv
Sep 14, 2017 2:31:16 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspTagException: No message found under code 'userKey' for locale 'en'.
at org.springframework.web.servlet.tags.MessageTag.doEndTag(MessageTag.java:200)
at org.apache.jsp.WEB_002dINF.views.mobile.cms.th.merchgenericmediacomponent_jsp._jspx_meth_spring_005fmessage_005f0(merchgenericmediacomponent_jsp.java:472)
at org.apache.jsp.WEB_002dINF.views.mobile.cms.th.merchgenericmediacomponent_jsp._jspService(merchgenericmediacomponent_jsp.java:130)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:603)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:542)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:160)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1257)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
This will work. Use the below snippet in the Jsp and replace the 'propertykey' with the one which you want to retrieve from local.properties or project.properties.
${jalosession.tenant.config.getParameter('propertykey')}
If you really only want to set some language properties than you should definitly use the:
\web\webroot\WEB-INF\messages\base.properties
for this configuration. Therefore this file was made. But if you have some other properties that you want to use in you *.jsp file you can use:
<spring:eval expression="T(de.hybris.platform.util.Config).getParameter('your.code')" var="myVar" scope="page" />
You should try putting your labels(in this case userKey=value) in base.properties file (or base_en.properties) instead of project.properties
base.properties is used for I18n, while
project.properties is used to configure ports, build environment, JVM options, etc...

IntelliJ Web Module Dependencies on other Module

I created a new web module in IntelliJ. The java classes in my src folder make calls to classes in another module, which is causing some java.lang.NoClassDefFoundError errors at runtime (everything is compiling correctly though). Is there a way to add a dependency such that the jsp files in my web app are properly able to access these java classes in this separate module?
Here's the error:
Type Exception Report
Message java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
"Exception
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:176)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:380)
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:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
java.net.URLClassLoader.findClass(URLClassLoader.java:381)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:129)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:60)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:171)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:380)
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:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Note The full stack trace of the root cause is available in the server logs."

java.lang.NoSuchMethodError: javax.el.ExpressionFactory.getStreamELResolver()Ljavax/el/ELResolver;

I get the error java.lang.NoSuchMethodError: javax.el.ExpressionFactory.getStreamELResolver()Ljavax/el/ELResolver; while using jstl in tomcat 8.0.33. I've checked the WEB-INF/lib of my application and it doesn't contain anything that is conflicting.
Also I checked the source code of javax.el.ExpressionFactory class from el-api.jar file present in tomcat 8's lib folder. The method signature is public ELResolver getStreamELResolver().
This issue occurred after I migrated an application from tomcat 6.0.35 to tomcat 8.0.33. The application was written using jstl-1.2
The complete stacktrace is
16-May-2016 19:14:54.119 SEVERE [ajp-nio-11009-exec-4] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [spring] in context with path [/app] threw exception [Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException: org.apache.tiles.util.TilesIOException: JSPException including path '/WEB-INF/JSP/APP/display.jsp'.] with root cause
java.lang.NoSuchMethodError: javax.el.ExpressionFactory.getStreamELResolver()Ljavax/el/ELResolver;
at org.apache.jasper.el.ELContextImpl.<clinit>(ELContextImpl.java:87)
at org.apache.jasper.compiler.Validator$ValidateVisitor.prepareExpression(Validator.java:1617)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:750)
at org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:950)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1853)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:720)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:584)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:523)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:935)
at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:679)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:673)
at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:103)
at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:96)
at org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
at org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer.write(ChainedDelegateAttributeRenderer.java:76)
at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:336)
at org.apache.tiles.template.InsertAttributeModel.renderAttribute(InsertAttributeModel.java:210)
at org.apache.tiles.template.InsertAttributeModel.end(InsertAttributeModel.java:126)
at org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:311)
... (truncated)
How to resolve this issue?
To tackle such problems of different versions of same class present on the classpath - the best way is to enable verbose class loading and see whether the class is actually being loaded from the intended jar file.
From command line we can run java -verbose:class MyClassWithMain. This will output all the classes loaded in the JVM and the name of the jar or any class on the classpath from which it was loaded. Once you find the source of the problem, you can remove it.
To enable verbose:class in tomcat, see this answer.

Using JNI so files on a dynamic web project(Apache Tomcat Server)

I am making a dynamic web project, which requires to use an external jar file. That jar uses several JNI so files. Now I have the jar and all the required so files. I have added the jar to the java build path, but I am not sure how to introduce the so files to the tomcat server.
I tried adding path to the so file as "LD_LIBRARY_PATH":
(Properties->Run/Debug Settings->edit->Environment->Select) and also
adding the path to "java.library.path"(Run
As->RunConfigurations->Tomcat v8 Server->Arguments->VM arguments)
flag.
Still it is not working, I am getting below error, whenever the my code is trying to access functions/classes from the above mentioned jar:
SEVERE: Servlet.service() for servlet [org.iotivity.simulator.agent.LaunchSimulator] in context with path
[/SimulatorAgent] threw exception [Servlet execution threw an
exception] with root cause java.lang.ClassNotFoundException:
org.oic.simulator.server.SimulatorResource$Type at
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
at
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1139)
at
org.iotivity.simulator.agent.LaunchSimulator.doPost(LaunchSimulator.java:86)
at
org.iotivity.simulator.agent.LaunchSimulator.doGet(LaunchSimulator.java:45)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
I have tried the same code with a simple Java Application, and it works fine by setting the LD_LIBRARY_PATH variable.
Any suggestion will be highly appreciated.
Your error is a ClassNotFoundException, which would suggest that the JAR isn't properly included. If there was a problem with the native library, you'd get a UnsatisfiedLinkError instead. To make the JAR available to Tomcat, you'd need to add it to the classpath (-classpath=/path/to/your.jar) or include it in your WAR. The latter depends on your build system, but if you use Maven it's rather easy using the maven-shade-plugin (this only works for the JAR though, the native code you'll have to keep on distributing separately). Hope that helps!

.War Works to deploy on Windows but fails to deploy on a Linux server (Tomcat 7)

As title introduced, the .War file I'm trying to deploy by using Tomcat 7 is not working on a machine running Linux. It does work on Windows and is of course deployed with Tomcat 7.
I've tried to track down the issue alone & searched for related problems on the web including this forum with no success so far. That is why i created this thread asking for help / hints.
The error message I tracked down are the following:
Sep 14, 2015 4:46:05 PM org.apache.catalina.deploy.NamingResources cleanUp
WARNING: Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/SmartHomeReasoner]] so no cleanup was performed for that container
javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context. Unable to find [comp].
at org.apache.naming.NamingContext.lookup(NamingContext.java:819)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.apache.catalina.deploy.NamingResources.cleanUp(NamingResources.java:986)
at org.apache.catalina.deploy.NamingResources.stopInternal(NamingResources.java:968)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5676)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:141)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1256)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:692)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:217)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:610)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
It were 2 problems actually causing this issue.
To solve the issue I had to:
*Check the web.xml VERY carefully after any misstakes like e.g. servlets that do not exist our already defined things e.g. driver being defined twice, meaning it's defined somewhere already AND also in the web.xml.
*Remove servlet in the ..\WEB-INF\lib folder of the project. E.g. javax.servlet-api-3.0.1.jar + javax.servlet-api-3.1.0.jar were removed in this case.
NOTE I even had jars that can conflict with each other on project-level but still I was able to deployed successfully on Windows but not on Linux.
Trust me both of the things I mentioned can be a issue, most likely if you take over work from other devs that have done this miss.
Just had the same issue and synchronizing the Java version for the Maven build (from 1.8 to 1.10) and the running environment (1.10) solved it.

Categories