gpt4 book ai didi

java - PersistenceManager 无法连接到数据库

转载 作者:行者123 更新时间:2023-12-02 10:53:45 25 4
gpt4 key购买 nike

当尝试运行使用 Jackrabbit(本地在 Tomcat7 上)的应用程序时,由于任何原因它无法连接到数据库。与数据库的连接可以通过具有相同凭据的常规 Java 应用程序进行。如何调查连接问题?有个问题Cannot instantiate persistence manager org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager但没有解释。

数据库连接配置:

<PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="url" value="jdbc:mysql://localhost:3306/repo"/>
<param name="databaseType" value="mysql"/>
<param name="user" value="admin" />
<param name="password" value="password11.." />
<param name="schemaObjectPrefix" value="${wsp.name}_"/>
<param name="externalBLOBs" value="true"/>
</PersistenceManager>

错误输出:

[localhost-startStop-1] INFO org.apache.jackrabbit.core.RepositoryImpl - Starting repository...
[localhost-startStop-1] INFO org.apache.jackrabbit.core.fs.local.LocalFileSystem - LocalFileSystem initialized at path jackrabbit\repository
[localhost-startStop-1] INFO org.apache.jackrabbit.core.fs.local.LocalFileSystem - LocalFileSystem initialized at path jackrabbit\version
Tue Aug 21 10:46:47 CEST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
[localhost-startStop-1] ERROR org.apache.jackrabbit.core.RepositoryImpl - failed to start Repository: Cannot instantiate persistence manager org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager
javax.jcr.RepositoryException: Cannot instantiate persistence manager org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager
at org.apache.jackrabbit.core.RepositoryImpl.createPersistenceManager(RepositoryImpl.java:1379)
at org.apache.jackrabbit.core.RepositoryImpl.createVersionManager(RepositoryImpl.java:512)
at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:313)
at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:615)
at org.apache.jackrabbit.core.TransientRepository$3.getRepository(TransientRepository.java:250)
at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:280)
at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:376)
at org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:144)
at org.omilab.services.repo.service.JackRabbitRepositoryProvider.<init>(JackRabbitRepositoryProvider.java:60)
at org.omilab.services.repo.service.JackRabbitRepositoryProvider.getInstance(JackRabbitRepositoryProvider.java:41)
at org.omilab.services.repo.service.JackRabbitConnector.<init>(JackRabbitConnector.java:45)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at codes.thischwa.c5c.ConnectorServlet.init(ConnectorServlet.java:79)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1282)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1195)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1085)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5318)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5610)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server.)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.apache.jackrabbit.core.util.db.ConnectionHelper.getExtraNameCharacters(ConnectionHelper.java:187)
at org.apache.jackrabbit.core.util.db.ConnectionHelper.prepareDbIdentifier(ConnectionHelper.java:142)
at org.apache.jackrabbit.core.persistence.pool.BundleDbPersistenceManager.init(BundleDbPersistenceManager.java:542)
at org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager.init(MySqlPersistenceManager.java:51)
at org.apache.jackrabbit.core.RepositoryImpl.createPersistenceManager(RepositoryImpl.java:1375)
... 33 more

编辑1:

在使用相同 Maven 构建的同一个 Tomcat 上,这个简单的应用程序可以连接到相同的数据库:

<%@ page import="java.sql.*"%>
<html>
<head>
<title>DB</title>
</head>
<body>
<h1>DB connectivity test!</h1>

<%
String db = "repo";
String user = "admin";
String password = "password11..";
try {
java.sql.Connection con;
Class.forName("org.gjt.mm.mysql.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/"+db, user, password);
out.println (db+ " database successfully opened.");
}
catch(SQLException e) {
out.println("SQLException caught: " +e.getMessage());
}
%>


</body>

最佳答案

我已经解决了这个问题。Maven 正在将旧版本的 mysql 连接器附加到此应用程序,该连接器本应兼容,但无法正常工作。

关于java - PersistenceManager 无法连接到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51947249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com