3 Replies Latest reply on May 28, 2012 6:58 AM by sfcoy

    why deploy as7 look for a not defined datasource jdbc:h2:mem:mydb

    alesky78

      hi guys

      i'm try to let my application to start under jboss as7

       

      my application use jpa with hibernate as provider to connect to databases...

      it use spring to get the connection that is obtained directly by jdbs definde in spring and iniected in the entity manager

       

      but when application start to be deployed it look for jdbc:h2:mem:mydb resource...

      in my application is not defined this resource in any point!

      i think that is the  example datasource defined in jboss when it started

       

      any idea about this?

       

      15:28:00,003 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-3) HHH000231: Schema export unsuccessful: java.sql.SQLException: No suitable driver found for jdbc:h2:mem:mydb

                at java.sql.DriverManager.getConnection(Unknown Source) [rt.jar:1.6.0_31]

                at java.sql.DriverManager.getConnection(Unknown Source) [rt.jar:1.6.0_31]

                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 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(Unknown Source) [rt.jar:1.6.0_31]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_31]

                at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_31]

        • 1. Re: why deploy as7 look for a not defined datasource jdbc:h2:mem:mydb
          jaikiran

          Is there any persistence.xml or hibernate.properties in your application package? What does it look like?

          • 2. Re: why deploy as7 look for a not defined datasource jdbc:h2:mem:mydb
            alesky78

            yes there is is in one of my jar module and it take care about the configuration of the entity manager

             

            but the connection is injected by spring

             

            that are the configuration files:

             

            for the persistence unit:

             

            <persistence version="1.0"

                      xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence              http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

                      <persistence-unit name="co-pu" transaction-type="RESOURCE_LOCAL">

                                <provider>org.hibernate.ejb.HibernatePersistence</provider>

                                <properties>

                                          <property name="hibernate.hbm2ddl.auto" value="no" />

                                          <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />

                                          <property name="hibernate.show_sql" value="true" />

                                          <property name="hibernate.format_sql" value="false" />

                                          <property name="hibernate.use_sql_comments" value="false" />

                                          <property name="hibernate.default_schema" value="RBS"/>

                                          <property name="hibernate.query.substitutions" value="true 1, false 0" />

                                </properties>

                      </persistence-unit>

            </persistence>

             

            and this is my spring file that configure thje entity manager

             

             

            <bean id="coDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">

                    <property name="driverClassName" value="${co.db.driver}"/>

                    <property name="url" value="${co.db.url}"/>

                    <property name="username" value="${co.db.username}"/>

                    <property name="password" value="${co.db.password}"/>

                </bean>

             

                      <bean id="coEntityManagerFactory"

                                class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

                                <property name="persistenceXmlLocation" value="${co.pu.location}" />

                                <property name="persistenceUnitName" value="co-pu" />

                                <property name="dataSource" ref="coDataSource" />

                                <property name="jpaVendorAdapter">

                                          <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">

                                                    <property name="showSql" value="true" />

                                                    <property name="generateDdl" value="false" />

                                                    <property name="databasePlatform" value="${co.db.dialect}" />

                                          </bean>

                                </property>

                      </bean>

            • 3. Re: why deploy as7 look for a not defined datasource jdbc:h2:mem:mydb
              sfcoy

              I think you need to rename your persistence.xml file to (say) spring-persistence.xml so that Spring is not fighting the JEE6 container over who is managing it.

              1 of 1 people found this helpful