java.lang.AbstractMethodError:javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax / servlet / ServletContext;)Ljavax / servlet / jsp / JspApplicationContext;
您好, 我正在开发vaadin中的Web服务器。我的应用程序工作正常,但现在当我启动它时,我有以下错误
java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
at org.apache.jasper.compiler.Validator$ValidateVisitor.<init>(Validator.java:515) ~[jasper.jar:7.0.55]
at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1845) ~[jasper.jar:7.0.55]
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217) ~[jasper.jar:7.0.55]
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373) ~[jasper.jar:7.0.55]
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) ~[jasper.jar:7.0.55]
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) ~[jasper.jar:7.0.55]
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657) ~[jasper.jar:7.0.55]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) ~[jasper.jar:7.0.55]
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) ~[jasper.jar:7.0.55]
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) ~[jasper.jar:7.0.55]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) ~[servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) ~[catalina.jar:7.0.55]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) ~[catalina.jar:7.0.55]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) ~[catalina.jar:7.0.55]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) [catalina.jar:7.0.55]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) [catalina.jar:7.0.55]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.55]
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:312) [catalina.jar:7.0.55]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.55]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) [catalina.jar:7.0.55]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) [tomcat-coyote.jar:7.0.55]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) [tomcat-coyote.jar:7.0.55]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736) [tomcat-coyote.jar:7.0.55]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695) [tomcat-coyote.jar:7.0.55]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_25]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.55]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
对于依赖关系我正在使用maven而我的pom是
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ContestiOpenDataJungle</groupId>
<artifactId>ContestiOpenDataJungle</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
</parent>
<properties>
<vaadin.version>7.4.4</vaadin.version>
<java.version>1.7</java.version>
<tomcat.version>7.0.59</tomcat.version>
</properties>
<repositories>
<repository>
<id>eXo-pub-repo</id>
<name>eXoPlatform public repo</name>
<url>http://repository.exoplatform.org/public</url>
</repository>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
<dependencies>
<!-- The core server part of Vaadin -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-server</artifactId>
<version>${vaadin.version}</version>
</dependency>
<!-- Vaadin themes -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
<version>${vaadin.version}</version>
</dependency>
<!-- Push support -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-push</artifactId>
<version>${vaadin.version}</version>
</dependency>
<!-- Precompiled DefaultWidgetSet -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
<version>${vaadin.version}</version>
</dependency>
<!-- Compiler for custom widget sets. Should not be deployed -->
<!-- <dependency> -->
<!-- <groupId>com.vaadin</groupId> -->
<!-- <artifactId>vaadin-client-compiler</artifactId> -->
<!-- <version>${vaadin.version}</version> -->
<!-- </dependency> -->
<!-- Vaadin client side, needed for widget set compilation -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
<version>${vaadin.version}</version>
<exclusions>
<exclusion>
<artifactId>validation-api</artifactId>
<groupId>javax.validation</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- Compiler for custom widget sets. Should not be deployed -->
<dependency>
<groupId>org.exoplatform.core</groupId>
<artifactId>exo.core.component.security.core</artifactId>
<version>2.5.12-GA</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/WebContent/WEB-INF/lib/TagCloud.jar</systemPath>
</dependency>
<dependency>
<groupId>eu.exeura</groupId>
<artifactId>DBSQLContesti2</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot</artifactId>
<version>1.0.0.beta2</version>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ru.xpoft.vaadin</groupId>
<artifactId>spring-vaadin-integration</artifactId>
<version>3.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring</artifactId>
<version>1.0.0.beta1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-server</artifactId>
</exclusion>
<exclusion>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-shared</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>ContestiOpenDataJungle</warName>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
服务器是Tomcat 7.0.59版。 java版本是1.7。 我发现错误可能是以下罐子:
servlet.jar
servlet-api.jar
j2ee.jar
因为他们有文件javax.servlet,但我没有它们。 https://community.oracle.com/thread/1397338?start=0
感谢您的帮助
答案 0 :(得分:1)
您缺少项目的以下依赖性:
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>7.0.59</version>
</dependency>
答案 1 :(得分:0)
在包含org.apache.jasper.compiler.Validator的库期望它作为javax.servlet.jsp.JspFactory实现的类定义之间可能存在版本控制问题。
为类提供3个具有相同二进制名称的jar并不是一个好习惯。除非你知道类加载器会选择哪个类,否则你将对行为的内容不知所措。 减少罐子的数量,只包括你需要的罐子。
如果那时仍然存在此冲突,请检查包含org.apache.jasper.compiler.Validator的库的依赖关系树,并确保您提供的javax.servlet.jsp.JspFactory实现实现了您在依赖树。
会发生什么事情:
-- my-framework-1.0.0 --
interface A {
method b ();
}
class AFactory {
A getDefault () { ... }
-- my-framework-2.0.0 --
interface A {
method b(String s);
}
class AFactory {
A getDefault () { ... }
-- my-implementation --
class B {
public void act () {
AFactory.getDefault().b();
}
}
只要使用my-framework-1.0.0进行部署,这将正常工作。使用my-frameworke-2.0.0进行部署将使其中断。
如果您的类加载器选择my-framework-1.0.0进行编译,但您的打包程序选择my-frameworke-2.0.0,则可能无法在IDE中看到此问题。