CMP Entity Bean using DefaultDS instead of user defined DS
rupshall Apr 27, 2004 1:31 PMI am running JBoss 3.2.3 on Slackware linux 9.1 with Sun's SDK 1.4.2_03.
I have a CMP defined for a customer transaction, it should be connecting to table TCUSMST in my user defined data source psaDS but instead it creates/connects to table CUSTOMERTRANSACTIONEJB in JBoss's DefaultDS.
Here are my config files:
ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> <ejb-jar > <description>[CDATA[No Description.]]</description> <display-name>Generated by XDoclet</display-name> <enterprise-beans> <!-- To add session beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called session-beans.xml that contains the <session></session> markup for those beans. --> <!-- Entity Beans --> <entity > <description>[CDATA[Customer Transaction Table]]</description> <display-name>Customer Transaction EJB</display-name> <ejb-name>CustomerTransactionEJB</ejb-name> <home>com.psasoft.cellular.interfaces.CustomerTransactionHomeRemote</home> <remote>com.psasoft.cellular.interfaces.CustomerTransactionRemote</remote> <local-home>com.psasoft.cellular.interfaces.CustomerTransactionHomeLocal</local-home> <local>com.psasoft.cellular.interfaces.CustomerTransactionLocal</local> <ejb-class>com.psasoft.cellular.ejb.CustomerTransactionBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.Integer</prim-key-class> <reentrant>false</reentrant> <cmp-version>2.x</cmp-version> <abstract-schema-name>CustomerTransaction</abstract-schema-name> <cmp-field > <description>[CDATA[Get the recordId]]</description> <field-name>recordId</field-name> </cmp-field> <cmp-field > <description>[CDATA[Get the company number]]</description> <field-name>companyNumber</field-name> </cmp-field> <cmp-field > <description>[CDATA[Get the cycle number]]</description> <field-name>cycleNumber</field-name> </cmp-field> <cmp-field > <description>[CDATA[Get the account number]]</description> <field-name>accountNumber</field-name> </cmp-field> <cmp-field > <description>[CDATA[Get the first name]]</description> <field-name>firstName</field-name> </cmp-field> <cmp-field > <description>[CDATA[Get the last name]]</description> <field-name>lastName</field-name> </cmp-field> <primkey-field>recordId</primkey-field> <security-identity> <use-caller-identity /> </security-identity> <query> <query-method> <method-name>findByAccountNumber</method-name> <method-params> <method-param>java.math.BigDecimal</method-param> </method-params> </query-method> <ejb-ql>[CDATA[SELECT OBJECT( c ) FROM CustomerTransaction AS c WHERE c.accountNumber=?1]]</ejb-ql> </query> <query> <query-method> <method-name>findByAccountNumber</method-name> <method-params> <method-param>java.math.BigDecimal</method-param> </method-params> </query-method> <ejb-ql>[CDATA[SELECT OBJECT( c ) FROM CustomerTransaction AS c WHERE c.accountNumber=?1]]</ejb-ql> </query> <!-- Write a file named ejb-finders-CustomerTransactionBean.xml if you want to define extra finders. --> </entity> <!-- To add entity beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called entity-beans.xml that contains the <entity></entity> markup for those beans. --> <!-- Message Driven Beans --> <!-- To add message driven beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called message-driven-beans.xml that contains the <message-driven></message-driven> markup for those beans. --> </enterprise-beans> <!-- Relationships --> <!-- Assembly Descriptor --> <assembly-descriptor > <!-- To add additional assembly descriptor info here, add a file to your XDoclet merge directory called assembly-descriptor.xml that contains the <assembly-descriptor></assembly-descriptor> markup. --> <!-- finder permissions --> <!-- finder permissions --> <!-- transactions --> <!-- finder transactions --> </assembly-descriptor> </ejb-jar>
jboss.xml:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd"> <jboss> <enterprise-beans> <!-- To add beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called jboss-beans.xml that contains the <session></session>, <entity></entity> and <message-driven></message-driven> markup for those beans. --> <entity> <ejb-name>CustomerTransactionEJB</ejb-name> <jndi-name>CustomerTransactionHomeRemote</jndi-name> <local-jndi-name>CustomerTransactionHomeLocal</local-jndi-name> <method-attributes> </method-attributes> </entity> </enterprise-beans> <resource-managers> </resource-managers> </jboss>
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> <defaults> <datasource>java:/psaDS</datasource> <datasource-mapping>DB2/400</datasource-mapping> <create-table>true</create-table> <remove-table>false</remove-table> <preferred-relation-mapping>foregin-key</preferred-relation-mapping> </defaults> <enterprise-beans> <!-- To add beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called jbosscmp-jdbc-beans.xml that contains the <entity></entity> markup for those beans. --> <entity> <ejb-name>CustomerTransactionEJB</ejb-name> <table-name>TCUSMST</table-name> <cmp-field> <field-name>recordId</field-name> <column-name>RECORD_ID</column-name> <jdbc-type>INTEGER</jdbc-type> <sql-type>INT(9)</sql-type> <auto-increment/> </cmp-field> <cmp-field> <field-name>companyNumber</field-name> <column-name>CO#</column-name> <jdbc-type>DECIMAL</jdbc-type> <sql-type>DECIMAL(2, 0)</sql-type> </cmp-field> <cmp-field> <field-name>cycleNumber</field-name> <column-name>CYCLE#</column-name> <jdbc-type>DECIMAL</jdbc-type> <sql-type>DECIMAL(3, 0)</sql-type> </cmp-field> <cmp-field> <field-name>accountNumber</field-name> <column-name>BACCT#</column-name> <jdbc-type>DECIMAL</jdbc-type> <sql-type>DECIMAL(7, 0)</sql-type> </cmp-field> <cmp-field> <field-name>firstName</field-name> <column-name>FNAME</column-name> <jdbc-type>CHAR</jdbc-type> <sql-type>CHAR(30)</sql-type> </cmp-field> <cmp-field> <field-name>lastName</field-name> <column-name>LNAME</column-name> <jdbc-type>CHAR</jdbc-type> <sql-type>CHAR(30)</sql-type> </cmp-field> <!-- jboss 3.2 features --> <!-- optimistic locking does not express the exclusions needed --> </entity> </enterprise-beans> </jbosscmp-jdbc>
psadb-ds.xml:
<?xml version="1.0" encoding="UTF-8"?> <!-- ===================================================================== --> <!-- --> <!-- JBoss Server Configuration --> <!-- --> <!-- ===================================================================== --> <!-- $Id: psadb-ds.xml,v 1.0.0.0 2004/03/28 12:33:00 rupshall Exp $ --> <datasources> <local-tx-datasource> <jndi-name>psaDS</jndi-name> <driver-class>com.ibm.as400.access.AS400JDBCDriver</driver-class> <connection-url>jdbc:as400://psaunit/psads</connection-url> <user-name>username</user-name> <password>password</password> <application-managed-security/> <min-pool-size>5</min-pool-size> <max-pool-size>25</max-pool-size> <!-- ******************************************** --> <!-- START - IBM Toolbox for Java JDBC properties --> <!-- ******************************************** --> <!-- General properties --> <connection-property name="prompt">false</connection-property> <!-- Server properties --> <connection-property name="libraries">QGPL, *LIBL</connection-property> <connection-property name="transaction isolation">none</connection-property> <!-- Format properties --> <connection-property name="naming">sql</connection-property> <!-- Performance properties --> <connection-property name="block size">128</connection-property> <connection-property name="extended dynamic">true</connection-property> <connection-property name="package">JBOSS</connection-property> <connection-property name="package cache">true</connection-property> <connection-property name="package library">QGPL</connection-property> <!-- Other properties --> <connection-property name="access">all</connection-property> <connection-property name="driver">toolbox</connection-property> <connection-property name="errors">full</connection-property> <connection-property name="extended metadata">true</connection-property> <!-- ******************************************** --> <!-- END - IBM Toolbox for Java JDBC properties --> <!-- ******************************************** --> <!-- Generic JDBC properties --> <connection-property name="char.encoding">UTF-8</connection-property> <!-- sql to call when connection is created <new-connection-sql>some arbitrary sql</new-connection-sql> --> <!-- sql to call on an existing pooled connection when it is obtained from pool <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql> --> </local-tx-datasource> </datasources>