开发者

OpenEJB cannot use javax.persistence.jtaDataSource

The following configuration is ok for WebLogic, but in OpenEJB it raises a error "javax.naming.NameNotFoundException: Name "AppDB" not found."

And if I removed the property javax.persistence.jtaDataSource, it works. And why set 2 duplicated datasource? Because it's a bug of Eclipselinks (see http://bugs.eclipse.org/246126)

<persistence-unit name="app1" transaction-type="JTA">
  <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
  <jta-data-source>AppDB</jta-data-source>

  <properties>
    <property name="javax.persistence.jtaDataSource" value="AppDB" />
  </properties>       
</persistence-unit>

The following is jndi.properties

java.naming.factory.initial=org.apache.openejb.client.LocalInitialContextFactory
openejb.validation.output.level=VERBOSE
openejb.nobanner=false
jdbc/AppDB = new://Resource?type=DataSource
jdbc/AppDB.provider = org.eclipse.persistence.jpa.PersistenceProvider 
jdbc/AppDB.JdbcDriver = oracle.jdbc.OracleDriver
jdbc/AppDB.JdbcUrl = jdbc:oracle:thin:@xx.xx.xx.xx:xxxx:xxxx
jdbc/AppDB.JtaManage开发者_运维技巧d = false
jdbc/AppDB.UserName = xxxx
jdbc/AppDB.Password = xxxx

Because this is a jar packaged by other team, I cannot change the content but I still want to use it in my OpenEJB, any suggestion? thanks.


Not at all sure how EclipseLink processes the javax.persistence.jtaDataSource property. I have to assume it's a JNDI lookup of some kind, but there's incredible significance in how they might do that. If they prepend java:comp/env/ for example, that significantly changes the semantics.

Maybe try overriding javax.persistence.jtaDataSource to use the OpenEJB global JNDI name for your datasource. So in your jndi.properties file, add

app1.javax.persistence.jtaDataSource = openejb:Resource/jdbc/AppDB

Definitely let me know if that works. Seems that might a good feature to add to OpenEJB even though the property is actually used by the JPA provider. Fixing invalid JNDI names could be more than convenient.

On a side note, there should be a logging statement saying 'jdbc/AppDB.provider' is not a property supported by the datasource. Probably best to delete that property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜