0 Replies Latest reply on Aug 21, 2012 1:33 AM by shuo li

    JBOSS AS7,SPRING MVC,MYSQLDATASOURCE

    shuo li Newbie

      I use the JBOSS of ECLIPSE plugin, create a  SPRING MVC project:

       

      1.jpg

      After that, I was JBOSS AS 7 server standalone \ configuration \ standalone.xml  create a datasource.

       

             <datasources>

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

                          <connection-url>jdbc:mysql://localhost:3306/activiti?useUnicode=true&amp;characterEncoding=UTF-8</connection-url>

                          <driver>mysql</driver>

                          <security>

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

                              <password>123456</password>

                          </security>

                      </datasource>

                      <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>

                      <drivers>

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

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

                          </driver>

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

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

                          </driver>

                      </drivers>

              </datasources>

       

      After that, I modified the spring-quickstart-ds.xml datasource,look like this:

       

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

      <!-- This is an unmanaged datasource. It should be used for proofs of concept

         or testing only. It uses H2, an in memory database that ships with JBoss

         AS. -->

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

         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">

         <!-- The datasource is bound into JNDI at this location. We reference

            this in META-INF/persistence.xml -->

         <datasource jndi-name="java:jboss/datasources/SpringQuickstartDS"

            pool-name="mysqlds" enabled="true"

            use-java-context="true">

            <connection-url>jdbc:mysql://localhost:3306/activiti?useUnicode=true&amp;characterEncoding=UTF-8</connection-url>

            <driver>mysql</driver>

            <security>

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

               <password>123456</password>

            </security>

         </datasource>

      </datasources>

       

      After that,in  the jboss-deployment-structure.xml ,  I increased a module like : <module name="com.mysqldatabase.mysql"/>

      2.jpg

       

      last ,  I start  service.an error like

       

      13:30:53,796 INFO  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-1) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider

      13:30:54,015 WARN  [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (MSC service thread 1-1) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: Could not create connection

                at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:277)

                at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:235)

                at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManagedConnectionPool.java:761)

                at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.getConnection(SemaphoreArrayListManagedConnectionPool.java:343)

                at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:397)

                at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:365)

                at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:329)

                at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:368)

                at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:464)

                at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:129)

                at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:67) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:253) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:119) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

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

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

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

                at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_29]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_29]

                at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_29]

      Caused by: java.sql.SQLException: java.lang.NoClassDefFoundError: com/mysql/jdbc/authentication/Sha256PasswordPlugin

                at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074) [mysql-connector-java-5.1.21.jar:]

                at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988) [mysql-connector-java-5.1.21.jar:]

                at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974) [mysql-connector-java-5.1.21.jar:]

                at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919) [mysql-connector-java-5.1.21.jar:]

                at com.mysql.jdbc.Util.handleNewInstance(Util.java:435) [mysql-connector-java-5.1.21.jar:]

                at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399) [mysql-connector-java-5.1.21.jar:]

                at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334) [mysql-connector-java-5.1.21.jar:]

                at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:249)

                ... 30 more

       

       

      13:30:54,093 WARN  [org.hibernate.engine.jdbc.internal.JdbcServicesImpl] (MSC service thread 1-1) HHH000342: Could not obtain connection to query metadata : javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/SpringQuickstartDS

      13:30:54,109 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.persistenceunit."springmvc.war#primary": org.jboss.msc.service.StartException in service jboss.persistenceunit."springmvc.war#primary": Failed to start service

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_29]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_29]

                at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_29]

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: primary] Unable to build EntityManagerFactory

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)

                at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)

                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)

                at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                ... 3 more

      Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set

                at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:97)

                at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:67)

                at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:172)

                at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)

                at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)

                at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270)

                at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266)

                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735)

                at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)

                ... 9 more

       

       

      13:30:54,156 INFO  [org.jboss.as] (MSC service thread 1-1) JBAS015951: Admin console listening on http://127.0.0.1:9990

      13:30:54,156 ERROR [org.jboss.as] (MSC service thread 1-1) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 9422ms - Started 275 of 467 services (114 services failed or missing dependencies, 76 services are passive or on-demand)

      13:30:54,375 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "springmvc.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"springmvc.war#primary\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"springmvc.war#primary\": Failed to start service"}}

      13:30:54,453 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010409: Unbound data source [jboss/datasources/SpringQuickstartDS]

      13:30:54,531 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment springmvc.war in 162ms

      13:30:54,531 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report

      JBAS014777:   Services which failed to start:      service jboss.persistenceunit."springmvc.war#primary": org.jboss.msc.service.StartException in service jboss.persistenceunit."springmvc.war#primary": Failed to start service

       

       

      13:30:54,546 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"springmvc.war#primary\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"springmvc.war#primary\": Failed to start service"}}}}

       

       

       

      please help me!!!!thank you