0 Replies Latest reply on Sep 22, 2005 4:37 PM by u9707118

    EJB's looking at hypersonic database instead of mysql

    u9707118

      This is a very strange problem...I have worked with JBOSS and Oracle many times without problem. However, now I am trying my hand at JBOSS and mySQL with some puzzling results.

      I have successfully created a Datasource that connects to mySQL and I have a class that performs JDBC queries (this class connects to this mySQL datasource -- see code below).

      System.out.println("Loading underlying JDBC driver.");
      try {
       Class.forName("com.mysql.jdbc.Driver");
      } catch (ClassNotFoundException e) {
       e.printStackTrace();
      }
      System.out.println("Done.");
      final InitialContext context = new InitialContext();
      dataSource = (DataSource)context.lookup ("java:/BBIMDB")


      However the EJB's seem to be pointing at a different database (I guess hypersonic) because when I call a findByPrimaryKey() method on a bean with a row I know exists, it can't find it (NotFoundException). And when I create an entity bean - it works without error, however it is nowhere to be seen in the mySQL database!

      I have created a mySQL datasource (mysql-ds.xml) as follows:
      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
       <local-tx-datasource>
       <jndi-name>BBIMDB</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/bbimdb</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>bbimdb</user-name>
       <password>password</password>
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>

      With my EJB's, I deploy the following jbosscmp-jdbc.xml file:
      <?xml version='1.0' encoding='windows-1252'?>
      <jbosscmp-jdbc>
       <defaults>
       <datasource>java:/BBIMDB</datasource>
       <datasource-mapping>mySQL</datasource-mapping>
       <create-table>false</create-table>
       <remove-table>false</remove-table>
       </defaults>
       <enterprise-beans>
      ...

      and the following jboss.xml file
      <?xml version = '1.0' encoding = 'windows-1252'?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">
      <jboss>
      <resource-ref>
       <res-ref-name>jdbc/BBIMDB</res-ref-name>
       <jndi-name>BBIMDB</jndi-name>
      </resource-ref>
      ...
      

      Please can somebody help? I am at a loss :(
      I am using jboss-4.0.1sp1 on winXP with mySQL 4.1 and connectorj 3.1.10