Проблема компиляции JSP и сервлетов в maven

#java #maven #jsp #servlets #tomcat8

#java #maven #jsp #сервлеты #tomcat8

Вопрос:

JSP и сервлеты перестали работать после того, как я перенес их из динамического веб-проекта в проект maven. Ранее в Dynamic web project все работало нормально. Возможно, проблема либо в pom.xml или web.xml . Я новичок в maven, не смог разобраться с проблемой. Это всегда выдает ошибку HTTP 500. журнал консоли

 SEVERE: Compilation error
org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException
    at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:342)
    at org.apache.jasper.compiler.JDTCompiler$1.findType(JDTCompiler.java:206)
    at org.apache.jasper.compiler.JDTCompiler$1.findType(JDTCompiler.java:163)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:96)
    at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49)
...................

Mar 16, 2019 10:36:46 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 1 in the generated java file
The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

Stacktrace:
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
..................
  

pom.xml

 <dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20160810</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>2.3.1</version>
        <scope>provided</scope>
    </dependency>

</dependencies>
<build>
    <finalName>PDFReader</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <path>/minor</path>
                <port>8080</port>
            </configuration>
        </plugin>

    </plugins>

</build>
  

web.xml

 <display-name>RakshitaWelfare</display-name>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>


<servlet>
    <servlet-name>projectServlet</servlet-name>
    <servlet-class>org.rakshitawelfare.Servlets.HomeServletDisp</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>projectServlet</servlet-name>
    <url-pattern>/HomeServletDisp/*</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>home</servlet-name>
    <jsp-file>/Home.jsp</jsp-file>
</servlet>

<servlet-mapping>
    <servlet-name>home</servlet-name>
    <url-pattern>/home/*</url-pattern>
</servlet-mapping>
  

Заранее спасибо.

Комментарии:

1. Можем ли мы увидеть раздел импорта для Home.jsp (или какой-либо другой JSP, который не компилируется)?

2.index.html <body onload="document.helloworld.submit()"> <form method="post" action="HomeServletDisp" id="helloworld" name="helloworld"></form> </body> HomeServletDisp.java ArrayList<Event> eventList = eventDao.findAll(); request.setAttribute("eventList", eventList); getServletContext().getRequestDispatcher("/Home.jsp?").forward(request, response);