我使用jackrabbit-jca-2.6.4.rar在Glassfish 4中部署了Jackrabbit 2.6.4。
当我使用以下配置(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>
但是当我切换到这个(通过数据源的Mysql)时:
<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>
没有运行时属性 数据库供应商:null 在部署时创建表:false 删除Undeploy中的表:false到类com.pepedigital.omakase.template.boundary.TemplateManager:查找失败的&#39; java:comp / env / jcr / repository&#39;在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) 在org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:138) ......还有70多个 引起:javax.naming.NamingException:查找失败的&#39; java:comp / env / jcr / repository&#39;在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异常是javax.naming.CommunicationException: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异常是java.lang.RuntimeException:javax.resource.ResourceException:无法创建存储库:无法实例化持久性管理器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) 在javax.naming.InitialContext.lookup(InitialContext.java:411) 在javax.naming.InitialContext.lookup(InitialContext.java:411) at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:613) ......还有73个 引起:javax.naming.CommunicationException: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} [根异常是java.lang.RuntimeException:javax.resource.ResourceException:无法创建存储库:无法实例化持久性管理器org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager] 在com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:513) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438) 在javax.naming.InitialContext.lookup(InitialContext.java:411) 在javax.naming.InitialContext.lookup(InitialContext.java:411) at com.sun.enterprise.naming.util.JndiNamingObjectFactory.create(JndiNamingObjectFactory.java:90) 在com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:745) at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:715) 在com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:159) 在com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:471) ......还有77个 引起:java.lang.RuntimeException:javax.resource.ResourceException:无法创建存储库:无法实例化持久性管理器org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager at com.sun.enterprise.resource.naming.ConnectorObjectFactory.getObjectInstance(ConnectorObjectFactory.java:200) 在javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321) at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:527) 在com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:487) ......还有85个 引起:javax.resource.ResourceException:无法创建存储库:无法实例化持久性管理器org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager 在org.apache.jackrabbit.jca.JCAManagedConnectionFactory.createRepository(JCAManagedConnectionFactory.java:220) 在org.apache.jackrabbit.jca.JCAManagedConnectionFactory.createConnectionFactory(JCAManagedConnectionFactory.java:153) at com.sun.enterprise.resource.naming.ConnectorObjectFactory.getObjectInstance(ConnectorObjectFactory.java:156) ......还有88个 ]
我在Glassfish中配置了Mysql JDBC连接池和JDBC连接资源(jdbc / MySQLDataSource),并在域/ lib目录中放置了mysql-connector-java-5.1.26-bin.jar。我可以通过Admin UI中的Glassfish JDBC连接池页面成功ping数据库。
我是否遗漏了JackRabbit PersistanceManager配置中的内容?
更新1
如果我不使用我的数据源,而是使用我的PersistanceManager配置中的JDBC URL连接到数据库,它会按预期工作。
答案 0 :(得分:0)
事实证明,Mysql JDBC连接池配置不正确。
为了让它工作,我必须设置以下属性:
我还必须在Url和URL字段中重复数据库和服务器名称,例如
JDBC:MySQL的://127.0.0.1:3306 / DB_NAME
此时我不确定为什么有Url和URL属性,但将它们都设置为上述URL。