ClassNotFoundException:javax.servlet.jsp.JspFactory

时间:2018-08-16 05:20:10

标签: java maven jetty

我有一个基于Maven的应用程序,该应用程序已完全复制并尝试运行mvn jetty:run

现在出现此错误:

Caused by: java.lang.ClassNotFoundException: javax.servlet.jsp.JspFactory
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
    ... 47 more

奇怪的是与另一台机器上工作的项目完全相同的副本。

这里是完整的依赖项: <dependency> <groupId>org.jboss.spec</groupId> <artifactId>jboss-javaee-6.0</artifactId> <version>1.0.0.Final</version> <type>pom</type> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.8</version> </dependency> <dependency> <groupId>io.fastjson</groupId> <artifactId>boon</artifactId> <version>0.30</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>com.google.http-client</groupId> <artifactId>google-http-client</artifactId> <version>1.21.0</version> </dependency> <dependency> <groupId>com.google.http-client</groupId> <artifactId>google-http-client-gson</artifactId> <version>1.21.0</version> </dependency> <dependency> <groupId>com.google.http-client</groupId> <artifactId>google-http-client-jackson2</artifactId> <version>1.21.0</version> </dependency> <dependency> <groupId>com.google.inject</groupId> <artifactId>guice</artifactId> <version>3.0</version> </dependency> <dependency> <groupId>com.google.inject.extensions</groupId> <artifactId>guice-servlet</artifactId> <version>3.0</version> </dependency> <dependency> <groupId>org.restlet.jee</groupId> <artifactId>org.restlet</artifactId> <version>${version.restlet}</version> </dependency> <!--<dependency>--> <!--<groupId>org.restlet.jee</groupId>--> <!--<artifactId>org.restlet.ext.jee</artifactId>--> <!--<version>${version.restlet}</version>--> <!--</dependency>--> <dependency> <groupId>org.restlet.jee</groupId> <artifactId>org.restlet.ext.fileupload</artifactId> <version>${version.restlet}</version> </dependency> <dependency> <groupId>org.restlet.jee</groupId> <artifactId>org.restlet.ext.servlet</artifactId> <version>${version.restlet}</version> </dependency> <dependency> <groupId>org.restlet.jee</groupId> <artifactId>org.restlet.ext.swagger</artifactId> <version>${version.restlet}</version> <exclusions> <exclusion> <groupId>org.raml</groupId> <artifactId>raml-parser</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.restlet.jee</groupId> <artifactId>org.restlet.ext.xstream</artifactId> <version>${version.restlet}</version> </dependency> <dependency> <groupId>org.restlet.jee</groupId> <artifactId>org.restlet.ext.json</artifactId> <version>${version.restlet}</version> </dependency> <dependency> <groupId>com.auth0</groupId> <artifactId>java-jwt</artifactId> <version>2.0.1</version> </dependency> <dependency> <groupId>org.mindrot</groupId> <artifactId>jbcrypt</artifactId> <version>0.3m</version> </dependency> <dependency> <groupId>com.carlosbecker</groupId> <artifactId>guice-junit-test-runner</artifactId> <version>1.1</version> <scope>test</scope> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>org.jetbrains.xodus</groupId> <artifactId>xodus-openAPI</artifactId> <version>1.2.3</version> </dependency> <dependency> <groupId>org.jetbrains.xodus</groupId> <artifactId>xodus-environment</artifactId> <version>1.2.3</version> </dependency> <dependency> <groupId>org.jetbrains.xodus</groupId> <artifactId>xodus-entity-store</artifactId> <version>1.2.3</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>${guava.version}</version> </dependency> <!-- Testing --> <dependency> <groupId>com.google.http-client</groupId> <artifactId>google-http-client-appengine</artifactId> <version>1.19.0</version> </dependency> <!-- Test Data --> <dependency> <groupId>org.fluttercode.datafactory</groupId> <artifactId>datafactory</artifactId> <version>0.8</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> </dependencies>

2 个答案:

答案 0 :(得分:1)

原因是javax.servlet.jsp.JspFactory工件中不存在类servlet-api。它存在于jsp-api工件中。我炸开了两个罐子,结果如下:

enter image description here

根据所需的版本添加jsp-api依赖项,例如:

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

答案 1 :(得分:0)

您可以在 pom.xml 中使用以下依赖

<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
    <scope>compile</scope>
</dependency>

tomcat-embed-jasper:提供对 .jsp 文件渲染的支持。