5 Replies Latest reply: Jun 4, 2013 9:15 AM by Randall Hauch RSS

ModeShape JPA using MySql

Tabish Shaikh Newbie

Hello Everyone,

 

I am trying to use ModeShape with MySql and my configuration is as follows

 

***************************************************************

 

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

<configuration xmlns:mode="http://www.modeshape.org/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">

    <mode:sources jcr:primaryType="nt:unstructured">

        <mode:source jcr:name="Cars" mode:classname="org.modeshape.connector.store.jpa.JpaSource"

             mode:model="Simple"

             mode:dialect="org.hibernate.dialect.MySQLDialect"

             mode:driverClassName="com.mysql.jdbc.Driver"

             mode:username="msf"

             mode:password="msf"

             mode:url="mysql://192.168.1.4:3306/jcr?autoReconnect=true"

             mode:maximumConnectionsInPool="1"

             mode:referentialIntegrityEnforced="true"

             mode:largeValueSizeInBytes="10000"

             mode:retryLimit="3"

             mode:compressData="false"

             mode:predefinedWorkspaceNames="workspace1"

             mode:showSql="true"

                mode:autoGenerateSchema="create"

                mode:creatingWorkspacesAllowed="true"

             mode:defaultWorkspaceName="workspace1" />

    </mode:sources>

 

    <mode:mimeTypeDetectors>

        <mode:mimeTypeDetector jcr:name="Detector">

            <mode:description>Standard extension-based MIME type detector</mode:description>

            <mode:classname>org.modeshape.graph.mimetype.ExtensionBasedMimeTypeDetector</mode:classname>

            <mode:classpath></mode:classpath>

            <mode:classpath></mode:classpath>

        </mode:mimeTypeDetector>

    </mode:mimeTypeDetectors>

 

    <mode:repositories>

        <mode:repository jcr:name="Cars">

            <mode:source>Cars</mode:source>

            <jcr:nodeTypes mode:resource="/cars.cnd" />

            <namespaces jcr:primaryType="mode:namespaces">

                <car jcr:primaryType="mode:namespace" mode:uri="http://jboss.org/dna/examples/cars/1.0"/>

            </namespaces>

            <mode:descriptors>

                <myDescriptor mode:value="foo" />

            </mode:descriptors>

        </mode:repository>

    </mode:repositories>

 

</configuration>

 

**********************************************************

 

When I am trying to initialiaze the repository from a Spring test case I get the following error

 

**********************************************************

DEBUG - PersistenceManagerTest.testSpring(22) | Into the test com.indieontech.PersistenceManager@6293df2c

DEBUG - PersistenceManager.init(74) | Initialization of the Persistence Manager................

DEBUG - PersistenceManager.init(81) | Loading Configurations ......................

DEBUG - PersistenceManager.init(99) | Starting Engine ..............

DEBUG - Logger.debug(191) | Properties for Hibernate configuration used for ModeShape JPA Source Cars:

DEBUG - Logger.debug(191) |   hibernate.connection.url = mysql://192.168.1.4:3306/jcr?autoReconnect=true

DEBUG - Logger.debug(191) |   hibernate.connection.max_fetch_depth = 3

DEBUG - Logger.debug(191) |   hibernate.c3p0.max_size = 1

DEBUG - Logger.debug(191) |   hibernate.c3p0.min_size = 0

DEBUG - Logger.debug(191) |   hibernate.cache.provider_class = org.hibernate.cache.NoCacheProvider

DEBUG - Logger.debug(191) |   hibernate.c3p0.timeout = 600

DEBUG - Logger.debug(191) |   hibernate.format_sql = true

DEBUG - Logger.debug(191) |   hibernate.c3p0.validate = false

DEBUG - Logger.debug(191) |   hibernate.connection.password = msf

DEBUG - Logger.debug(191) |   hibernate.connection.username = msf

DEBUG - Logger.debug(191) |   hibernate.hbm2ddl.auto = create

DEBUG - Logger.debug(191) |   hibernate.connection.driver_class = com.mysql.jdbc.Driver

DEBUG - Logger.debug(191) |   hibernate.dialect = org.hibernate.dialect.MySQLDialect

DEBUG - Logger.debug(191) |   hibernate.bytecode.use_reflection_optimizer = false

DEBUG - Logger.debug(191) |   hibernate.connection.provider_class = org.hibernate.connection.C3P0ConnectionProvider

DEBUG - Logger.debug(191) |   hibernate.use_sql_comments = true

DEBUG - Logger.debug(191) |   hibernate.c3p0.idle_test_period = 180

DEBUG - Logger.debug(191) |   hibernate.c3p0.acquire_increment = 1

DEBUG - Logger.debug(191) |   hibernate.c3p0.max_statements = 100

DEBUG - Logger.debug(191) |   hibernate.show_sql = true

DEBUG - Logger.debug(191) |   hibernate.connection.pool_size = 0

WARN - BasicResourcePool$AcquireTask.run(1841) | com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@5b2ddfe4 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:

java.sql.SQLException: No suitable driver

at java.sql.DriverManager.getDriver(DriverManager.java:264)

at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:224)

at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)

at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)

at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)

at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)

at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)

at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)

at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)

at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

WARN - SettingsFactory.buildSettings(144) | Could not obtain connection metadata

java.sql.SQLException: Connections could not be acquired from the underlying database!

at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)

at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)

at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)

at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:78)

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

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

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

at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)

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

at org.modeshape.connector.store.jpa.JpaSource.getConnection(JpaSource.java:1206)

at org.modeshape.graph.connector.RepositoryConnectionPool.newWrappedConnection(RepositoryConnectionPool.java:980)

at org.modeshape.graph.connector.RepositoryConnectionPool.getConnection(RepositoryConnectionPool.java:831)

at org.modeshape.repository.RepositoryLibrary.createConnection(RepositoryLibrary.java:558)

at org.modeshape.graph.Graph.execute(Graph.java:278)

at org.modeshape.graph.Graph$5.process(Graph.java:226)

at org.modeshape.graph.request.RequestBuilder.verifyWorkspace(RequestBuilder.java:72)

at org.modeshape.graph.Graph.useWorkspace(Graph.java:377)

at org.modeshape.graph.Graph.getCurrentWorkspace(Graph.java:352)

at org.modeshape.graph.Graph.getCurrentWorkspaceName(Graph.java:337)

at org.modeshape.jcr.JcrRepository.<init>(JcrRepository.java:744)

at org.modeshape.jcr.JcrEngine.doCreateJcrRepository(JcrEngine.java:435)

at org.modeshape.jcr.JcrEngine.getRepository(JcrEngine.java:271)

at com.indieontech.PersistenceManager.init(PersistenceManager.java:110)

at com.indieontech.PersistenceManagerTest.testSpring(PersistenceManagerTest.java:23)

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

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

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

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

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)

at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)

at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)

at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)

at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)

at org.junit.runners.ParentRunner.run(ParentRunner.java:236)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)

at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)

at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115)

at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102)

at org.apache.maven.surefire.Surefire.run(Surefire.java:180)

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

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

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

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

at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)

at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)

Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)

at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)

at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)

at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)

... 54 more

 

********************************************************

 

I have tried to run it as a standalone app also and the same error occurs....

 

Any tips on how to get this running ? Thanking you all in advance for the help

 

Kind Regards,

Tabish Anwar Shaikh