5

We are facing the below exception when I click on View button to see the user details :

2017-06-30 19:23:52,831 ERROR [com.myapp.jsp] - <Unable to compile class for JSP: 

An error occurred at line: 53 in the jsp file: /WEB-INF/jsps/ViewUserDetails.jsp
apache cannot be resolved or is not a field
50:                     </myapphtml:myappRow>
51:                                         
52:                     <myapphtml:myappRow align="left" label="userdetails.field.label.orgs">
53:                         <logic:iterate name="userDetails" property="Orgs" id="org">         
54:                             &nbsp;<bean:write name="org" property="name" /><br>
55:                         </logic:iterate>
56:                     </myapphtml:myappRow>


Stacktrace:>
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 53 in the jsp file: /WEB-INF/jsps/ViewUserDetails.jsp
apache cannot be resolved or is not a field
50:                     </myapphtml:myappRow>
51:                                         
52:                     <myapphtml:myappRow align="left" label="userdetails.field.label.orgs">
53:                         <logic:iterate name="userDetails" property="mappedOrgs" id="org">           
54:                             &nbsp;<bean:write name="org" property="name" /><br>
55:                         </logic:iterate>
56:                     </myapphtml:myappRow>


Stacktrace:
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:490)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:379)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
    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.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:743)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:410)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
    at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
    at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
    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.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at at com.myapp.tools.auth.client.AuthFilter.doFilter(AuthFilter.java:512)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.myapp.tools.auth.client.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:90)
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:218)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

This happens only in the combination of RHEL 7.x and Tomcat combination. I am not able to reproduce this issue in combination other then this.

Attaching the ViewUserDetails.jsp

<%@ page import="org.apache.struts.Globals" %>
<%@ page import="com.myapp.tools.api.impl.User" %>

<%@ include file="include/commonDef.jspf" %>

<tiles:insert definition="myapp.csd.office.layout.default">

    <tiles:put name="header" type="String">
        <myapphtml:myappPageHeaderTab headerImage="images/default/icn_user.gif" headerText="form.page.title.user_details"/>
    </tiles:put>

    <tiles:put name="content" type="String">
        <myapphtml:myappBlock>
            <myapphtml:myappMessage
                    genErrorKey="<%= myappGlobals.GENERAL_ERROR %>"
                    valErrorKey="<%= Globals.ERROR_KEY %>"
                    genErrorHeading="MC.General.genError"
                    valErrorHeading="MC.General.genError"
                    headingBundle="myappBASETAG"/>
        </myapphtml:myappBlock>

        <strutshtml:form action="/processUserList.do" method="POST">
            <input type="hidden" name="action" value="" />



                    <myapphtml:myappRow align="left" label="userdetails.field.label.orgs">
                        <logic:iterate name="userDetails" property="Orgs" id="org">         
                            &nbsp;<bean:write name="org" property="name" /><br>
                        </logic:iterate>
                    </myapphtml:myappRow>



            <myapphtml:myappButtonRow formname="UserDetailsForm">
                <myapphtml:myappButton action="cancel" name="form.button.label.cancel" buttonStyle="button_gt" />           
            </myapphtml:myappButtonRow>         
        </strutshtml:form>

    </tiles:put>

</tiles:insert>
Deepak Jain
  • 305
  • 1
  • 3
  • 19

1 Answers1

4

Try to see if you have a String called org change it to other name as org1.

See answer.

String org = ""; something like this in jsp somewhere on the top of that package statement. Change that variable name to org1 or some other meaningful one and your problem will be solved.

There's a known issue in Tomcat which its Compiler is interpreting this as a reference to the field apache of object org

The code works in TC4 because the generated code is much simpler - it ignores a number of possible error conditions. The fix for these issues in TC5 and TC6 includes a fully qualified reference to org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode()

The complier is interpreting this as a reference to the field apache of object org.

When you have generated code, there is always going to be the possibility of a naming clash. I can't see an easy way around this.

I am going to mark this as WONTFIX. More generally, avoiding the use of widely used package prefixes (org, com, etc) as variable names will reduce your risk of hitting this issue.

As an aside, a quick Google suggests you might also want to avoid 2 letter variable names that clash with top level domains.

Notice that RHEL uses a specific tomcat version which not as community version.

Any community releases of Tomcat are not supported

The supported releases of Tomcat are included in our products:

Tomcat rpm package included in RHEL 7.1, which is based on Tomcat 7.0.54.

Please note that we backport critical bug and security fixes on the above versions when issues are raised or CVEs are reported. Therefore, the versions we provide are not exactly the same as community versions of Tomcat.

Community
  • 1
  • 1
Ori Marko
  • 56,308
  • 23
  • 131
  • 233
  • Am i supposed to change the value in the jsp or the java code in backend? if in jsp, I tried that and didn't work. It gave me the same exception with org1. – Deepak Jain Jul 10 '17 at 08:08
  • It resolved the issue but can you tell me why this worked? is the "org" keyword is reserved in the rhel or java or anywhere? – Deepak Jain Jul 11 '17 at 09:23
  • 1
    add details of a known issue – Ori Marko Jul 11 '17 at 10:11
  • @ user7294900 This issue doesn't occur in the platforms other then RHEL+tomcat. So is this specific to this platform or this is specific to tomcat? – Deepak Jain Jul 12 '17 at 06:17
  • @ user7294900 is this the java which comes specific for RHEL env, causing the issue with the tomcat? – Deepak Jain Jul 12 '17 at 06:18
  • what are the other combinations you tried ? can you specify? – Ori Marko Jul 12 '17 at 06:21
  • I added more info about RHEL and tomcat version – Ori Marko Jul 12 '17 at 06:28
  • I tried RHEL+weblogic, RHEL+Websphere, Windows+weblogic, Windows+Websphere, Windows+Tomcat. But only combination which I saw error is in RHEL+Tomcat. – Deepak Jain Jul 12 '17 at 06:47
  • Yes because there's a problem with some versions of tomcat, and RHEL use specific version of tomcat which isn't community version. – Ori Marko Jul 12 '17 at 06:50
  • yes I used tomcat 8.0.43 which is not a community version but I think in tomcat 7 and 8 any version would be having the issue. – Deepak Jain Jul 12 '17 at 06:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/149087/discussion-between-deepak-jain-and-user7294900). – Deepak Jain Jul 13 '17 at 08:40