Tomcat 8 (8.0.30)、OpenWebBeans 1.6.2、JSF Mojarra 2.2.12、および OmniFaces 1.8 を使用しています。OmniFaces を新しいバージョンにアップグレードすることにしました。2.0 以降では CDI が必要なようですが、Tomcat を (OmniFaces 2.2 で) 起動すると、以下のエラーが発生します。OmniFaces の互換性マトリックスによると、Tomcat+Mojarra+OWB は 8.0.30+2.2.12+1.6.2 で動作するはずです。
2.0 でも試しましたが、同じエラーが発生しました。2.1 で別の問題が発生しましたが、動作は 2.0 と同じであるため、2.2 で修正されたものだと思いました。2.3-RC1 でも同じ問題が発生します。
CDI を実行していることを OmniFaces に認識させるために必要な特定の操作はありますか? OmniFaces のバグでしょうか?
この問題を再現するために非常に小さなサンプル アプリを作成したので、メイン アプリケーションに他に干渉するものはないと確信しています。
mar 22, 2016 10:57:46 FM org.apache.webbeans.lifecycle.AbstractLifeCycle bootstrapApplication
INFO: OpenWebBeans Container has started, it took [447] ms.
mar 22, 2016 10:57:46 FM org.omnifaces.ApplicationListener checkCDIAvailable
SEVERE:
????????????????????????????????????????????????????????????????????????????????
? ?? ? ?
? ? ????? ? OmniFaces failed to initialize! ?
? ???? ?????? ? ?
? ?????? ??????? ? This OmniFaces version requires CDI, but ?
? ??????? ??????? ? none was found on this environment. ?
? ??????????????????????? ? ?
? ??????????????????????? ? OmniFaces 2.x requires a minimum of JSF 2.2.?
? ????????????????????? ? Since this JSF version, the JSF managed bean?
? ????????????????????? ? facility @ManagedBean is semi-official ?
? ?????????????????????? ? deprecated in favour of CDI. JSF 2.2 users ?
? ?????????????????????? ? are strongly encouraged to move to CDI. ?
? ?????????????????????? ? ?
? ??????????????????????? ? OmniFaces goes a step further by making CDI ?
? ???????????????????????? ? a REQUIRED dependency next to JSF 2.2. This ?
? ???????????????????????? ? not only ensures that your web application ?
? ???????????????? ???????? ? represents the state of art, but this also ?
? ????????????????????????? ? makes for us easier to develop OmniFaces, ?
? ?????????????????????????? ? without the need for all sorts of hacks in ?
? ?????????????????????????? ? in order to get OmniFaces to deploy on ?
? ???????????????????????????? ? environments without CDI. ?
? ???????????????????????????? ? ?
? ???????????????????????????? ? You have 3 options: ?
?????????????????????????????????? 1. Downgrade to OmniFaces 1.x. ?
?????????????????????????????????? 2. Install CDI in this environment. ?
?????????????????????????????????? 3. Switch to a CDI capable environment. ?
?????????????????????????????????? ?
?????????????????????????????????? For additional instructions, check ?
?????????????????????????????????? http://omnifaces.org/cdi ?
?????????????????????????????????? ?
????????????????????????????????????????????????????????????????????????????????
mar 22, 2016 10:57:46 FM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.omnifaces.ApplicationListener
java.lang.ExceptionInInitializerError
at org.omnifaces.ApplicationListener.checkCDIAvailable(ApplicationListener.java:74)
at org.omnifaces.ApplicationListener.contextInitialized(ApplicationListener.java:58)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: CDI BeanManager instance is not available in JNDI.
at org.omnifaces.config.BeanManager.<init>(BeanManager.java:99)
at org.omnifaces.config.BeanManager.<clinit>(BeanManager.java:49)
... 11 more
Caused by: java.lang.IllegalStateException: javax.naming.NamingException: Cannot create resource instance
at org.omnifaces.util.JNDI.lookup(JNDI.java:95)
at org.omnifaces.config.BeanManager.<init>(BeanManager.java:95)
... 12 more
Caused by: javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:117)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.omnifaces.util.JNDI.lookup(JNDI.java:90)
... 13 more
私が使用しているpom.xmlは次のとおりです。
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>se.app.testapp</groupId>
<artifactId>sampleapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-jsf</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-el22</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-web</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.12</version>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<type>jar</type>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<type>jar</type>
</dependency>
</dependencies>
</project>