8 Replies Latest reply on Apr 23, 2014 5:09 AM by maxandersen

    Setting up datasource in JBoss

    sjparikh

      Hello,

       

      I am new to JBoss. I downloaded JBoss Developer Studio

       

      JBoss Enterprise Application Platform - Version 6.2.0.GA

       

      I am trying to setup MySQL as datasource and it is not able to recognize my XML.

       

      I copied mysql-connector-java-5.1.30-bin.jar in jboss-eap\standalone\lib directory. Then I placed mysql-ds.xml in jboss-eap\standalone\deployments directory. Following is the content of mysql-ds.xml:

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

      <datasources>

        <datasource>

        <jndi-name>java:/DefaultDS</jndi-name>

         <connection-url>jdbc:mysql://localhost:3306/test</connection-url>

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

         <user-name>root</user-name>

         <password>test1102</password>

         <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>

         <metadata>

        <type-mapping>mySQL</type-mapping>

        </metadata>

        </datasource>

      </datasources>

       

      When I restart JBoss server from my JBDevStudio. I see following message in the console:

       

      09:44:25,580 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report

      JBAS014777:   Services which failed to start:      service jboss.deployment.unit."mysql-ds.xml".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."mysql-ds.xml".PARSE: JBAS018733: Failed to process phase PARSE of deployment "mysql-ds.xml"

       

      I will appreciate if someone can shed some light on what am I doing wrong here.

       

      Thanks,

      Swetal

        • 1. Re: [jbdevstudio-users] Setting up datasource in JBoss
          burrsutter

          Can you try our datasource wizard?

           

          http://screencast.com/t/LneBx3ZA

           

          It should generate a valid -ds.xml for you, if not, we really do want to know

           

           

          On Apr 22, 2014, at 11:07 AM, Swetal Parikh <jbdevstudio-users@lists.jboss.org> wrote:

           

          Hello,

           

          I am new to JBoss. I downloaded JBoss Developer Studio

           

          JBoss Enterprise Application Platform - Version 6.2.0.GA

           

          I am trying to setup MySQL as datasource and it is not able to recognize my XML.

           

          I copied mysql-connector-java-5.1.30-bin.jar in jboss-eap\standalone\lib directory. Then I placed mysql-ds.xml in jboss-eap\standalone\deployments directory. Following is the content of mysql-ds.xml:

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

          <datasources>

            <datasource>

            <jndi-name>java:/DefaultDS</jndi-name>

             <connection-url>jdbc:mysql://localhost:3306/test</connection-url>

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

             <user-name>root</user-name>

             <password>test1102</password>

             <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>

             <metadata>

            <type-mapping>mySQL</type-mapping>

            </metadata>

            </datasource>

          </datasources>

           

          When I restart JBoss server from my JBDevStudio. I see following message in the console:

           

          09:44:25,580 INFO  (Controller Boot Thread) JBAS014774: Service status report

          JBAS014777:   Services which failed to start:      service jboss.deployment.unit."mysql-ds.xml".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."mysql-ds.xml".PARSE: JBAS018733: Failed to process phase PARSE of deployment "mysql-ds.xml"

           

          I will appreciate if someone can shed some light on what am I doing wrong here.

           

          Thanks,

          Swetal

           

          Posted by forums

          Original post: https://community.jboss.org/message/869775#869775

           

          _______________________________________________

          jbdevstudio-users mailing list

          jbdevstudio-users@lists.jboss.org

          https://lists.jboss.org/mailman/listinfo/jbdevstudio-users

           

           

          • 2. Re: Setting up datasource in JBoss
            wdfink

            Datasources are handled different in EAP6.

            The recommended way is to use a module for the driver and use the subsystem datasources to install the DS as managed, see Data Source Configuration in AS 7

             

            You might use *-ds.xml files for development, a description how to do it is here

            • 3. Re: Setting up datasource in JBoss
              maxandersen

              where do you see recommended way is to use modules ?  if your driver is jdbc 4 compliant no need for added complexity of modules.

              • 4. Re: Setting up datasource in JBoss
                maxandersen

                Try what Burr suggest - what the wizard does differently is it will put the mysql. jar in the deployments directory where it should be picked up.

                • 5. Re: Setting up datasource in JBoss
                  wdfink

                  Sorry, you're right -  the recommended way is to use a managed datasource (*-ds.xml files for development)

                  for simple DS the driver can be deployed or installed as a module but sometimes you need to use it as module if the scenario is more complex.

                  • 6. Re: Setting up datasource in JBoss
                    sjparikh

                    Hi Burr,

                    Thanks for the reply. I tried to create data source using the tool you mentioned. It created following XML (New_MySQL-ds.xml) :

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

                    <datasources xmlns="http://www.jboss.org/ironjacamar/schema">

                    <datasource jndi-name="java:jboss/datasources/New_MySQL" enabled="true"

                         use-java-context="true" pool-name="New_MySQL">

                      <connection-url>jdbc:mysql://localhost:3306/addressbook</connection-url>

                      <driver>mysql-connector-java-5.1.30-bin.jar</driver>

                      <pool></pool>

                      <security>

                       <user-name>root</user-name>

                       <password>test1102</password>

                      </security>

                    </datasource>

                    </datasources>

                     

                    But I am still getting following error when I bring up the application server:

                    13:06:01,920 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report

                    JBAS014777:   Services which failed to start:      service jboss.deployment.unit."TestFrontEnd.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."TestFrontEnd.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "TestFrontEnd.war"

                          service jboss.deployment.unit."mysql-ds.xml".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."mysql-ds.xml".PARSE: JBAS018733: Failed to process phase PARSE of deployment "mysql-ds.xml"

                    • 7. Re: Setting up datasource in JBoss
                      sjparikh

                      I found following article on how to set it up:

                      http://bnlconsulting.com/index.php/blog/item/88-jboss-71-adding-mysql-datasource

                       

                      After I followed the document, I do see Datasource being added on management console. But when I try to test the connection, I get following error:

                       

                      Unexpected HTTP response: 500

                       

                       

                      Request

                      {

                          "address" => [

                              ("subsystem" => "datasources"),

                              ("data-source" => "EmployeeServiceDS")

                          ],

                          "operation" => "flush-all-connection-in-pool"

                      }

                       

                       

                      Response

                       

                       

                      Internal Server Error

                      {

                          "outcome" => "failed",

                          "failure-description" => "JBAS010440: failed to invoke operation: JBAS010442: failed to match pool. Check JndiName: java:jboss/datasources/EmplouyeeServiceDS",

                          "rolled-back" => true

                      }

                      • 8. Re: Setting up datasource in JBoss
                        maxandersen

                        The datasource you show has this name: java:jboss/datasources/New_MySQL 

                        your error indicates you used: java:jboss/datasources/EmplouyeeServiceDS when trying to refer to it.

                         

                        Those names should match for it to be found.