我有JSF war文件并将其部署到Tomcat8上。但是,当我启动它时,有以下异常:
23-Sep-2015 08:55:39.664 INFO [http-nio-4747-exec-15] org.apache.catalina.core.ApplicationContext.log HTMLManager: start: Starting web application '/jsfexample'
23-Sep-2015 08:55:39.709 SEVERE [http-nio-4747-exec-15] org.apache.catalina.core.ApplicationContext.log FAIL - Application at context path /jsfexample could not be started
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/jsfexample]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1293)
......................
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/webapp/FacesServlet
at java.lang.ClassLoader.defineClass1(Native Method)
... 32 more
23-Sep-2015 08:55:39.711 INFO [http-nio-4747-exec-15] org.apache.catalina.core.ApplicationContext.log HTMLManager: list: Listing contexts for virtual host 'localhost'
我在Tomcat 7中遇到了同样的问题,我通过添加完整的JSF maven依赖项来解决它(我缺少jsf-impl
):
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.12</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-api</artifactId>
<version>2.2</version>
</dependency>