0 Replies Latest reply on Aug 8, 2005 9:08 PM by gberish

    A Simple Entity Bean Deployment Goes to Wrong Database

    gberish

      I don't know if this is a beginners question, but I am a beginner and I had a heck of a time figuring out how the mapping from ejb entity bean to application to server all worked together.

      The code below is just the relevant lines of all the xml deployment files I thought I needed to persist a simple entity bean to a simple table.

      I have only two mysql databases:
      - jbossdb in a resource named DefaultDS, and
      - ejbtestdb in a resource named ejbTestDS.

      I thought the code below would make the bean persist in a table named ejbtestdb.memebers.

      But when used it throws an SQLException that says it cannot find jbossdb.members?

      As an aside, if I let the bean create its own table, it creates jbossdb.members and works fine.

      Can anyone suggest where I screwed up below in trying to connect the bean to ejbTestDS? I.e. ejbtestdb.members?

      Thanx, glb

      ejb-jar.xml
      Map the bean to a <resource-ref-name>

      <ejb-jar>
       <enterprise-beans>
       <!-- OneBean -->
       <entity>
       <ejb-name>OneBeanEJB</ejb-name>
       <resource-ref>
       <res-ref-name>OneBeanDS</res-ref-name>
       </resource-ref>
       </entity>
       </enterprise-beans>
      </ejb-jar>
      jboss.xml
      Map the <resource-ref-name> to a <jndi-name>
      <jboss>
       <enterprise-beans>
       <entity>
       <ejb-name>OneBeanEJB</ejb-name>
       <resource-ref>
       <res-ref-name>OneBeanDS</res-ref-name>
       <jndi-name>ejbTestDS</jndi-name>
       </resource-ref>
       </entity>
       </enterprise-beans>
      </jboss>
      jbosscmp-jdbc.xml
      Tie the bean to a table name
      <jbosscmp-jdbc>
       <enterprise-beans>
       <entity>
       <ejb-name>OneBeanEJB</ejb-name>
       <create-table>false</create-table>
       <table-name>members</table-name>
       </entity>
       </enterprise-beans>
      </jbosscmp-jdbc>
      mysql-ds.xml
      Map the <jndi-name> to a port
      <datasources>
       <local-tx-datasource>
       <jndi-name>DefaultDS</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/jbossdb</connection-url>
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </local-tx-datasource>
      
       <local-tx-datasource>
       <jndi-name>ejbTestDS</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/ejbtestdb</connection-url>
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>