2 Replies Latest reply on Feb 17, 2005 8:28 AM by Peter Kormos

    Datasource and CMP entity bean

    Peter Kormos Newbie

      Hi,

      I wrote a simple entity bean that would use CMP. I'm using Oracle JDBC driver, and the bean works OK under JBoss 3.2.3. In Jboss 4.0, it seem to use the default DataSource and not the one I'm trying to specify.


      The deployment descriptors are:

      ejb.xml:

      <ejb-jar>
       <display-name>testModule</display-name>
       <enterprise-beans>
       <entity>
       <display-name>Enterprise1BeanName</display-name>
       <ejb-name>Enterprise1BeanName</ejb-name>
       <home>Enterprise1Home</home>
       <remote>Enterprise1Remote</remote>
       <ejb-class>Enterprise1Bean</ejb-class>
       <persistence-type>Container</persistence-type>
       <prim-key-class>java.lang.String</prim-key-class>
       <reentrant>False</reentrant>
       <cmp-field>
       <field-name>id</field-name>
       </cmp-field>
       <cmp-field>
       <field-name>payload</field-name>
       </cmp-field>
       <primkey-field>id</primkey-field>
       </entity>
       </enterprise-beans>
       <assembly-descriptor>
       <container-transaction>
       <method>
       <ejb-name>Enterprise1BeanName</ejb-name>
       <method-name>*</method-name>
       </method>
       <trans-attribute>Required</trans-attribute>
       </container-transaction>
       </assembly-descriptor>
      </ejb-jar>
      


      jaws.xml:

      <jaws>
       <datasource>testDataSource</datasource>
       <type-mapping>Oracle8</type-mapping>
       <enterprise-beans>
       <entity>
       <ejb-name>Enterprise1BeanName</ejb-name>
       <cmp-field>
       <field-name>id</field-name>
       <column-name>ID</column-name>
       </cmp-field>
       <cmp-field>
       <field-name>payload</field-name>
       <column-name>PAYLOAD</column-name>
       </cmp-field>
       <table-name>EJBTEST</table-name>
       </entity>
       </enterprise-beans>
      </jaws>
      


      jboss.xml:

      <jboss>
       <enterprise-beans>
       <entity>
       <ejb-name>Enterprise1BeanName</ejb-name>
       <jndi-name>Enterprise1JNDI</jndi-name>
       </entity>
       </enterprise-beans>
      </jboss>
      


      "testDataSource" is configured in oracle-ds.xml and jdbc driver's jar file is in /lib directory.

      Could anyone help?

      Thanks,

      Peter

        • 1. Re: Datasource and CMP entity bean
          Joshua Jackson Master

          Perhaps it is because you forgot to tell whisc datasource you use in ejb.xml. Hope this helps.

          • 2. Re: Datasource and CMP entity bean
            Peter Kormos Newbie

            defkewl:

            I tried to add <resource-ref> to jboss.xml and ejb.xml but it didn't help.

            But then I read it on the Net, that I should use jbosscmp-jdbc.xml instead of jaws.xml.

            So I created one

            <?xml version="1.0" encoding="UTF-8"?>
            <jbosscmp-jdbc>
             <defaults>
             <datasource>java:/testDataSource</datasource>
             <type-mapping>Oracle8</type-mapping>
            
             <debug>true</debug>
             <create-table>true</create-table>
             <remove-table>false</remove-table>
             <read-only>false</read-only>
             <time-out>0</time-out>
             <select-for-update>false</select-for-update>
             <pk-constraint>true</pk-constraint>
             <relation-mapping-style>foreign-key</relation-mapping-style>
             <read-ahead>
             <strategy>on-load</strategy>
             <page-size>500</page-size>
             <eager-load-group>group name</eager-load-group>
             </read-ahead>
             </defaults>
             <enterprise-beans>
             <entity>
             <ejb-name>Enterprise1BeanName</ejb-name>
             <table-name>EJBTEST</table-name>
            
             <cmp-field>
             <field-name>id</field-name>
             <column-name>ID</column-name>
             </cmp-field>
             <cmp-field>
             <field-name>payload</field-name>
             <column-name>PAYLOAD</column-name>
             </cmp-field>
            
             </entity>
             </enterprise-beans>
            </jbosscmp-jdbc>
            


            and then the CMP worked.

            Peter