4 Replies Latest reply on Jun 18, 2004 1:14 PM by seabird

    Converting from Hypersonic to MYSQL

    seabird

      This is actually a series of messages strung together from a posting at "theserverside.com" I didn't get many helpful answers here, so I am submitting the evidence to this august group and begging for assistance.

      Sorry the post is so long, I wanted to offer as much evidence as I could.

      "I had a good working demo of an EJB/CMP application on the Hypersonic DB. However, Hypersonic didn't do some of the things I needed, so I "upgraded" to mysql on a windows platform.

      My development environment is Eclipse 2.1.3 and Lomboz 2.1.3.

      My problem comes in creating the DDs for both the mysql world and the beans themselves. I have modified the xdoclet.xml file to put in what I thought were the right pieces of data for the generation of the jbosscmp-jdbc.xml file.

      Some key parts of that are as follows:

      <jbosscmp-jdbc>

      mySQLDS
      <datasource-mapping>mySQL</datasource-mapping>
      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>

      -------------------------------------------------------
      The following is the log output from the deployment in jboss

      Depends On Me: , ObjectName: jboss.j2ee:jndiName=RoleBean,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Error in jbosscmp-jdbc
      .xml : datasource-mapping mySQLDS not found, ObjectName: jboss.j2ee:jndiName=Per
      sonBean,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Error in jbosscmp-jdbc
      .xml : datasource-mapping mySQLDS not found]

      -----------------------------------------------------------

      The following is the sum total of my mysql-service.xml file. This file is in the jboss/server/default/deploy folder. I found the skeleton of this file in the jboss/docs/examples/jca directory. There was a recommendation on one site (I have forgotten which) that I modify this file. It is somewhat worrying that the comments in the file suggest that it is for mySQL 2.011 and I am using release 3.2.3 of JBOSS.

      Any help would be greatly appreciated. I am fast losing hair - I keep tearing it out!

      Chris Bird - see XML below.


      <?xml version="1.0" encoding="UTF-8"?>

      <!-- ===================================================================== -->
      <!-- -->
      <!-- JBoss Server Configuration -->
      <!-- -->
      <!-- ===================================================================== -->

      <!-- $Id: mysql-ds.xml,v 1.1 2002/07/22 22:57:24 d_jencks Exp $ -->
      <!-- ==================================================================== -->
      <!-- Datasource config for MySQL using 2.0.11 driver -->
      <!-- ==================================================================== -->



      <local-tx-datasource>
      <jndi-name>mySQLDS</jndi-name>
      <connection-url>jdbc:mysql://localhost/kipoko</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>chris</user-name>

      </local-tx-datasource>



      I then followed the Chapter 8 - Using Other Databases of the JBoss 3.2 Getting Started PDF file located here http://www.jboss.org/docs/index to setup MySQL database to use with JBosss.
      I changed my jbosscmp-jdbc.xml to look like the following:



      -----------------------------------------------------------------------------

      <jbosscmp-jdbc>

      java:/DefaultDS
      <datasource-mapping>mySQL</datasource-mapping>
      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>


      -----------------------------------------------------------------------------

      The mysql-service.xml (in the deploy directory) looks like the following. Note that apart from comments this is the whole file. It would appear to me that there ought to be more than this.

      -----------------------------------------------------------------------------


      <local-tx-datasource>
      <jndi-name>DefaultDS</jndi-name>
      <connection-url>jdbc:mysql://localhost:3306/kipoko</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>chris</user-name>

      </local-tx-datasource>


      -------------------------------------------------------------------------------

      When i go to http://localhost:8080/jmx-console to look at what has been deployed, I am not exactly sure what to look for, but here are some indications that things are not right:

      In the section jboss.jdbc there is 1 service: text says
      service=SQLExceptionProcessor

      If I go to the JNDIView service, I would expect to see a DefaultDS service under the java namespace. It isn't there. That confirms the error messages from the jbossdeployer, but doesn't solve the problem for me! My guess is that the mysql-service.xml did not deploy correctly, but the log file entries don't confirm that. Here is the extract from the log....

      ------------------------------------------------------------------------------
      2004-06-17 10:03:44,310 INFO [org.jboss.deployment.MainDeployer] Starting deployment of package: file:/D:/jboss/jboss-3.2.3/server/default/deploy/mysql-service.xml
      2004-06-17 10:03:44,360 INFO [org.jboss.deployment.MainDeployer] Deployed package: file:/D:/jboss/jboss-3.2.3/server/default/deploy/mysql-service.xml

      -------------------------------------------------------------------------------

      The actual error messages in the log for the failure to deploy my beans are:

      -----------------------------------------------------------------------------

      ObjectName: jboss.j2ee:jndiName=PersonBean,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Error: can't find data source: java:/DefaultDS; - nested throwable: (javax.naming.NameNotFoundException: DefaultDS not bound)]

      -----------------------------------------------------------------------------

      Any (and all) further help greatly appreciated. If anyone would prefer to get in touch offline, then feel free to email me at:

      seabird(nospam)@msn.com.

      Of course, you would need to remove the (nospam) entry!


      There is clearly something squirrely here. It doesn't seem to matter what entry I put in here

      <driver-class>com.mysql.jdbc.Driver</driver-class>

      Even if I comment out this line, jboss claims to deploy it correctly (according to the log). So I am truly confused. "

      Thanks in advance:

      Chris

        • 1. Re: Converting from Hypersonic to MYSQL
          seabird

          There is a format error (or something) in the previous post.

          The XML did not render cleanly.

          It should have read: I had to drop the opening < from <defaults and </defaults to get the text to display correctly.

          <jbosscmp-jdbc>
          defaults>
          mySQLDS
          <datasource-mapping>mySQL</datasource-mapping>
          <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
          defaults>

          • 2. Re: Converting from Hypersonic to MYSQL
            pnevado

            In case you may find it useful, here it is my configuration with MySql: it works with JBoss 3.2.4 and MySql 4.0.18:

            <!-- ===================================================================== -->
            <!-- -->
            <!-- Standard JBossCMP-JDBC Configuration -->
            <!-- -->
            <!-- ===================================================================== -->
            
            <!-- $Id: standardjbosscmp-jdbc.xml,v 1.39.2.46 2004/04/20 18:20:40 loubyansky Exp $ -->
            
            <jbosscmp-jdbc>
            
             <defaults>
             <datasource>java:/mysqlDS</datasource>
             <datasource-mapping>mySQL</datasource-mapping>
            ========================================
            <datasources>
             <local-tx-datasource>
             <jndi-name>mysqlDS</jndi-name>
             <connection-url>jdbc:mysql://localhost:3306/vivoen</connection-url>
             <driver-class>com.mysql.jdbc.Driver</driver-class>
             <user-name>p</user-name>
             <password>s</password>
             <!-- sql to call on an existing pooled connection when it is obtained from pool -->
             <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
             </local-tx-datasource>
            
            </datasources>


            • 3. Re: Converting from Hypersonic to MYSQL

              You mention your mysql-service.xml file. To define a new datasource you need a -ds.xml file. This is processed by the deployer to create various MBeans that respresent the JDBC data source.

              Rename your mysql-service.xml file mysql-ds.xml and redeploy. You should see a number of additional MBeans in the jboss.jca section of the JMX console. The actual data source name you've defined in the <jndi-name> element should be visible in the JNDI view in the java: section.
              This is the data source the EJB must be configured to use.

              Hope this helps.
              If you buy the full documentation it covers configuring new data sources (in the JCA chapter) and the CMP layer.

              • 4. Thanks to All - Re: Converting from Hypersonic to MYSQL
                seabird

                Thanks very much for your assistance. The subtelty of the -ds had previously escaped me. While I was about it I upgraded to JBOSS 3.2.4. All is working as expected now.

                When I stop moving around, I will certainly buy the books.

                Regards

                Chris