Tomcat 7 fails to compile JSP Pages

Deadly 提交于 2019-12-31 04:11:18

问题


I have an application that works perfectly fine on Tomcat 6. I have now moved this application to Tomcat 7 and the JSPs are throwing below compilation exception

Mar 21, 2014 12:05:56 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/core-tool-5.0] threw     exception [Unable to compile class for JSP: 

An error occurred at line: 22 in the generated java file
The type welcome_jsp must implement the inherited abstract method JspSourceDependent.getDependants()

An error occurred at line: 28 in the generated java file
The type Map is not generic; it cannot be parameterized with arguments <String, Long>

An error occurred at line: 31 in the generated java file
_jspx_dependants cannot be resolved to a variable

An error occurred at line: 31 in the generated java file
The type HashMap is not generic; it cannot be parameterized with arguments <String, Long>

An error occurred at line: 32 in the generated java file
_jspx_dependants cannot be resolved

An error occurred at line: 32 in the generated java file
The method valueOf(String) in the type Long is not applicable for the arguments (long)

An error occurred at line: 40 in the generated java file
The type Map is not generic; it cannot be parameterized with arguments <String, Long>

An error occurred at line: 41 in the generated java file
_jspx_dependants cannot be resolved to a variable

Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:469)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.jasig.cas.client.util.AssertionThreadLocalFilter.doFilter(AssertionThreadLocalFilter.java:54)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.jasig.cas.client.util.HttpServletRequestWrapperFilter.doFilter(HttpServletRequestWrapperFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.accenture.toolkit.filters.ToolkitAuthenticationFilter.doFilter(ToolkitAuthenticationFilter.java:91)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:201)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at     org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:5    85)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    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:722)

I have taken a look at the java files created by jasper for both tomcat versions and there is one major change that I found. For example, Corresponding to error in line no. 22, the getDependants() method in the java file for tomcat 6 has the following signature:

  public Object getDependants() {
    return _jspx_dependants;
  }

Whereas in case of Tomcat 7, this is

  public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
    return _jspx_dependants;
  }

I had raised this issue couple of months ago too. Did not find a resolution so i switched to tomcat but now we need to do a production release for this code on tomcat 7 hence need a concrete solution to this.

It would be great if some one could please help me identify what do i need to correct to have this issue resolved

Below is the list of all jars in WEB-INF/lib folder of my application:

activation-1.1.jar
ant-1.6.jar
ant-1.7.0.jar
ant-launcher-1.7.0.jar
aopalliance-1.0.jar
asm-3.2.jar
asm-4.1.jar
asm-analysis-4.1.jar
asm-tree-4.1.jar
asm-util-4.1.jar
aspectjweaver-1.7.2.jar
avalon-framework-api-4.2.0.jar
avalon-framework-api-4.2.0.jar
avalon-framework-api-4.3.1.jar
avalon-framework-impl-4.3.1.jar
batik-all-1.7.jar
batik-anim-1.7.jar
batik-awt-util-1.7.jar
batik-bridge-1.7.jar
batik-css-1.7.jar
batik-dom-1.7.jar
batik-ext-1.7.jar
batik-extension-1.7.jar
batik-gvt-1.7.jar
batik-js-1.7.jar
batik-parser-1.7.jar
batik-script-1.7.jar
batik-svg-dom-1.7.jar
batik-svggen-1.7.jar
batik-transcoder-1.7.jar
batik-util-1.7.jar
batik-xml-1.7.jar
cas-client-core-3.2.1.jar
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-collections-3.2.jar
commons-compress-1.4.1.jar
commons-digester-1.8.jar
commons-discovery-0.4_1.jar
commons-el-1.0.jar
commons-exec-1.1.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-lang-2.4.jar
commons-logging-1.1.1.jar
commons-validator-1.3.1.jar
dom4j-1.6.1.jar
fop-1.0.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
jackson-core-asl-1.9.13.jar
jackson-jaxrs-1.9.13.jar
jackson-mapper-asl-1.9.13.jar
jackson-xc-1.9.13.jar
jadretro-1.6.1.jar
javassist-3.14.0-GA.jar
jaxb-api-2.1.jar
jaxb-impl-2.1.jar
jaxen-1.1.1.jar
jbpmmigration-0.11.jar
jdec-20.jar
jdom-1.0.jar
junit-4.4.jar
log4j-1.2.14.jar
maven-model-3.0.4.jar
mimepull-1.6.jar
mysql-connector-java-5.1.22.jar
org.eclipse.core.contenttype-3.4.100.v20100505-1235.jar
org.eclipse.core.expressions-3.4.200.v20100505.jar
org.eclipse.core.filesystem-1.3.0.v20100526-0737.jar
org.eclipse.core.jobs-3.5.0.v20100515.jar
org.eclipse.core.resources-3.6.0.v20100526-0737.jar
org.eclipse.core.runtime-3.6.0.v20100505.jar
org.eclipse.equinox.app-1.3.0.v20100512.jar
org.eclipse.equinox.common-3.6.0.v20100503.jar
org.eclipse.equinox.preferences-3.3.0.v20100503.jar
org.eclipse.equinox.registry-3.5.0.v20100503.jar
org.eclipse.jdt.core-3.5.1.v_972_R35x.jar
org.eclipse.osgi.services-3.2.100.v20100503.jar
org.eclipse.osgi-3.6.0.v20100517.jar
org.osgi.foundation-1.2.0.jar
org-apache-batik-all-1.7-201002241055.jar
parboiled-core-1.1.4.jar
parboiled-java-1.1.4.jar
pegdown-1.2.2-DAVIS.jar
plexus-utils-2.0.6.jar
pmd-4.3.jar
poi-3.7.jar
poi-ooxml-3.7.jar
poi-ooxml-schemas-3.7.jar
redline-1.1.12.jar
serializer-2.7.0.jar
serializer-2.7.1.jar
spring-aop-3.2.4.RELEASE.jar
spring-aspects-3.2.4.RELEASE.jar
spring-beans-3.2.4.RELEASE.jar
spring-context-3.2.4.RELEASE.jar
spring-context-support-3.2.4.RELEASE.jar
spring-core-3.2.4.RELEASE.jar
spring-expression-3.2.4.RELEASE.jar
spring-instrument-3.2.4.RELEASE.jar
spring-jdbc-3.2.4.RELEASE.jar
spring-tx-3.2.4.RELEASE.jar
spring-web-3.2.4.RELEASE.jar
spring-webmvc-3.2.4.RELEASE.jar
stax-api-1.0.1.jar
stax-api-1.0-2.jar
windup-engine-0.7.0.jar
windup-metadata-0.7.0.jar
xalan-2.7.0.jar
xercesImpl-2.7.1.jar
xml-apis-1.3.04.jar
xml-apis-ext-1.3.04.jar
xmlbeans-2.3.0.jar
xmlgraphics-commons-1.4.jar
xmlParserAPIs-2.6.2.jar
xmlunit-1.4.jar
xom-1.0.jar
xz-1.0.jar

Also, below is the dependency list from my applications pom.xml

<dependencies>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
            <version>3.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>avalon-framework</groupId>
            <artifactId>avalon-framework-api</artifactId>
            <version>4.2.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.kenai.nbpwr</groupId>
            <artifactId>org-apache-batik-all</artifactId>
            <version>1.7-201002241055</version>
        </dependency>
        <dependency>
            <groupId>org.jasig.cas.client</groupId>
            <artifactId>cas-client-core</artifactId>
            <version>3.2.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.7.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.3</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
            <version>1.8</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.bundles</groupId>
            <artifactId>commons-discovery</artifactId>
            <version>0.4_1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-el</groupId>
            <artifactId>commons-el</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.2.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.3.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlgraphics</groupId>
            <artifactId>fop</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-stax-api_1.0_spec</artifactId>
            <version>1.0.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-asl</artifactId>
            <version>1.9.13</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-jaxrs</artifactId>
            <version>1.9.13</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.13</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-xc</artifactId>
            <version>1.9.13</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>jaxen</groupId>
            <artifactId>jaxen</artifactId>
            <version>1.1.1</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <artifactId>icu4j</artifactId>
                    <groupId>com.ibm.icu</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>jdec</groupId>
            <artifactId>jdec</artifactId>
            <version>20</version>
            <scope>system</scope>
            <systemPath>C:\Users\kinjal.doshi\Documents\spring-toolkit\migrationtoolkit/src/main/webapp/WEB-INF/lib/jdec-20.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-model</artifactId>
            <version>3.0.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jvnet</groupId>
            <artifactId>mimepull</artifactId>
            <version>1.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.22</version>
        </dependency>
        <dependency>
            <groupId>pmd</groupId>
            <artifactId>pmd</artifactId>
            <version>4.3</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>asm</groupId>
                    <artifactId>asm</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.7</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.7</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>3.7</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>xalan</groupId>
            <artifactId>serializer</artifactId>
            <version>2.7.1</version>
        </dependency>          
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>system</scope>
            <systemPath>C:\Users\kinjal.doshi\Apache Software Foundation\apache-tomcat-7.0.32\lib\servlet-api.jar</systemPath> 
        </dependency>
        <dependency>
            <groupId>xalan</groupId>
            <artifactId>xalan</artifactId>
            <version>2.7.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.7.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <version>1.3.04</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis-ext</artifactId>
            <version>1.3.04</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.3.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlgraphics</groupId>
            <artifactId>xmlgraphics-commons</artifactId>
            <version>1.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>jsp-api</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.2</version>
            <scope>system</scope>
            <systemPath>C:\Users\kinjal.doshi\Apache Software Foundation\apache-tomcat-7.0.32\lib\jsp-api.jar</systemPath> 
        </dependency>
        <dependency>
            <groupId>net.sf.jadretro</groupId>
            <artifactId>jadretro</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-exec</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.windup</groupId>
            <artifactId>windup-engine</artifactId>
            <version>0.7.0</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-instrument</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>       
    </dependencies>

回答1:


Finally found the conflicting jar. It is org.osgi.foundation-1.2.0.jar. However this jar is required by another dependency that I am using so need to find a way to resolve this issue.




回答2:


This error is typically caused by compiling JSPs on Tomcat 6 and then trying to run them on Tomcat 7.

If you are pre-compiling your JSPs, make sure that all the Tomcat libraries you are using for pre-compilation are from exactly the same version of Tomcat as the JSPs will be running on.

If you are compiling JSPs on the fly, make sure you empty the work directory when switching from Tomcat 6 to Tomcat 7.

Also make sure that your Tomact 7 installation does not contain any stray libraries from a Tomcat 6 installation and that you don't include any Tomcat JARs with your web application.




回答3:


Adding this line to context.xml should resolve this issue.

<Loader delegate="true">


来源:https://stackoverflow.com/questions/22552244/tomcat-7-fails-to-compile-jsp-pages

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!