Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] [jetty-users] JSP pages are recompiled at runtime

The recommended way to deploy for a production environment is to precompile jsps and place <servlet> definitions for them into web.xml. You can use a tool like the jetty-jspc-maven-plugin to do that for you: see https://www.eclipse.org/jetty/documentation/current/jetty-jspc-maven-plugin.html. You could also use an ant task to do the compilation, see https://tomcat.apache.org/tomcat-8.5-doc/jasper-howto.html#Production_Configuration. This way, page accesses are fast as there is no on-the-fly compilation and thus no need for a full jdk on the production machine.

When NOT using precompiled jsps defined as <servlets>, when a jsp page is requested, the jsp engine uses the scratch dir to look for a class matching the jsp. It does so iff development==true or the page is being requested for the first  time. The page will be (re)compiled iff: the class does not exist, or the modification date on the jsp page is more recent than the date on the class file.

As Joakim suggests, you should try and produce more debug logs to determine the difference between your test and production environments. But ideally, you would instead use the proper pre-compilation procedure for your production environment.

Jan


On 14 September 2017 at 07:56, upendar devu <devulapalli8@xxxxxxxxx> wrote:
I'm sure that we didn't get any errors removing scratch dir.

On Sep 13, 2017 5:39 PM, "Joakim Erdfelt" <joakim@xxxxxxxxxxx> wrote:
Removing that scratchdir attribute just moves the jsp compilation to system temp (aka java.io.tmpdir)
Its a requirement for JSP, you cannot run without a scratch directory.
In fact, you'll get startup errors if the scratch directory is bad/invalid.

Eg:

The JSP engine is not configured with a scratch dir. \n 
Please add \"jsp.initparams=scratchdir=<dir-name>\" \n 
in the servlets.properties file for this context.

or 

The scratchDir you specified: {0} is unusable.

I believe that to use precompiled JSPs you have to put the precompiled versions into your ServletContextHandler as servlets.

Jan, do you concur?


Joakim Erdfelt / joakim@xxxxxxxxxxx

On Wed, Sep 13, 2017 at 2:18 PM, upendar devu <devulapalli8@xxxxxxxxx> wrote:
We removed below line of code then we dont see the folder embedded-jetty-jsp getting created . I believe server using the pre compiled jsp pages as I dont locate the JSPs recompiling.

context.setAttribute("javax.servlet.context.tempdir", getScratchDir());

On Wed, Sep 13, 2017 at 5:16 PM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
I would have expected each compiled JSP to be added as a Servlet to the ServletContextHandler via the .addServlet() call.


Joakim Erdfelt / joakim@xxxxxxxxxxx

On Wed, Sep 13, 2017 at 2:10 PM, upendar devu <devulapalli8@xxxxxxxxx> wrote:
Thanks for quick response.  I dont think we followed the example code you followed but little lines of code might match .

Attached code snippet what we are using.  Please refer the code.

I think below line of code does .
WebAppContext.setBaseResource(new ResourceCollection(validPaths.toArray(new String[0])));.
i.e 
WebAppContext.setBaseResource(new ResourceCollection("src/main/webapp", "src/main/resources", "src/main", "webapp", ".");



On Wed, Sep 13, 2017 at 4:45 PM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
The fact that you mention /tmp/embedded-jetty-jsp hints that you are using the example code from

Is this true?

If so, can you describe how you are adding your pre-compiled JSPs to the ServletContextHandler?


Joakim Erdfelt / joakim@xxxxxxxxxxx

On Wed, Sep 13, 2017 at 1:24 PM, upendar devu <devulapalli8@xxxxxxxxx> wrote:
We recently upgraded from Jetty version 8 to 9.4.6  ; The embedded Jetty server recompiling the JSP pages and creating a folder /tmp/embedded-jetty-jsp despite the configuration attribute Development is set to false.

In my lower env   - the folder embedded-jetty-jsp is getting created and we see all the recompiled JSP pages .

in Production env -  the folder embedded-jetty-jsp is getting created and we see ONLY few of the JSP pages are getting recompiled . Due to this we are getting below error on clicking the page in the portal - the page associated to jSP is recompiled in that tmp folder.

We need your help to find the rootcause and fix for this issue. 

Error :

07 Sep 2017 16:26:28,153 [qtp1043351526-50615] ERROR biz.xxxx.xxxx.common.struts.ExceptionInterceptor (intercept:31) - JSPException including path '/pages/theme/xxxx.jsp'. org.apache.tiles.request.render.CannotRenderException: JSPException including path '/pages/theme/xxxx.jsp'. at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:399) at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:238) at org.apache.tiles.TilesContainerWrapper.render(TilesContainerWrapper.java:103) at org.apache.tiles.impl.mgmt.CachingTilesContainer.render(CachingTilesContainer.java:126) at org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:161) at org.apache.struts2.result.StrutsResultSupport.execute(StrutsResultSupport.java:208) at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277) at com.opensymphony.xwork2.interceptor.annotations.AnnotationWorkflowInterceptor.intercept(AnnotationWorkflowInterceptor.java:133) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.doIntercept(ConversionErrorInterceptor.java:139) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:133) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:88) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:174) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:171) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at biz.xxxx.xxxx.common.struts.PreBindInterceptor.intercept(PreBindInterceptor.java:19) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at biz.xxxx.xxxx.core.web.interceptor.LiteResultInterceptor.intercept(LiteResultInterceptor.java:51) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at biz.xxxx.xxxx.core.web.interceptor.FragmentInterceptor.intercept(FragmentInterceptor.java:35) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:246) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at biz.xxxx.xxxx.common.struts.NoCacheInterceptor.intercept(NoCacheInterceptor.java:39) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at biz.xxxx.xxxx.core.web.interceptor.SecurityInterceptor.intercept(SecurityInterceptor.java:70) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at biz.xxxx.xxxx.common.struts.ExceptionInterceptor.intercept(ExceptionInterceptor.java:23) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247) at org.apache.struts2.factory.StrutsActionProxy.execute(StrutsActionProxy.java:54) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564) at org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:81) at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:143) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637) at biz.xxxx.xxxx.common.filter.BaseFilter$WrappedFilterChain.doFilter(BaseFilter.java:108) at biz.xxxx.xxxx.common.filter.BaseFilter.doFilter(BaseFilter.java:64) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637) at biz.xxxx.xxxx.common.filter.BaseFilter$WrappedFilterChain.doFilter(BaseFilter.java:108) at biz.xxxx.xxxx.common.filter.ResponseUrlFilter.onDynamic(ResponseUrlFilter.java:14) at biz.xxxx.xxxx.common.filter.BaseFilter.doFilter(BaseFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637) at biz.xxxx.xxxx.common.filter.BaseFilter$WrappedFilterChain.doFilter(BaseFilter.java:108) at biz.xxxx.xxxx.common.filter.PerformanceFilter.onDynamic(PerformanceFilter.java:17) at biz.xxxx.xxxx.common.filter.BaseFilter.doFilter(BaseFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637) at biz.xxxx.xxxx.common.filter.BaseFilter$WrappedFilterChain.doFilter(BaseFilter.java:108) at biz.xxxx.xxxx.common.filter.SecurityContextFilter.onDynamic(SecurityContextFilter.java:18) at biz.xxxx.xxxx.common.filter.BaseFilter.doFilter(BaseFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.Server.handle(Server.java:564) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110) at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124) at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128) at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590) at java.lang.Thread.run(Thread.java:748) Caused by: java.io.IOException: JSPException including path '/pages/theme/xxxx.jsp'. at org.apache.tiles.request.servlet.ServletUtil.wrapServletException(ServletUtil.java:61) at org.apache.tiles.request.jsp.JspRequest.doInclude(JspRequest.java:125) at org.apache.tiles.request.AbstractViewRequest.dispatch(AbstractViewRequest.java:47) at org.apache.tiles.request.render.DispatchRenderer.render(DispatchRenderer.java:47) at org.apache.tiles.request.render.ChainedDelegateRenderer.render(ChainedDelegateRenderer.java:68) at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:259) at org.apache.tiles.TilesContainerWrapper.render(TilesContainerWrapper.java:108) at org.apache.tiles.template.InsertAttributeModel.renderAttribute(InsertAttributeModel.java:188) at org.apache.tiles.template.InsertAttributeModel.execute(InsertAttributeModel.java:132) at org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:299) at org.apache.jsp.pages.common.layout_jsp._jspx_meth_tiles_005finsertAttribute_005f10(layout_jsp.java:1645) at org.apache.jsp.pages.common.layout_jsp._jspx_meth_c_005fotherwise_005f0(layout_jsp.java:1614) at org.apache.jsp.pages.common.layout_jsp._jspx_meth_c_005fchoose_005f1(layout_jsp.java:1527) at org.apache.jsp.pages.common.layout_jsp._jspx_meth_c_005fwhen_005f0(layout_jsp.java:1010) at org.apache.jsp.pages.common.layout_jsp._jspx_meth_c_005fchoose_005f0(layout_jsp.java:915) at org.apache.jsp.pages.common.layout_jsp._jspService(layout_jsp.java:255) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:833) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:566) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:203) at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:73) at org.apache.tiles.request.servlet.ServletRequest.forward(ServletRequest.java:265) at org.apache.tiles.request.servlet.ServletRequest.doForward(ServletRequest.java:228) at org.apache.tiles.request.AbstractClientRequest.dispatch(AbstractClientRequest.java:57) at org.apache.tiles.request.render.DispatchRenderer.render(DispatchRenderer.java:47) at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:259) at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:397) ... 85 more Caused by: java.lang.NoClassDefFoundError: org/apache/jsp/tag/web/form_tag at org.apache.jsp.pages.theme.xxxx_jsp._jspx_meth_neu_005fform_005f0(xxxx_jsp.java:378) at org.apache.jsp.pages.theme.xxxx_jsp._jspService(xxxx_jsp.java:301) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:566) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.Dispatcher.include(Dispatcher.java:124) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:887) at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:679) at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:673) at org.apache.tiles.request.jsp.JspRequest.doInclude(JspRequest.java:123) ... 128 more


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev



--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
Expert assistance from the creators of Jetty and CometD


Back to the top