1

Please help me to solve the issue. I built a WAR (uising Maven) but when I tried to deploy it in Tomcat I got an Exception:

org.apache.jasper.JasperException: Unable to compile class for JSP:
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

I found the cause of the problem on stackoverflow - the issue is in inconsistency of the Servlet API in project's classpath and relevant libraries used by current version of servlet container. The provided solution is to avoid adding any Servlet API relevant libraries (servlet-api.jar, jstl.jar, jsp-api.jar, etc.) to lib - folder. I also found a solution for Eclipse ([How do I import the javax.servlet API in my Eclipse project?). But I develop in IntellijIDEA and it differs from Eclipse. In my case there is no possibility to not add servlet-api.jar and jstl-${version}.jar to classpath. If I don't add them I can't compile a project. If anyone can assist me in the issue I would thankful a lot.

Community
  • 1
  • 1
aime
  • 247
  • 4
  • 16

1 Answers1

2

When using maven, you can exclude dependencies from the war using the provided scope, like this:

<dependencies>
    <dependency>
        <groupId>some.group.id</groupId>
        <artifactId>some-artifact-id</artifactId>
        <version>x.y.z</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

You need to do that for all the dependencies provided by tomcat.


Intellij Idea also provide a similar scope mechanism, see the documentation here.

msrd0
  • 7,816
  • 9
  • 47
  • 82
  • Thank you! It worked out. But right now I have another problem - java.io.FileNotFoundException: Could not open ServletContext resource ))) I'm going to find solution for this issue – aime Jan 31 '15 at 16:26