7 Replies Latest reply on Dec 30, 2002 4:32 PM by zaphod

    JBoss does not see my MySql database

    dferquian

      I am running JBoss 3.0.2 and MySql but Jboss keeps accesing the hsquldb default database instead of my mysql database. I already copied mysql-service.xml in C:\jboss-3.0.2\server\default\deploy but when i run JBoss it pays no attention to it.
      How is the right way to configure it? Any help would be appreciated.

        • 1. Re: JBoss does not see my MySql database
          kuba.nowakowski

          hi

          check with this file

          for me it's working fine

          mysql-service.xml :

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

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



          <!-- ==================================================================== -->
          <!-- New ConnectionManager setup for mysql using 2.0.11 driver -->
          <!-- Build jmx-api (build/build.sh all) and view for config documentation -->
          <!-- ==================================================================== -->




          <!-- Include a login module configuration named MySqlDbRealm.
          Update your login-conf.xml, here is an example for a
          ConfiguredIdentityLoginModule:

          <application-policy name = "MySqlDbRealm">

          <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
          <module-option name = "principal">yourprincipal</module-option>
          <module-option name = "userName">yourusername</module-option>
          <module-option name = "password">yourpassword</module-option>
          <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MySqlDS</module-option>
          </login-module>

          </application-policy>

          NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the
          module-option name = "managedConnectionFactoryName"
          must match the object name of the ConnectionManager you are configuring here.
          -->
          <!--uncomment out this line if you are using the MySqlDbRealm above
          MySqlDbRealm
          -->

          <depends optional-attribute-name="ManagedConnectionFactoryName">
          <!--embedded mbean-->


          MySqlDS



          <config-property name="ConnectionURL" type="java.lang.String">jdbc:mysql://banking.emea.cpqcorp.net:3306/mmdb</config-property>
          <config-property name="DriverClass" type="java.lang.String">org.gjt.mm.mysql.Driver</config-property>
          <!--set these only if you want only default logins, not through JAAS -->
          <config-property name="UserName" type="java.lang.String">mm</config-property>
          <config-property name="Password" type="java.lang.String"></config-property>




          <!--Below here are advanced properties -->
          <!--hack-->
          <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper




          <depends optional-attribute-name="ManagedConnectionPool">
          <!--embedded mbean-->


          0
          50
          5000
          15
          <!--criteria indicates if Subject (from security domain) or app supplied
          parameters (such as from getConnection(user, pw)) are used to distinguish
          connections in the pool. Choices are
          ByContainerAndApplication (use both),
          ByContainer (use Subject),
          ByApplication (use app supplied params only),
          ByNothing (all connections are equivalent, usually if adapter supports
          reauthentication)-->
          ByContainer



          <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager

          <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:name=JaasSecurityManager

          java:/TransactionManager
          <!--make the rar deploy! hack till better deployment-->
          jboss.jca:service=RARDeployer






          kuba

          • 2. Re: JBoss does not see my MySql database
            dferquian

            kuba, thanks for your answer. Unfortunately I did not get it to work. here is my mysql-service.xml file to see if can help you to give me a hint. Do I have to add something in te login-config.xml file too?


            <!-- ==================================================================== -->
            <!-- New ConnectionManager setup for mysql using 2.0.11 driver -->
            <!-- Build jmx-api (build/build.sh all) and view for config documentation -->
            <!-- ==================================================================== -->

            <!-- Include a login module configuration named MySqlDbRealm.
            Update your login-conf.xml, here is an example for a
            ConfiguredIdentityLoginModule:

            <application-policy name = "MySqlDbRealm">

            <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
            <module-option name = "principal">yourprincipal</module-option>
            <module-option name = "userName">yourusername</module-option>
            <module-option name = "password">yourpassword</module-option>
            <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MySqlDS</module-option>
            </login-module>

            </application-policy>

            NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the
            module-option name = "managedConnectionFactoryName"
            must match the object name of the ConnectionManager you are configuring here.
            -->
            <!--uncomment out this line if you are using the MySqlDbRealm above
            MySqlDbRealm
            -->
            <depends optional-attribute-name="ManagedConnectionFactoryName">
            <!--embedded mbean-->

            MySqlDS


            <config-property name="ConnectionURL" type="java.lang.String">jdbc:odbc:ODBCSistemasLegados//localhost:3306/dbSistLeg</config-property>
            <config-property name="DriverClass" type="java.lang.String">sun.jdbc.odbc.JdbcOdbcDriver</config-property>
            <!--set these only if you want only default logins, not through JAAS -->
            <config-property name="UserName" type="java.lang.String"/>
            <config-property name="Password" type="java.lang.String"/>


            <!--Below here are advanced properties -->
            <!--hack-->
            <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper


            <depends optional-attribute-name="ManagedConnectionPool">
            <!--embedded mbean-->

            0
            50
            5000
            15
            <!--criteria indicates if Subject (from security domain) or app supplied
            parameters (such as from getConnection(user, pw)) are used to distinguish
            connections in the pool. Choices are
            ByContainerAndApplication (use both),
            ByContainer (use Subject),
            ByApplication (use app supplied params only),
            ByNothing (all connections are equivalent, usually if adapter supports
            reauthentication)-->
            ByContainer


            <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager
            <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager
            java:/TransactionManager
            <!--make the rar deploy! hack till better deployment-->
            jboss.jca:service=RARDeployer

            • 3. Re: JBoss does not see my MySql database
              dferquian

              kuba, thnks for your answer. Unfortunately I coul not get it to work. Here is my mysql-service.xml file to see if you can give me a hint based on it. Do I have to add something in the login-config.xml file also?
              Thanks.


              <!-- ==================================================================== -->
              <!-- New ConnectionManager setup for mysql using 2.0.11 driver -->
              <!-- Build jmx-api (build/build.sh all) and view for config documentation -->
              <!-- ==================================================================== -->

              <!-- Include a login module configuration named MySqlDbRealm.
              Update your login-conf.xml, here is an example for a
              ConfiguredIdentityLoginModule:

              <application-policy name = "MySqlDbRealm">

              <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
              <module-option name = "principal">yourprincipal</module-option>
              <module-option name = "userName">yourusername</module-option>
              <module-option name = "password">yourpassword</module-option>
              <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MySqlDS</module-option>
              </login-module>

              </application-policy>

              NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the
              module-option name = "managedConnectionFactoryName"
              must match the object name of the ConnectionManager you are configuring here.
              -->
              <!--uncomment out this line if you are using the MySqlDbRealm above
              MySqlDbRealm
              -->
              <depends optional-attribute-name="ManagedConnectionFactoryName">
              <!--embedded mbean-->

              MySqlDS


              <config-property name="ConnectionURL" type="java.lang.String">jdbc:odbc:ODBCSistemasLegados//localhost:3306/dbSistLeg</config-property>
              <config-property name="DriverClass" type="java.lang.String">sun.jdbc.odbc.JdbcOdbcDriver</config-property>
              <!--set these only if you want only default logins, not through JAAS -->
              <config-property name="UserName" type="java.lang.String"/>
              <config-property name="Password" type="java.lang.String"/>


              <!--Below here are advanced properties -->
              <!--hack-->
              <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper


              <depends optional-attribute-name="ManagedConnectionPool">
              <!--embedded mbean-->

              0
              50
              5000
              15
              <!--criteria indicates if Subject (from security domain) or app supplied
              parameters (such as from getConnection(user, pw)) are used to distinguish
              connections in the pool. Choices are
              ByContainerAndApplication (use both),
              ByContainer (use Subject),
              ByApplication (use app supplied params only),
              ByNothing (all connections are equivalent, usually if adapter supports
              reauthentication)-->
              ByContainer


              <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager
              <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager
              java:/TransactionManager
              <!--make the rar deploy! hack till better deployment-->
              jboss.jca:service=RARDeployer

              • 4. Re: JBoss does not see my MySql database
                dferquian

                kuba, thnks for your answer. Unfortunately I couldn't get it to work. Here is my mysql-service.xml file to see if you could give me a hint based on it. Do I have to add something in the login-config.xml file also?
                Thanks in addvance.

                Daniel


                <!-- ==================================================================== -->
                <!-- New ConnectionManager setup for mysql using 2.0.11 driver -->
                <!-- Build jmx-api (build/build.sh all) and view for config documentation -->
                <!-- ==================================================================== -->

                <!-- Include a login module configuration named MySqlDbRealm.
                Update your login-conf.xml, here is an example for a
                ConfiguredIdentityLoginModule:

                <application-policy name = "MySqlDbRealm">

                <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
                <module-option name = "principal">yourprincipal</module-option>
                <module-option name = "userName">yourusername</module-option>
                <module-option name = "password">yourpassword</module-option>
                <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MySqlDS</module-option>
                </login-module>

                </application-policy>

                NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the
                module-option name = "managedConnectionFactoryName"
                must match the object name of the ConnectionManager you are configuring here.
                -->
                <!--uncomment out this line if you are using the MySqlDbRealm above
                MySqlDbRealm
                -->
                <depends optional-attribute-name="ManagedConnectionFactoryName">
                <!--embedded mbean-->

                MySqlDS


                <config-property name="ConnectionURL" type="java.lang.String">jdbc:odbc:ODBCSistemasLegados//localhost:3306/dbSistLeg</config-property>
                <config-property name="DriverClass" type="java.lang.String">sun.jdbc.odbc.JdbcOdbcDriver</config-property>
                <!--set these only if you want only default logins, not through JAAS -->
                <config-property name="UserName" type="java.lang.String"/>
                <config-property name="Password" type="java.lang.String"/>


                <!--Below here are advanced properties -->
                <!--hack-->
                <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper


                <depends optional-attribute-name="ManagedConnectionPool">
                <!--embedded mbean-->

                0
                50
                5000
                15
                <!--criteria indicates if Subject (from security domain) or app supplied
                parameters (such as from getConnection(user, pw)) are used to distinguish
                connections in the pool. Choices are
                ByContainerAndApplication (use both),
                ByContainer (use Subject),
                ByApplication (use app supplied params only),
                ByNothing (all connections are equivalent, usually if adapter supports
                reauthentication)-->
                ByContainer


                <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager
                <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager
                java:/TransactionManager
                <!--make the rar deploy! hack till better deployment-->
                jboss.jca:service=RARDeployer

                • 5. Re: JBoss does not see my MySql database
                  kennedyz

                  1. Copy the mysql-service.xml file into your server's deploy directory.

                  2. Edit the mysql-service.xml file to reflect your database connection information:
                  <config-property name="ConnectionURL" type="java.lang.String">jdbc:mysql://HOSTNAME_OR_IP/DATABASE</config-property>
                  <config-property name="DriverClass" type="java.lang.String">com.mysql.jdbc.Driver</config-property>
                  <!--set these only if you want only default logins, not through JAAS -->
                  <config-property name="UserName" type="java.lang.String">USERNAME</config-property>
                  <config-property name="Password" type="java.lang.String">PASSWORD</config-property>

                  3. Place the library containing the DriverClass into your server's lib directory. (The above xml snippit uses the mysql Connector/J library from http://www.mysql.com/downloads/api-jdbc-stable.html)

                  4. If you are using CMP, put the following lines into the default section of jbosscmp-jdbc.xml file
                  java:/MySqlDS
                  <datasource-mapping>mySQL</datasource-mapping>

                  • 6. Re: JBoss does not see my MySql database
                    cuslenghi

                    Hay que agregar esto en login-config pero no anda
                    Si no en el manual del jboss capitulo 10 explica pero!!!

                    <application-policy name="MySqlDbRealm">

                    <login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule" flag="required">
                    <module-option name="principal"/>
                    <module-option name="userName"/>
                    <module-option name="password"/>
                    <module-option name="managedConnectionFactoryName"> jboss.jca:service=LocalTxCM,name=MySqlDS</module-option>
                    </login-module>

                    </application-policy>

                    • 7. Re: JBoss does not see my MySql database
                      zaphod

                      Hi,

                      I tried the settings below in my jbosscmp-jdbc.xml file but it seems this is not allowed.

                      java:/MySqlDS
                      <datasource-mapping>mySQL</datasource-mapping>


                      ...
                      22:39:29,086 ERROR [XmlFileLoader] File file:/C:/Java/jboss-3.0.3_tomcat-4.1.12/
                      server/default/tmp/deploy/server/default/deploy/ProductEJB.jar/91.ProductEJB.jar
                      !/META-INF/jbosscmp-jdbc.xml process error. Line: 10. Error message:
                      org.xml.sax.SAXParseException: In Element "defaults" ist hier "datasource" nicht
                      zulõssig.
                      at org.apache.crimson.parser.Parser2.error(Parser2.java:3160)
                      at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.consume(
                      ValidatingParser.java:349)
                      at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1317)
                      at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
                      at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
                      at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
                      at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
                      at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
                      at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
                      at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)

                      at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl
                      .java:185)
                      at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:76)
                      at org.jboss.metadata.XmlFileLoader.getDocument(XmlFileLoader.java:257)
                      at org.jboss.metadata.XmlFileLoader.getDocumentFromURL(XmlFileLoader.jav

                      any help would be appreciated,
                      Zaphod