6 Replies Latest reply on Apr 28, 2004 2:00 PM by rupshall

    CMP Entity Bean using DefaultDS instead of user defined DS

    rupshall

      I 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>
      
      


        • 1. Re: CMP Entity Bean using DefaultDS instead of user defined
          sesques

          Is your psadb-ds.xml loaded correctly (did you see it in the server log file) ?

          Probably not the error, but the

          <preferred-relation-mapping>foregin-key</preferred-relation-mapping>

          tag has an error, it must be foreign-key


          • 2. Re: CMP Entity Bean using DefaultDS instead of user defined
            rupshall

            psadb-ds.xml deploys without errors, I have used it successfully in a session bean.

            Thanks for pointing out the typo, it wasn't the problem but its fixed now.

            I am getting zero errors on the console and I can access the CMP bean in question and it access/updates the DefaultDS. I jusr cannot determine why it is using the DefautDS.

            • 3. Re: CMP Entity Bean using DefaultDS instead of user defined
              sesques

              In my opinion, nothing's wrong in your descriptors.
              I suggest you activate some traces in the ejb plugin to solve that issue.

              • 4. Re: CMP Entity Bean using DefaultDS instead of user defined
                rupshall

                I added the log4j entries and redeployed the my data source and EJB. I couldn't see any errors or anything that looked odd. I added the log entries from the forum readme, should I be adding something different?

                Here is what I added to log4j.xml:

                 <category name="org.jboss.resource">
                 <priority value="TRACE" class="org.jboss.logging.XLevel"/>
                 </category>
                
                 <category name="org.jboss.tm">
                 <priority value="TRACE" class="org.jboss.logging.XLevel"/>
                 </category>
                
                 <category name="org.jboss.resource.adapter.jdbc">
                 <priority value="TRACE" class="org.jboss.logging.XLevel"/>
                 </category>
                
                 <category name="org.jboss.resource.adapter.jms">
                 <priority value="TRACE" class="org.jboss.logging.XLevel"/>
                 </category>
                
                 <category name="org.jboss.resource.connectionmanager">
                 <priority value="TRACE" class="org.jboss.logging.XLevel"/>
                 </category>
                




                • 5. Re: CMP Entity Bean using DefaultDS instead of user defined
                  sesques

                  Adds

                  <category name="org.jboss.ejb.plugins">
                   <priority value="TRACE" class="org.jboss.logging.XLevel"/>
                  </category>
                  

                  for the EJB engine.


                  • 6. Re: CMP Entity Bean using DefaultDS instead of user defined
                    rupshall

                    Thanks that helped me find the problem. I deployed another ejb that I already had working and with the ejb debugging turned on I noticed the problem.

                    before:

                    2004-04-28 13:39:29,370 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.CustomerTransactionEJB] Loading standardjbosscmp-jdbc.xml : file:/home/rupshall/.local/lib/jboss-3.2.3/server/default/conf/standardjbosscmp-jdbc.xml
                    


                    after:
                    2004-04-28 13:39:29,370 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.CustomerTransactionEJB] Loading standardjbosscmp-jdbc.xml : file:/home/rupshall/.local/lib/jboss-3.2.3/server/default/conf/standardjbosscmp-jdbc.xml
                    2004-04-28 13:39:30,208 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.CustomerTransactionEJB] jar:file:/home/rupshall/.local/lib/jboss-3.2.3/server/default/tmp/deploy/tmp26303psa-EJB.jar!/META-INF/jbosscmp-jdbc.xml found. Overriding defaults
                    



                    My ear file didn't contain jbosscmp-jdbc.xml, it missed it when I created my new build.xml. Added it to my build.xml created a new build, everything worked like a charm!!

                    Thanks for all the help,
                    Robert