[英]Absent Code attribute in method that is not native or abstract in class file javax/faces/webapp/FacesServlet
I am building a PoC for using JSF and am using Tomcat 7.0.59
as my server. 我正在构建一个使用JSF的PoC,并使用
Tomcat 7.0.59
作为我的服务器。 My pom.xml
looks like : 我的
pom.xml
看起来像:
<repositories>
<repository>
<id>Java.Net</id>
<url>http://download.java.net/maven/2/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
I looked up for the error and found out that it is caused due to the javaee-api
but looks like even after adding that particular dependency the issue isn't resolving. 我查找错误并发现它是由
javaee-api
引起的,但看起来甚至在添加了特定的依赖项之后问题仍无法解决。 There is a different thread but it is on different servers like glassfish, jboss and doesn't seem to be working on my case. 有一个不同的线程,但它在不同的服务器,如glassfish,jboss,似乎并没有在我的情况下工作。
EDIT : After suggestions from Samuel and Tiny, I have reached to this pom.xml : 编辑:在Samuel和Tiny的建议之后,我已经达到了这个pom.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
And maven dependency tree looks like : maven依赖树看起来像:
com.Sourabh:SourabhTest:war:0.1
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] +- javax.faces:jsf-api:jar:2.1:compile
[INFO] \- com.sun.faces:jsf-impl:jar:2.1.7:compile
Servlet-api must be flagged with <scope>provided</scope>
, as the jar in provided by tomcat. Servlet-api必须用
<scope>provided</scope>
标记,作为tomcat提供的jar。 If you don't you might encounter class loader issues. 如果不这样,您可能会遇到类加载器问题。
To ensure that you don't have several time the same dependency (through transitive dep.) you can run mvn dependency:tree
or go in the dependency hierarchy plugin in eclipse 为了确保你没有多次相同的依赖(通过传递dep。)你可以运行
mvn dependency:tree
或者进入eclipse中的依赖层次结构插件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.