JtyProcessEngineConfigurationで動作するActivitiとCdiStandaloneProcessEngineConfigurationで動作するActivitiを正常に取得できました。エラーがCdiJtaProcessEngineConfigurationがロードされる前にトランザクションマネージャーを要求します。
javax.naming.NameNotFoundExceptionがされた状態で
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans <a href="http://www.springframework.org/schema/beans/spring-beans.xsd"> " rel="nofollow">http://www.springframework.org/schema/beans/spring-beans.xsd"> </a> <bean id="transactionManager" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/TransactionManager"></property> <property name="resourceRef" value="true" /> </bean> <bean id="processEngineConfiguration" class="org.activiti.cdi.CdiJtaProcessEngineConfiguration"> <property name="transactionManager" ref="transactionManager" /> <property name="transactionsExternallyManaged" value="true" /> <property name="dataSourceJndiName" value="openejb:Resource/jdbc/AppDS" /> <property name="databaseSchemaUpdate" value="false"/> <property name="jobExecutorActivate" value="false"/> <property name="asyncExecutorEnabled" value="true"/> <property name="asyncExecutorActivate" value="true"/> <property name="history" value="audit"/> </bean> </beans>
次のように
しかし、私はCdiJtaProcessEngineConfigurationの作業を取得することはできないのですが、私の設定の例は次のとおりです。名前を[トランザクションマネージャー]このコンテキストでは にバインドされていません。 [TransactionManager]が見つかりません。
と
2016-11-29 13:47:37 ERROR ProcessEngines:174 - Exception while initializing process engine: Error creating bean with name 'processEngineConfiguration' defined in resource loaded through InputStream: Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager';
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in resource loaded through InputStream: Invocation of init method failed;
nested exception is javax.naming.NameNotFoundException: Name [TransactionManager] is not bound in this Context. Unable to find [TransactionManager].
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngineConfiguration' defined in resource loaded through InputStream: Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager';
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in resource loaded through InputStream: Invocation of init method failed;
nested exception is javax.naming.NameNotFoundException: Name [TransactionManager] is not bound in this Context. Unable to find [TransactionManager].
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary
私は私が使用しているアプリケーションサーバーがTomeeプラス1.7.3
乾杯が何であるかを試すために次の
わかりませんが、以下のようにスタックトレースがあります Adam
[編集1] JtaProcessEngineConfigurationマニュアルを読み込む必要があります。アプリケーションは準備完了ですが、CdiStandaloneProcessEngineConfigurationとCdiJtaProcessEngineConfigurationはActivitiExtensionクラスを介して自動的に読み込まれます。
[編集2] (@Romain MANNI-Bucau提案どおりに)次のように
try {
InitialContext initialContext = new InitialContext();
try {
transactionManager = (TransactionManager) initialContext.lookup("openejb:Resource/TransactionManager");
} finally {
initialContext.close();
}
} catch (NamingException e) {
LOGGER.error(e.getMessage(), e);
}
I取得するには、次の例外トレース
(CDIなし)拡張JtaProcessEngineConfiguration内のトランザクションマネージャを検索2016-12-06 09:16:35 ERROR TestJtaProcessEngineConfiguration:29 - Name "Resource/TransactionManager" not found.
javax.naming.NameNotFoundException: Name "Resource/TransactionManager" not found.
at org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:199)
at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:151)
at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:119)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
<snip>
[編集3] "java.naming.factory.initial = org.apache.openejb.core.OpenEJBI nitialContextFactory"を使用しようとすると、次のスタックトレースが発生します。
Cannot instantiate class: org.apache.openejb.core.OpenEJBInitialContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.openejb.core.OpenEJBInitialContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.init(InitialContext.java:244)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
しかし、JNDIの文字列を使用して "のOpenEJB:トランザクションマネージャーは" 次のように
SUCCESS 作業の設定がjndiNameのプロパティを使用しています動作します。
<property name="jndiName" value="openejb:TransactionManager"></property>
プロパティの値を "java:comp/env/TransactionManager"に変更してください。多分これが助けになるでしょう。しかし、一般的な問題は、jndi-name "TransactionManager"がネームスペース "java:comp"にバインドされていないということです。 –
@ MaximKreschishin返信ありがとう、私は理解しています。 JtaProcessEngineConfigurationはTransactionManagerをルックアップできますが、後でApplication Deploy Cycleでalotと呼ばれます。 私はCdiJtaProcessEngineConfigurationを取得して、アプリケーションデプロイサイクルの後半でトランザクションマネージャをロードするようにしていますが、Production Safeコードからは遠いです。 – Adz