org.apache.jasper.el.ELContextImpl cannot be cast to org.apache.jasper.runtime.ELContextImpl

前端 未结 7 1211
有刺的猬
有刺的猬 2020-12-16 01:02

I have a web service project implemented in java and it also contains jsp pages. I deploy it on jetty 8.1.5 on my machine and it works normally. But when I deploy on a windo

相关标签:
7条回答
  • 2020-12-16 01:17

    That can happen if your webapp ships with servletcontainer-specific JAR files such as jasper.jar, jetty.jar servlet.jar, etc in the /WEB-INF/lib for some unclear reason. This is in turn conflicting with with a different versioned JAR file on the target servletcontainer.

    Remove that servletcontainer-specific JAR file from your webapp's /WEB-INF/lib. It doesn't belong there. It's supposed to be already supplied by the servletcontainer itself.

    See also:

    • How do I import the javax.servlet API in my Eclipse project? (this doesn't exactly answer your concrete problem, but this is at least technically the same core problem which should give you a better understanding of this common starter's mistake)
    0 讨论(0)
  • 2020-12-16 01:17

    For me (Jetty 8.1.14), this exact error message was actually caused by another webapp in the same Jetty container. Are you running more than one webapps?

    0 讨论(0)
  • 2020-12-16 01:18

    Apart from the answers mentioned watch out for one more thing. I've another war deployed under the same Tomcat 7.0.42 instance which had a jsp-2.1-6.0.2.jar under its WEB-INF/lib. This jar has org.apache.jasper.runtime.ELContextImpl class.

    My understanding was that each webapp has its own classloader and the class files loaded by one webapp is not visible to the other webapp. Still as nothing was working I removed the other war which had that jsp.jar and restarted my tomcat and to my surprise the exception was no longer coming. Somehow this class was getting loaded and causing the issue.

    The interesting thing is that both of these wars work perfectly fine in Tomcat 6.x.

    0 讨论(0)
  • 2020-12-16 01:19

    Add this line in <context>:

    <Loader delegate="true" />
    

    This problem is related with a conflicted jars in the applications tag. This looks like:

    <?xml version='1.0' encoding='utf-8'?>
    <!-- The contents of this file will be loaded for each web application -->
    <Context>
    
      <!-- Default set of monitored resources -->
      <WatchedResource>WEB-INF/web.xml</WatchedResource>
      <Loader delegate="true" /> <!--this line-->
      <!-- Uncomment this to disable session persistence across Tomcat restarts -->
      <!--
          <Manager pathname="" />
        -->
    
      <!-- Uncomment this to enable Comet connection tacking (provides events on session expiration as well as webapp lifecycle) -->
      <!--
          <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
        -->
    
    </Context>
    
    0 讨论(0)
  • 2020-12-16 01:25

    IF you are using maven (I asked on a comment without response), you can avoid conflictive jars using a "provided" scope. When you deploy it for production, jars are not included.

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    

    I'm not sure about jetty's jars but it's probably the same.

    IF you are NOT using maven, you should move your conflictive jars (servlets and jetty) to your develompent container lib folder and remove them from your applications WEB-INF/lib folder.

    0 讨论(0)
  • 2020-12-16 01:26

    If the folder /WEB-INF/lib of your webapp does not contain a jasper.jar (see BalusC' answer), please check whether another webapp is running in your container. Then check if that webapp contains a jasper.jar in its folder /WEB-INF/lib. This happened to us. Be removing jasper.jar from those webapps (sic!), the problem could be solved. Obviously, the webapps are not that isolated for meach other as they should be. The problem appeared as we switched from Tomcat6 to Tomcat7 and jasper.jar (version 6) was bundled accidently with one of our webapps.

    0 讨论(0)
提交回复
热议问题