PUBLIC - Liferay Portal Community Edition
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-11709

JSP pages in standalone webapp does not work in some cases within the same app server as Liferay

    Details

    • Type: Bug Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: 6.0.4 GA
    • Fix Version/s: 6.0.4 GA, 6.0.5 GA
    • Component/s: UI Infrastructure
    • Labels:
      None
    • Environment:
      Liferay 6.0.4 bundled with Glassfish
    • Similar Issues:
      Show 5 results 

      Description

      In the class JspFactoryWrapper there is the line:

      JspFactory.setDefaultFactory(_jspFactoryWrapper);

      Due to this the jspFactory is changed for all of the webapp withing the same JVM (if the JSP is in the same classloader for all of them which is normal)
      In jsp-impl 2.2.1 there is the following function when an el expression is evaluated:

      private static ExpressionFactory getExpressionFactory(
      PageContext pageContext)

      { PageContextImpl pc = (PageContextImpl) JspContextWrapper.getRootPageContext(pageContext); return pc.getJspApplicationContext().getExpressionFactory(); }

      On this there is a ClassCastException because the PageContext is not the implementation of the jsp-impl but the implementation of liferay: com.liferay.portal.kernel.servlet.PageContextWrapper

      To reproduce:

      • Download cas-server war and depoy it
      • Visit any of the servlet of cas, for example /login

      The following exception will occur:

      [#|2010-07-28T14:49:49.634+0200|WARNING|glassfishv3.0|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=42;_ThreadName=Thread-1;|org.apache.catalina.core.StandardHostValve@12d44f8d: Exception Processing ErrorPage[errorCode=500, location=/WEB-INF/view/jsp/errors.jsp]
      org.apache.jasper.JasperException: java.lang.ClassCastException: com.liferay.portal.kernel.servlet.PageContextWrapper cannot be cast to org.apache.jasper.runtime.PageContextImpl
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:483)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:373)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
      at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:802)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:664)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:499)
      at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:468)
      at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:364)
      at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:475)
      at org.apache.catalina.core.StandardHostValve.dispatchToErrorPage(StandardHostValve.java:669)
      at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:364)
      at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:329)
      at org.apache.catalina.core.StandardHostValve.postInvoke(StandardHostValve.java:241)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:334)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
      at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:229)
      at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:334)
      at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:814)
      at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:743)
      at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:936)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:682)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.ClassCastException: com.liferay.portal.kernel.servlet.PageContextWrapper cannot be cast to org.apache.jasper.runtime.PageContextImpl
      at org.apache.jasper.runtime.PageContextImpl.getExpressionFactory(PageContextImpl.java:952)
      at org.apache.jasper.runtime.PageContextImpl.evaluateExpression(PageContextImpl.java:1002)
      at org.apache.jsp.WEB_002dINF.view.jsp.errors_jsp._jspx_meth_c_when_0(errors_jsp.java from :212)
      at org.apache.jsp.WEB_002dINF.view.jsp.errors_jsp._jspx_meth_c_choose_0(errors_jsp.java from :183)
      at org.apache.jsp.WEB_002dINF.view.jsp.errors_jsp._jspService(errors_jsp.java from :91)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:406)
      ... 23 more

      I am not sure if it is a good idea to set the static property of JspFactory to the liferay implementation because it is set appserver wide. If it is set, somehow it should be found out if the request is within a Liferay portlet and if not the original jspfactory impl functions should be used without any change in the behavior (using the original jsp-impl pagecontext).

        Issue Links

          Activity

          Hide
          Anders Kr. Andersen added a comment -

          Liferay 6.0.3 also fails with Glassfish. It seems that (JSP) Expression Language cannot be used in Liferay with Glassfish. For me it makes it impossible to use Liferay on Glassfish

          Show
          Anders Kr. Andersen added a comment - Liferay 6.0.3 also fails with Glassfish. It seems that (JSP) Expression Language cannot be used in Liferay with Glassfish. For me it makes it impossible to use Liferay on Glassfish
          Hide
          Samuel Kong added a comment -

          Barrie, we're still working on trying to reproduce, but this ticket doesn't add up.

          If you take a look at JspFactorySwapper.swap(), you notice that this swap should only happen with Tomcat. So if there is an issue, it should be with how we detect Tomcat.

          Show
          Samuel Kong added a comment - Barrie, we're still working on trying to reproduce, but this ticket doesn't add up. If you take a look at JspFactorySwapper.swap(), you notice that this swap should only happen with Tomcat. So if there is an issue, it should be with how we detect Tomcat.
          Hide
          Balazs Zsoldos added a comment -

          Hi,

          to reproduce you simply need to:

          Does not matter if CAS server is configured or not as the exception will come out anyway

          Show
          Balazs Zsoldos added a comment - Hi, to reproduce you simply need to: Download Liferay 6.0.4 bundled with Glassfish Download cas-server from http://www.jasig.org/cas/download Rename cas-server-xxx.war to cas.war and deploy it by copying to domains/domain1/autodeploy after a server start visit http://localhost:8080/cas/login (cas here is the war webapp name of the cas-server) Does not matter if CAS server is configured or not as the exception will come out anyway
          Hide
          Samuel Kong added a comment -

          Bug confirmed.

          Also confirmed that the root of the problem is with ServerDetector.isTomcat(). This is returning true for GF which causes the JspFactorySwapper to execute when it should not execute for GF.

          Same problem probably also applies for other Tomcat based app servers.

          Show
          Samuel Kong added a comment - Bug confirmed. Also confirmed that the root of the problem is with ServerDetector.isTomcat(). This is returning true for GF which causes the JspFactorySwapper to execute when it should not execute for GF. Same problem probably also applies for other Tomcat based app servers.
          Hide
          Brian Chan added a comment -

          Fixed in LPS-12022

          Show
          Brian Chan added a comment - Fixed in LPS-12022

            People

            • Votes:
              8 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                4 years, 37 weeks, 2 days ago

                Development

                  Structure Helper Panel