我有一个包含许多模块的 Java EE 应用程序。我试图能够进行间接 JNDI 查找。
我按照以下步骤操作:
ejb-jar.xml:在每个模块中。我定义了一个企业 bean。模块中的所有 DAO 都继承自这个 DAO(MyDataAccessObject)
<enterprise-beans>
<session>
<ejb-name>DataAccessObject</ejb-name>
<ejb-class>com.mycompany.dao.MyDataAccessObject</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<resource-ref id="MyRef">
<description />
<res-ref-name>jdbc/My_db</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</session>
</enterprise-beans>
persistence.xml:我在每个 persistence.xml 中定义(在每个模块中)
<jta-data-source>java:comp/env/jdbc/My_db</jta-data-source>
ibm-应用程序-bnd.xml
<resRefBindings xmi:id="MyRef" jndiName="jdbc/My_db">
?????? Should I use resRefBindings. If yes, how?
</resRefBindings>
我应该在 Websphere 知道的有关 java:comp/env/jdbc/My_db 的文档中添加什么?
我已经做的足够/正确吗?
目前,如果我想启动应用程序,我会收到此错误:
The server cannot locate the java:comp/env/jdbc/my_db data source for the My_Modul persistence unit because it has encountered the following exception:
Name comp/env/jdbc not found in context "java:".
编辑:我在事件文件中也发现了这个错误:
Caused by: <openjpa-2.1.2-SNAPSHOT-r422266:1384519 fatal user error> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:76)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)
at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)