Reputation: 6694
I have a Java EE Application consisting many modules. I am trying to be able to make Indirect JNDI lookups.
I followed these Steps:
ejb-jar.xml: In each module. i defined an enterprise bean. All DAOs in the module inherits from this 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 : I defined in each persistence.xml (in every module)
<jta-data-source>java:comp/env/jdbc/My_db</jta-data-source>
ibm-application-bnd.xml
<resRefBindings xmi:id="MyRef" jndiName="jdbc/My_db">
?????? Should I use resRefBindings. If yes, how?
</resRefBindings>
What should i add to this document that Websphere knows about java:comp/env/jdbc/My_db?
Is it enough/correct what i have already done?
Currently I get this error if i want to start the application:
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:".
Edit: I found also this error in an incident file:
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)
Upvotes: 1
Views: 11457
Reputation: 5782
You use XMI bindings (resRefBindings) which are supported in WAS 7.0 but considered obsolete. It is recommended to use XML bindings. In META-INF
there should be file named ibm-ejb-jar-bnd.xml
with contents like this:
<ejb-jar-bnd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ejb-jar-bnd_1_0.xsd" version="1.0">
<session name="DataAccessObject">
<resource-ref name="**datasource_ref_in_your_EJB**" binding-name="jdbc/My_db"/>
</session>
</ejb-jar-bnd>
I also assume you already have datasource with JNDI name "jdbc/My_db" configured within WAS.
Upvotes: 1