Apache Tomcat(TomEE)/8.5.6(7.0.2)Oracle JTS / XA-Datasource配置

时间:2017-04-06 14:05:12

标签: oracle tomee xa jts tomee-7

是否有任何人正在运行示例配置:

  • Apache Tomcat(TomEE)/8.5.6(7.0.2)PLUME
  • Oracle 11g(ojdbc7.jar)

尽可能匹配EE / JPA 2.1-开发?

目前,如果我尝试使用我的数据源,我会收到TomEE的用户数据库。我认为这是由日志条目引起的" org.apache.openejb.config.AutoConfig.deploy找到匹配的数据源:jdbc / jKgvDS但这个不是JTA数据源",回到了最后一个已知的运行数据源。那么如何配置有效的JTA数据源呢?

server.xml中:



<Resource id="jKgvDS" name="jdbc/jKgvDS" 
                      jtaManaged="true"
                      auth="Container"
                      type="oracle.jdbc.xa.client.OracleXADataSource" 
                      
driverClassName="oracle.jdbc.xa.client.OracleXADataSource"
                      factory="oracle.jdbc.pool.OracleDataSourceFactory"
                      url="jdbc:oracle:thin:@db:1521:db"
                      username="myuser" 
                      password="mypass" 
                      maxActive="20"
                      maxIdle="30"
                      maxWait="-1"
                      validationQuery="SELECT 1 FROM DUAL"
            />
&#13;
&#13;
&#13;

context.xml(在conf和app-file中试用)

&#13;
&#13;
<ResourceLink global='jdbc/jKgvDS' 
name='jdbc/jKgvDS' type="javax.sql.XADatasource" 
auth="Container" />
&#13;
&#13;
&#13;

的persistence.xml

&#13;
&#13;
<persistence-unit name="jKgvPU" transaction-type="JTA">
        <jta-data-source>jdbc/jKgvDS</jta-data-source>        
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <validation-mode>NONE</validation-mode>
        <properties>
            <property
                name="openjpa.jdbc.DBDictionary"  
value="org.apache.openjpa.jdbc.sql.OracleDictionary" />
            <property
                name="openjpa.jdbc.DBDictionary"
value="oracle(maxEmbeddedBlobSize=-1,maxEmbeddedClobSize=-1)" />
            <property
                name="openjpa.jdbc.SynchronizeMappings"
                value="buildSchema(ForeignKeys=true)" />
        </properties>
    </persistence-unit>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

我们走了(是啊......):

<Resource id="jKgvDS" name="jdbc/jKgvDS" 
                  jtaManaged="true"
                  auth="Container"
                  type="javax.sql.DataSource" 
  driverClassName="oracle.jdbc.driver.OracleDriver"
 factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
                  url="jdbc:oracle:thin:@POSDBORA:1521:posdbora"
                  username="myuser" 
                  password="mypass" 
                  maxActive="20"
                  maxIdle="30"
                  maxWait="-1"
                  validationQuery="SELECT 1 FROM DUAL"
        /> 

不需要运行web.xml或context.xml中的引用。