java.lang.ClassNotFoundException: org.apache.jsp.index_jsp

后端 未结 7 1757
执念已碎
执念已碎 2020-12-03 03:17

I have an old struts 1 app that has always been built using Ant, which I\'m converting to use Maven instead. The structure of my app is modular, with dependency management i

相关标签:
7条回答
  • 2020-12-03 03:36

    It's been a while since I posted this, but I thought I would show how I figured it out (as best as I recall now).

    I did a Maven dependency tree to find dependency conflicts, and I removed all conflicts with exclusions in dependencies, e.g.:

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging-api</artifactId>
        <version>1.1</version>
        <exclusions>
            <exclusion>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    

    Also, I used the provided scope for javax.servlet dependencies so as not to introduce an additional conflict with what is provided by Tomcat when I run the app.

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

    HTH.

    0 讨论(0)
  • 2020-12-03 03:48

    This was caused because of something like this in my case:

    <jsp-config>
        <jsp-property-group>
            <url-pattern>*.jsp</url-pattern>
            <include-prelude>/headerfooter/header.jsp</include-prelude>
            <include-coda>/headerfooter/footer.jsp</include-coda>
        </jsp-property-group>
    </jsp-config>
    

    The problem was actually I did not have header.jsp in my project. However the error message was still saying index_jsp was not found.

    0 讨论(0)
  • 2020-12-03 03:51

    I also lost a half of day trying to fix this.

    It appeared that root was my project pom.xml file with dependency:

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

    Other members of the team had no problems. At the end it appeared, that I got newer tomcat which has different version of jsp-api provided (in tomcat 7.0.60 and above it will be jsp-api 2.2).

    So in this case, options would be:

    a) installing different (older/newer) tomcat like (Exactly what I did, because team is on older version)
    b) changing dependency scope to 'compile'
    c) update whole project dependencies to the actual version of Tomcat/lib provided APIs
    d) put matching version of the jsp-api.jar in {tomcat folder}/lib
    
    0 讨论(0)
  • 2020-12-03 03:55

    I have had the same problem in my project. I used an IntelliJ Idea 14 and Maven 8. And what I've noticed is that when I added a tomcat destination to to IDE it automaticly linked two jars from tomcat lib directory, they were servlet-api and jsp-api. Also I had them in my pom.xml. I killed a whole day trying to figure out why I'm getting java.lang.ClassNotFoundException: org.apache.jsp.index_jsp. And kewpiedoll99 is right. That is because there are dependency conflicts. When I added provided to those two jars in my pom.xml I found a happiness :)

    0 讨论(0)
  • 2020-12-03 03:56

    An addition to the other answers that didn't work for me: In my case the error occurred due to permission errors. The project got deployed while the tomcat was running as root, later when started as tomcat user I got the error from the question title.

    Solution in my case was to set the right permissions, e.x. on a unix system:

    cd <tomcat-dir>
    chown -R <tomcat-user> *
    
    0 讨论(0)
  • 2020-12-03 03:56

    What version of tomcat are you using ? What appears to me is that the tomcat version is not supporting the servlet & jsp versions you're using. You can change to something like below or look into your version of tomcat on what it supports and change the versions accordingly.

     <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.0.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jsp-api</artifactId>
                <version>2.0</version>
                <scope>provided</scope>
            </dependency>
    
    0 讨论(0)
提交回复
热议问题