我正在尝试在Java EE兼容的Application Server之外使用JTA 1.2,例如在Apache Tomcat中,到目前为止我尝试过的是Mr. Jonathan Halliday's way和How to Configure Server Platform Using Java
但是我得到了以下异常
-javax.faces.FacesException:#{utama.satu}:javax.enterprise.context.ContextNotActiveException:ARJUNA016105:无法查找TransactionManager
-Caused by:javax.faces.el.EvaluationException:javax.enterprise.context.ContextNotActiveException:ARJUNA016105:无法查找TransactionManager
-Caused by:javax.enterprise.context.ContextNotActiveException:ARJUNA016105:无法查找TransactionManager
-Caused by:javax.naming.NameNotFoundException:名称[TransactionManager]未绑定在此Context中。无法找到[TransactionManager]。
这是我的META-INF / context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="" reloadable="true">
<Resource auth="Container" factory="org.jboss.weld.resources.ManagerObjectFactory" name="BeanManager" type="javax.enterprise.inject.spi.BeanManager"/>
<Transaction factory="com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple"/>
<ResourceLink global="jdbc/coba" name="jdbc/coba" type="javax.sql.DataSource" />
</Context>
这是我的conf / server.xml:
<GlobalNamingResources>
....
<Resource name="jdbc/coba"
auth="Container"
type="javax.sql.DataSource"
factory="org.jboss.jbossts.tomcat.TransactionalResourceFactory"
XADataSourceImpl="com.microsoft.sqlserver.jdbc.SQLServerXADataSource"
xa.setUser="sa"
xa.setPassword="123456"
xa.setURL="jdbc:sqlserver://127.0.0.1:1433;databaseName=hrd;"
/>
....
</GlobalNamingResources>
这是我的persistence.xml,它显示了我如何重新引用数据源:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="sungguhPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:comp/env/jdbc/coba</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<validation-mode>NONE</validation-mode>
<properties>
<property name="eclipselink.session.customizer" value="id.ac.ums.tomcat.JPAEclipseLinkSessionCustomizer"/>
<property name="eclipselink.logging.level" value="FINEST"/>
<property name="eclipselink.id-validation" value="NONE"/>
</properties>
</persistence-unit>
</persistence>
我还根据官方EclipseLink文档的描述构建了我的客户org.eclipse.persistence.config.SessionCustomizer,但过去24小时我仍然遇到同样的异常:-(
答案 0 :(得分:0)
没有检查您使用的详细信息,但是您提供了TransactionSynchronizationRegistry吗?这就是@TransactionScoped的实现方式
你需要根据你的impl提供java:comp / TransactionManager和/或java:comp / TransactionSynchronizationRegistry