问题
I have deployed Jackrabbit 2.6.4 in Glassfish 4 using jackrabbit-jca-2.6.4.rar.
Everything works when I use the following configuration (Derby via JDBC):
<PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager">
<param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
<param name="schemaObjectPrefix" value="${wsp.name}_"/>
</PersistenceManager>
but when I switch to this (Mysql via a datasource):
<PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager">
<param name="url" value="jdbc/MySQLDataSource"/>
<param name="driver" value="javax.naming.InitialContext"/>
<param name="schemaObjectPrefix" value="${wsp.name}_"/>
</PersistenceManager>
No Runtime properties Database Vendor : null Create Tables at Deploy : false Delete Tables at Undeploy : false into class com.pepedigital.omakase.template.boundary.TemplateManager: Lookup failed for 'java:comp/env/jcr/repository' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:717) at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:484) at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:170) at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:138) ... 70 more Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/jcr/repository' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.CommunicationException: Communication exception for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming, com.sun.enterprise.naming.logicalName=java:comp/env/jcr/repository} [Root exception is java.lang.RuntimeException: javax.resource.ResourceException: Failed to create repository: Cannot instantiate persistence manager org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager]] at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438) at javax.naming.InitialContext.lookup(InitialContext.java:411) at javax.naming.InitialContext.lookup(InitialContext.java:411) at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:613) ... 73 more Caused by: javax.naming.CommunicationException: Communication exception for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming, com.sun.enterprise.naming.logicalName=java:comp/env/jcr/repository} [Root exception is java.lang.RuntimeException: javax.resource.ResourceException: Failed to create repository: Cannot instantiate persistence manager org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager] at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:513) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438) at javax.naming.InitialContext.lookup(InitialContext.java:411) at javax.naming.InitialContext.lookup(InitialContext.java:411) at com.sun.enterprise.naming.util.JndiNamingObjectFactory.create(JndiNamingObjectFactory.java:90) at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:745) at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:715) at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:159) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:471) ... 77 more Caused by: java.lang.RuntimeException: javax.resource.ResourceException: Failed to create repository: Cannot instantiate persistence manager org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager at com.sun.enterprise.resource.naming.ConnectorObjectFactory.getObjectInstance(ConnectorObjectFactory.java:200) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321) at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:527) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:487) ... 85 more Caused by: javax.resource.ResourceException: Failed to create repository: Cannot instantiate persistence manager org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager at org.apache.jackrabbit.jca.JCAManagedConnectionFactory.createRepository(JCAManagedConnectionFactory.java:220) at org.apache.jackrabbit.jca.JCAManagedConnectionFactory.createConnectionFactory(JCAManagedConnectionFactory.java:153) at com.sun.enterprise.resource.naming.ConnectorObjectFactory.getObjectInstance(ConnectorObjectFactory.java:156) ... 88 more ]]
I have configured a Mysql JDBC Connection Pool and JDBC Connection Resource (jdbc/MySQLDataSource) in Glassfish and placed mysql-connector-java-5.1.26-bin.jar in the domain/lib directory. I can successfully ping the database via the Glassfish JDBC Connection Pool page in the Admin UI.
Am I missing something in the JackRabbit PersistanceManager configuration?
UPDATE 1
If I don't use my datasource and instead use a JDBC URL in my PersistanceManager configuration to connect to the database it works as expected.
回答1:
It turns out that the Mysql JDBC connection pool was not configured correctly.
In order to get it to work I had to set the following properties:
- User
- Password
- DatabaseName
- ServerName
- Url
- URL
I also had to repeat the database and server name in the Url and URL fields e.g.
jdbc:mysql://127.0.0.1:3306/db_name
At this point I'm not sure why there is a Url and a URL property but setting both of them to the above URL worked.
来源:https://stackoverflow.com/questions/19644294/cannot-instantiate-persistence-manager-org-apache-jackrabbit-core-persistence-po