OpenEJB 无法使用 javax.persistence.jtaDataSource
以下配置对于 WebLogic 来说没问题,但在 OpenEJB 中它会引发错误“javax.naming.NameNotFoundException:未找到名称“AppDB”。”
如果我删除了属性 javax.persistence.jtaDataSource,它就可以工作。为什么要设置2个重复的数据源?因为这是 Eclipselinks 的一个错误(参见 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>
以下是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.JtaManaged = false
jdbc/AppDB.UserName = xxxx
jdbc/AppDB.Password = xxxx
因为这是其他团队打包的 jar,所以我无法更改内容,但我仍然想在我的 OpenEJB 中使用它,有什么建议吗?谢谢。
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.JtaManaged = 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
完全不确定 EclipseLink 如何处理 javax.persistence.jtaDataSource 属性。我必须假设这是某种 JNDI 查找,但他们如何做到这一点具有令人难以置信的意义。例如,如果它们在前面加上 java:comp/env/ ,则会显着改变语义。
也许尝试重写 javax.persistence.jtaDataSource 来使用数据源的 OpenEJB 全局 JNDI 名称。因此,在您的
jndi.properties
文件中,添加“Definitely let me Know if that work”。似乎这可能是一个添加到 OpenEJB 的好功能,即使该属性实际上由 JPA 提供程序使用。修复无效的 JNDI 名称可能非常方便。
顺便说一句,应该有一个日志记录声明说“jdbc/AppDB.provider”不是数据源支持的属性。可能最好删除该属性。
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 prependjava: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 yourjndi.properties
file, addDefinitely 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.