10 Replies Latest reply on Sep 27, 2013 4:16 PM by Markus Ebel

    No suitable driver found for jdbc:mysql://localhost:3306/test

    pulsedrone Newbie

      hello,  im using JBOSS 7.1.1 and mysql connector 5.1.24. I googled a lot to find a solution for my problem, but all i found couldnt help solving this problem. Here is my standalone.xml:

       

      {code:xml}

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

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

                          <driver>mysql</driver>

                          <security>

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

                              <password>root</password>

                          </security>

                          <validation>

                              <validate-on-match>false</validate-on-match>

                              <background-validation>false</background-validation>

                          </validation>

                          <statement>

                              <share-prepared-statements>false</share-prepared-statements>

                          </statement>

                      </datasource>

                      <drivers>

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

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

      {code}

       

      Then the module.xml:

       

      {code:xml}

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

      <module xmlns="urn:jboss:module:1.1" name="com.mysql" slot="main">

        <resources>

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

        </resources>

          <dependencies>

            <module name="javax.api"/>

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

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

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

          </dependencies>

      </module>

      {code}

       

      the hibernate.cfg.xml:

       

      {code:xml}

      <?xml version='1.0' encoding='utf-8'?>

      <!DOCTYPE hibernate-configuration PUBLIC

        "-//Hibernate/Hibernate Configuration DTD//EN"

        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

       

       

       

      <hibernate-configuration>

       

        <session-factory>

       

       

        <!-- User/Password -->

        <property name="connection.username">root</property>

        <property name="connection.password">root</property>

       

        <!-- SQLSERVER -->

        <property name="hibernate.current_session_context_class">thread</property>

                          <property name="connection.driver_class">com.mysql.jdbc.Driver</property>

                          <property name="connection.url">jdbc:mysql://localhost:3306/test</property>

                          <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

        <property name="connection.pool_size">5</property>

       

        </session-factory>

       

      </hibernate-configuration>

      {code}

       

      i createted a Folder in JBOSSHOME/modues/mysql/main with the module.xml and the connector jar inside as overall mentioned. But i always got the same exception:

       

      {code}

      11:30:30,374 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (http-localhost-127.0.0.1-8080-1) HHH000231: Schema export unsuccessful: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test

                at java.sql.DriverManager.getConnection(DriverManager.java:602) [classes.jar:1.6.0_51]

                at java.sql.DriverManager.getConnection(DriverManager.java:154) [classes.jar:1.6.0_51]

                at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:173) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.tool.hbm2ddl.DatabaseExporter.<init>(DatabaseExporter.java:52) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:368) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:305) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:294) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:452) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at MyApp.WebApp.util.HibernateUtil.<clinit>(HibernateUtil.java:26) [classes:]

                at MyApp.WebApp.model.Member.save(Member.java:152) [classes:]

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [classes.jar:1.6.0_51]

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [classes.jar:1.6.0_51]

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [classes.jar:1.6.0_51]

                at java.lang.reflect.Method.invoke(Method.java:597) [classes.jar:1.6.0_51]

                at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.13.Final.jar:]

                at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]

                at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]

                at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.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.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [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.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                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(Thread.java:680) [classes.jar:1.6.0_51]

       

      11:30:30,393 INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] (http-localhost-127.0.0.1-8080-1) HHH000230: Schema export complete

      11:30:30,457 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-localhost-127.0.0.1-8080-1) SQL Error: 0, SQLState: 08001

      11:30:30,458 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-localhost-127.0.0.1-8080-1) No suitable driver found for jdbc:mysql://localhost:3306/test

      11:30:30,461 WARNUNG [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http-localhost-127.0.0.1-8080-1) #{Member.save}: org.hibernate.exception.JDBCConnectionException: Could not open connection: javax.faces.FacesException: #{Member.save}: org.hibernate.exception.JDBCConnectionException: Could not open connection

                at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.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.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [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.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                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(Thread.java:680) [classes.jar:1.6.0_51]

      Caused by: javax.faces.el.EvaluationException: org.hibernate.exception.JDBCConnectionException: Could not open connection

                at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.1.7-jbossorg-2.jar:]

                ... 24 more

      Caused by: org.hibernate.exception.JDBCConnectionException: Could not open connection

                at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:131) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:304) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1263) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at MyApp.WebApp.model.Member.save(Member.java:154) [classes:]

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [classes.jar:1.6.0_51]

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [classes.jar:1.6.0_51]

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [classes.jar:1.6.0_51]

                at java.lang.reflect.Method.invoke(Method.java:597) [classes.jar:1.6.0_51]

                at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.13.Final.jar:]

                at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]

                at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]

                at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.7-jbossorg-2.jar:]

                at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                ... 25 more

      Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test

                at java.sql.DriverManager.getConnection(DriverManager.java:602) [classes.jar:1.6.0_51]

                at java.sql.DriverManager.getConnection(DriverManager.java:154) [classes.jar:1.6.0_51]

                at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:173) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:276) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                ... 40 more

       

      {code}

       

      i  tried anothe version of hibernate.cfg.xml but same error:

       

      {code:xml}

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

      <!DOCTYPE hibernate-configuration PUBLIC

        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"

        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

      <hibernate-configuration>

          <session-factory>

              <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

              <property name="hibernate.connection.password">root</property>

              <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>

              <property name="hibernate.connection.username">root</property>

              <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

          </session-factory>

      </hibernate-configuration>


      {code}

       

      plus,i got the connector inside WEB-INF/lib and added this to build path.

      My anyone help??

       

      i now tried this over console:

      {quote}

      ./jboss-cli.sh --connect --controller=10.100.100.12:9999

      org.jboss.as.cli.CliInitializationException: Failed to connect to the controller

                at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:229)

                at org.jboss.as.cli.impl.CliLauncher.main(CliLauncher.java:207)

                at org.jboss.as.cli.CommandLineMain.main(CommandLineMain.java:34)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:606)

                at org.jboss.modules.Module.run(Module.java:260)

                at org.jboss.modules.Main.main(Main.java:291)

      Caused by: org.jboss.as.cli.CommandLineException: The controller is not available at 10.100.100.12:9999

                at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:639)

                at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:613)

                at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:227)

                ... 8 more

      {quote}

      i should say that im using a mac osx 10.8 and i tried jdk 1.7 25 and also 1.6 ..nothing works

       

      ok..now i have seen something interresting {quote}Also, the jar file must have a META-INF/services/java.sql.Driver file. {quote}

       

      Could someone please explian the content of this file...??