Tomcat 7でMojarra 2.1を使用したいので、pomファイルに次の依存関係を追加しました。
<dependency>
<groupId>com.Sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>com.Sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.2</version>
</dependency>
しかし、Tomcatを起動しようとすると、次の例外が発生しました。
org.Apache.catalina.LifecycleException: Failed to start component [StandardServer[8007]]
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
at org.Apache.catalina.startup.Catalina.start(Catalina.Java:621)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:39)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:25)
at Java.lang.reflect.Method.invoke(Method.Java:597)
at org.Apache.catalina.startup.Bootstrap.start(Bootstrap.Java:322)
at org.Apache.catalina.startup.Bootstrap.main(Bootstrap.Java:450)
Caused by: org.Apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
at org.Apache.catalina.core.StandardServer.startInternal(StandardServer.Java:727)
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:148)
... 7 more
Caused by: org.Apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
at org.Apache.catalina.core.StandardService.startInternal(StandardService.Java:443)
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:148)
... 9 more
Caused by: org.Apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
at org.Apache.catalina.core.ContainerBase.startInternal(ContainerBase.Java:1033)
at org.Apache.catalina.core.StandardEngine.startInternal(StandardEngine.Java:291)
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:148)
... 11 more
Caused by: org.Apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]]
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
at org.Apache.catalina.core.ContainerBase.startInternal(ContainerBase.Java:1033)
at org.Apache.catalina.core.StandardHost.startInternal(StandardHost.Java:774)
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:148)
... 14 more
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)
at Java.lang.ClassLoader.defineClassCond(ClassLoader.Java:632)
at Java.lang.ClassLoader.defineClass(ClassLoader.Java:616)
at Java.security.SecureClassLoader.defineClass(SecureClassLoader.Java:141)
at org.Apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.Java:2820)
at org.Apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.Java:1150)
at org.Apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.Java:1645)
at org.Apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.Java:1523)
at com.Sun.faces.config.FacesInitializer.<clinit>(FacesInitializer.Java:107)
at Java.lang.Class.forName0(Native Method)
at Java.lang.Class.forName(Class.Java:247)
at org.Apache.catalina.startup.ContextConfig.getServletContainerInitializer(ContextConfig.Java:1543)
at org.Apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.Java:1466)
at org.Apache.catalina.startup.ContextConfig.webConfig(ContextConfig.Java:1285)
at org.Apache.catalina.startup.ContextConfig.configureStart(ContextConfig.Java:896)
at org.Apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.Java:322)
at org.Apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.Java:119)
at org.Apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.Java:90)
at org.Apache.catalina.core.StandardContext.startInternal(StandardContext.Java:5103)
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:148)
... 17 more
これはどのように引き起こされ、どうすれば解決できますか?
これが私のweb.xml
ファイルに問題の原因が含まれている可能性があります:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://Java.Sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://Java.Sun.com/xml/ns/javaee http://Java.Sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>appName</display-name>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:META-INF/spring/context.xml
classpath:META-INF/spring/security.xml
</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<welcome-file-list>
<welcome-file>customers</welcome-file>
</welcome-file-list>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.Sun.faces.config.ConfigureListener</listener-class>
</listener>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
</web-app>
私はあなたと同じ問題を抱えており、servlet-api
〜javax.servlet.api
は問題を修正します。この助けを願っています。 Juno Eclipse、Tomcat 7、Dynamic Web Module 3.0、およびJDK 1.7を使用していることに注意してください。
<dependency>
<groupId>com.Sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.13</version>
</dependency>
<dependency>
<groupId>com.Sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.13</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
私も同じ問題を抱えており、
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
または
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
それらをスコーププロバイダーに設定した後(またはMavenテストでサーバーを起動するときにそれらを完全に削除した後)、私にとっては機能し始めます。
@このブログを参照してください:j ava.lang.ClassFormatError:クラスファイルにネイティブまたは抽象ではないメソッドのコード属性がありません) -javax.persistence.GenerationType
の問題について説明しますが、私はあなたと私は同じ問題にぶつかった。
変化する:
<dependency>
<groupId>com.Sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.2</version>
</dependency>
に:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.1.6</version>
</dependency>
私はglassfish-embedded-allにトレードしてこれを解決しました。
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.2.2</version>
<scope>provided</scope>
</dependency>