4 Replies Latest reply on Dec 4, 2016 1:29 PM by andreamorgar

    Conexión MySQL y JBoss 7.1.1

    josemo

      Buenos días,

       

      Desde hace ya un tiempo arrastro el siguiente problema que no me deja continuar con mi desarrollo... Intento conectar una base de datos MySQL (llamada 'login') y un servidor JBoss 7.1.1 en el entorno Eclipse IDE en Windows XP.

       

      Les adjunto los pasos que he realizado para su valoración.

       

      El archivo standalone.xml

       

      <datasources>

                      <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">

                          <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>

                          <driver>h2</driver>

                          <security>

                              <user-name>sa</user-name>

                              <password>sa</password>

                          </security>

                      </datasource>

                      <datasource jta="true" jndi-name="java:jboss/datasources/login" pool-name="login" enabled="true" use-java-context="true" use-ccm="true">

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

                          <driver>mysql</driver>

                          <security>

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

                          </security>

                      </datasource>

                      <drivers>

                          <driver name="h2" module="com.h2database.h2">

                              <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>

                          </driver>

                          <driver name="mysql" module="com.mysql">

                              <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>

                          </driver>

                      </drivers>

                  </datasources>

       

      Duda 1. ¿La password de la base de datos es una cadena vacía... está bien que se omita? Lo pongo pero JBoss al cargar elimina el tag de <password>

       

      A continuación, en el directorio modules/com/mysql/main pegué el .jar de MySQL (mysql-connector-java-5.0.8-bin.jar), se me creó automáticamente el .index de ese .jar y, además, creé el archivo module.xml que pego abajo:

       

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

      <module xmlns="urn:jboss:module:1.0" name="mysql">

        <resources>

          <resource-root path="mysql-connector-java-5.0.8-bin.jar"/>

        </resources>

        <dependencies>

                <module name="javax.api"/>

                <module name="javax.transaction.api"/>

                <module name="javax.servlet.api" optional="true"/>

        </dependencies>

      </module>

       

      El método que tengo de conexión en Java es el siguiente...

       

      private Connection cnn = null;

       

      public Connection getConexion (String strDs) throws Exception {

                    try {

                              InitialContext initialContext = new InitialContext();

                              DataSource ds = (DataSource) initialContext.lookup(strDs.toString());

                              try {

                                        cnn = ds.getConnection();                        // Línea en la que falla...

                              } catch (SQLException sqle) {

                                        System.out.println(

                                                            "Error en el método getConexion() de la clase Proceso: " + strDs +

                                                                                sqle.getMessage());

                                        throw sqle;

                              }

                    } catch (NamingException ne) {

                              System.out.println(

                                                  "Error en el método getConexion() de la clase Proceso: " +

                                                                      ne.getMessage());

                              throw ne;

                    }

                    return cnn;

                }

       

      Pego también la consola:

       

      15:12:18,218 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA

      15:12:19,015 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA

      15:12:19,171 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting

      15:12:23,296 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)

      15:12:23,328 INFO  [org.xnio] XNIO Version 3.0.3.GA

      15:12:23,328 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA

      15:12:23,343 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA

      15:12:23,609 INFO  [org.jboss.as.configadmin] JBAS016200: Activating ConfigAdmin Subsystem

      15:12:23,671 INFO  [org.jboss.as.clustering.infinispan] JBAS010280: Activating Infinispan subsystem.

      15:12:23,703 INFO  [org.jboss.as.naming] JBAS011800: Activating Naming Subsystem

      15:12:23,734 INFO  [org.jboss.as.osgi] JBAS011940: Activating OSGi Subsystem

      15:12:23,906 INFO  [org.jboss.as.security] JBAS013101: Activating Security Subsystem

      15:12:23,937 INFO  [org.jboss.as.webservices] JBAS015537: Activating WebServices Extension

      15:12:24,203 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers

      15:12:25,468 INFO  [org.jboss.as.connector] (MSC service thread 1-2) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)

      15:12:25,484 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]

      15:12:25,953 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-2) Arrancando Coyote HTTP/1.1 en puerto http-localhost-127.0.0.1-8080

      15:12:27,296 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]

      15:12:27,343 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-1) JBoss Web Services - Stack CXF Server 4.0.2.GA

      15:12:27,609 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on /127.0.0.1:9999

      15:12:27,687 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) JBAS015012: Started FileSystemDeploymentService for directory C:\Documents and Settings\Administrador\Mis documentos\jboss-as-7.1.1.Final\standalone\deployments

      15:12:27,750 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on localhost/127.0.0.1:4447

      15:12:27,859 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found Login_7.1.war in deployment directory. To trigger deployment create a file called Login_7.1.war.dodeploy

      15:12:28,125 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report

      JBAS014775:    New missing/unsatisfied dependencies:

            service jboss.jdbc-driver.com_mysql_jdbc_Driver (missing) dependents: [service jboss.data-source.java:jboss/datasources/login] ¿De dónde sale esto?

       

       

      15:12:28,171 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "Login_7.1.war"

      15:12:29,390 INFO  [org.jboss.web] (MSC service thread 1-1) JBAS018210: Registering web context: /Login_7.1

      15:12:29,406 INFO  [org.jboss.as] (MSC service thread 1-2) JBAS015951: Admin console listening on http://127.0.0.1:9990

      15:12:29,406 ERROR [org.jboss.as] (MSC service thread 1-2) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 12110ms - Started 175 of 255 services (2 services failed or missing dependencies, 76 services are passive or on-demand)

      15:12:29,609 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "Login_7.1.war"

      15:12:44,250 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Login_7.1].[jsp]] (http-localhost-127.0.0.1-8080-1) Servlet.service() para servlet jsp lanzó excepción: java.lang.NoSuchMethodError: Metodos.bbdd.getConexion(Ljava/lang/String;)V

                at org.apache.jsp.Validacion_jsp._jspService(Validacion_jsp.java:68)

                at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) [jbossweb-7.0.13.Final.jar:]

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) [jbossweb-7.0.13.Final.jar:]

                at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326) [jbossweb-7.0.13.Final.jar:]

                at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253) [jbossweb-7.0.13.Final.jar:]

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

                at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_15]

       

       

      15:15:43,515 INFO  [org.jboss.as.osgi] (MSC service thread 1-1) JBAS011942: Stopping OSGi Framework

      15:15:43,671 INFO  [org.jboss.as.logging] JBAS011503: Restored bootstrap log handlers

      15:15:43,984 INFO  [com.arjuna.ats.jbossatx] ARJUNA032018: Destroying TransactionManagerService

      15:15:43,984 INFO  [com.arjuna.ats.jbossatx] ARJUNA032014: Stopping transaction recovery manager

      15:15:44,000 INFO  [org.jboss.as.server.deployment] JBAS015877: Stopped deployment Login_7.1.war in 510ms

      15:15:44,000 INFO  [org.jboss.as.controller] JBAS014774: Service status report

      JBAS014776:    Newly corrected services:

            service jboss.jdbc-driver.com_mysql_jdbc_Driver (new available) ¿Por qué cuando apago el servidor aparece este mensaje?

       

       

      15:15:44,000 INFO  [org.jboss.as] JBAS015950: JBoss AS 7.1.1.Final "Brontes" stopped in 513ms

       

      Espero que me puedan ayudar con las 'pistas' que les estoy dando.

       

      Muchas gracias, un saludo.

        • 1. Re: Conexión MySQL y JBoss 7.1.1
          wdfink

          First what I see is that the module.xml does not match the directory and the references.

          See this document how to add the module.

           

          Also you should ask in English which might be easier for us to help you

          1 of 1 people found this helpful
          • 2. Re: Conexión MySQL y JBoss 7.1.1
            josemo

            I have seen the web that you say and I have copied it, but I have the same problem...

             

            I have questions:

             

                 1. What do I do in the META-INF directory? Where is it?

                 2. Is neccesary that I declare the datasource again in the file domain.xml?

             

            My module.xml is in the directory: C:\Documents and Settings\Administrador\Mis documentos\jboss-as-7.1.1.Final\modules\com\mysql\main

            It is together the MySQL connector and his .INDEX.

             

            standalone.xml

            <datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS">

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

                                <driver>com.mysql</driver>

                                <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>

                                <pool>

                                    <min-pool-size>10</min-pool-size>

                                    <max-pool-size>100</max-pool-size>

                                    <prefill>true</prefill>

                                </pool>

                                <security>

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

                                </security>

                                <statement>

                                    <prepared-statement-cache-size>32</prepared-statement-cache-size>

                                    <share-prepared-statements>true</share-prepared-statements>

                                </statement>

                            </datasource>

             

            and my module.xml is the same that the module.xml of your web.

             

            My console says:

            JBAS014775:    New missing/unsatisfied dependencies:

                  service jboss.jdbc-driver.com_mysql (missing) dependents: [service jboss.data-source.java:jboss/datasources/MySqlDS]

             

            But when I stop it says:

            JBAS014776:    Newly corrected services:

                  service jboss.jdbc-driver.com_mysql (new available)

                  service jboss.server.controller.management.security_realm.ApplicationRealm.properties_authentication (new available)

             

            Sorry for my poor English level.

             

            Thanks,

            yours sincerely.

            • 3. Re: Conexión MySQL y JBoss 7.1.1
              josemo

              Thanks for your answer, finally the problem was the mysql connector, I changed the version and run it.

              • 4. Re: Conexión MySQL y JBoss 7.1.1
                andreamorgar

                Can you tell me what version did you use to run it????? I have the same error, thanks