-
1. Re: Override Default Datasource in Entity EJBs
juha Dec 5, 2003 9:32 AM (in response to afranken)Try using the local resource reference tags instead.
-- Juha -
2. Re: Override Default Datasource in Entity EJBs
afranken Dec 5, 2003 10:03 AM (in response to afranken)Could you be more specific... I know of only local-jndi-name and ejb-local-ref.
My bean is using EJB 1. so it has only a remote component interface.
Can you think of anything else I am not doing correctly?
Do I need the jbosscmp-jdbc.xml?
I have included it as well inside META-INF.
It looks like...
<jbosscmp-jdbc>
<enterprise-beans>
<ejb-name>AcctAccessMatrix</ejb-name>
java:/msSQL7EJBPool
<datasource-mapping>MS SQLSERVER</datasource-mapping>
true
<create-table>false</create-table>
<remove-table>false</remove-table>
<read-only>false</read-only>
<time-out>300</time-out>
<select-for-update>false</select-for-update>
<pk-constraint>true</pk-constraint>
<read-ahead>true</read-ahead>
<table-name>AcctAccessMatrix2</table-name>
<entity-command name="mssql-fetch-key"/>
<type-mapping>
MS SQLSERVER
.......
.......
</type-mapping>
</enterprise-beans>
</jbosscmp-jdbc>
Thanks. -
3. Re: Override Default Datasource in Entity EJBs
afranken Dec 5, 2003 10:23 AM (in response to afranken)I put some random text into META-INF/jbosscmp-jdbc.xml and no parsing errors occured.
I don't believe jboss is looking at that file...
?? -
4. Re: Override Default Datasource in Entity EJBs
juha Dec 5, 2003 11:46 AM (in response to afranken)The jbosscmp-jdbc.xml file is only required for CMP Entities.
It sounds like what you're trying to do is lookup a datasource from java:comp/env namespace.
-- Juha -
5. Re: Override Default Datasource in Entity EJBs
juha Dec 5, 2003 11:47 AM (in response to afranken)Sorry, I meant resource-env-ref previously.
-- Juha -
6. Re: Override Default Datasource in Entity EJBs
afranken Dec 5, 2003 12:01 PM (in response to afranken)I am trying to deplay a CMP Entity Bean and when deployed, jboss is ignoring the jbosscmp-jdbc.xml.
No parsing errors occur. ?? -
7. Re: Override Default Datasource in Entity EJBs
juha Dec 5, 2003 12:18 PM (in response to afranken)Then you don't need to declare the resource references to your datasource in ejb-jar.xml.
Post your full deployment descriptors and explain what you're trying to do.
-- Juha -
8. Re: Override Default Datasource in Entity EJBs
afranken Dec 5, 2003 12:39 PM (in response to afranken)Below are the files that are location in META-INF/
In conf/standardjbosscmp-jdbc.xml and standardjaws.xml I define the default datasource to use Oracle mappings.
In my CMP Entity EJB I want to specify in the descriptor to override the default datasource and use a SQLSERVER datasource.
Every thing I have tried ends up using the default oracle datasource.
I don't believe jboss is reading my jbosscmp-jdbc.xml file because no parser errors occur. Not sure what I am not doing right.
Thanks..
META-INF/ejb-jar.xml
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<enterprise-beans>
<ejb-name>AcctAccessMatrix</ejb-name>
com.acs.vsx.account.ejb.AcctAccessMatrixHome
com.acs.vsx.account.ejb.AcctAccessMatrix
<ejb-class>com.acs.vsx.account.ejb.AcctAccessMatrixEJB</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>com.acs.vsx.account.ejb.AcctAccessMatrixPK</prim-key-class>
False
<cmp-field>
<field-name>accessLevel</field-name>
</cmp-field>
<cmp-field>
<field-name>subAcctNum</field-name>
</cmp-field>
<cmp-field>
<field-name>univAcctNum</field-name>
</cmp-field>
<cmp-field>
<field-name>iDNumber</field-name>
</cmp-field>
<resource-ref>
<res-ref-name>jdbc/msSQL7EJBPool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<ejb-name>AcctAccessMatrix</ejb-name>
<method-name>*</method-name>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
META-INF/jboss.xml
<?xml version="1.0" encoding="UTF-8"?>
<enterprise-beans>
<ejb-name>AcctAccessMatrix</ejb-name>
<jndi-name>AcctAccessMatrix</jndi-name>
<resource-ref>
<res-ref-name>jdbc/msSQL7EJBPool</res-ref-name>
<jndi-name>java:/msSQL7EJBPool</jndi-name>
</resource-ref>
</enterprise-beans>
META-INF/jbosscmp-jdbc.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jbosscmp-jdbc PUBLIC
"-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN"
"http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">
<jbosscmp-jdbc>
<enterprise-beans>
<ejb-name>AcctAccessMatrix</ejb-name>
java:/msSQL7EJBPool
<datasource-mapping>MS SQLSERVER</datasource-mapping>
true
<create-table>false</create-table>
<remove-table>false</remove-table>
<read-only>false</read-only>
<time-out>300</time-out>
<select-for-update>false</select-for-update>
<pk-constraint>true</pk-constraint>
<read-ahead>true</read-ahead>
<table-name>AcctAccessMatrix2</table-name>
<entity-command name="mssql-fetch-key"/>
</enterprise-beans>
</jbosscmp-jdbc> -
9. Re: Override Default Datasource in Entity EJBs
juha Dec 5, 2003 1:38 PM (in response to afranken)I'm not sure how the CMP engine behaves when you declare your DTD as version 1.1. It would make sense to me it won't use the jbosscmp-jdbc.xml file in that case since it's a configuration file specific to CMP 2.0 engine. But you'd have to ask on the Persistence forum to be certain.
However, try declaring the version 2.0 of the DTD for your entity and then in the version tag specify your CMP version as 1.x. The 2.0 DTD should force the use of CMP 2.0 engine at least which is the one that reads the jbosscmp-jdbc.xml file.
-- Juha -
10. Re: Override Default Datasource in Entity EJBs
afranken Dec 5, 2003 3:25 PM (in response to afranken)Thank you Juha!!! That was the problem!!!! I appreciate your help.