gpt4 book ai didi

java - TommEE session 持久存储不工作

转载 作者:行者123 更新时间:2023-11-28 22:01:50 27 4
gpt4 key购买 nike

我在 rhel 机器上使用 TomEE plus 1.7.1。我已经为持久性存储设置了 jdbc 存储,以将 session 数据存储在 mysql 数据库中。 jdbc 存储在 rhel 机器上不工作。甚至文件中的持久性也不起作用。以下是我所做的设置。

在/conf/context.xml 中添加了这个

<Manager className="org.apache.catalina.session.PersistentManager"
maxIdleBackup="0">
<Store className="org.apache.catalina.session.JDBCStore"
connectionURL="jdbc:mysql://dbservername:3306/someName?user=[user]&amp;password=[pass]"
driverName="com.mysql.jdbc.Driver"
sessionAppCol="app_name"
sessionDataCol="session_data"
sessionIdCol="session_id"
sessionLastAccessedCol="last_access"
sessionMaxInactiveCol="max_inactive"
sessionTable="TOMCAT_SESSIONS"
sessionValidCol="valid_session"/>
</Manager>

我有一个包含以下内容的 TomEE 启动脚本。第2行与jdbc store相关

export JAVA_OPTS="-Djava.awt.headless=true -Dawt.toolkit=sun.awt.HToolkit"
export CATALINA_OPTS="-Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true"
sh catalina.sh start

在mysql中创建了如下表

created following table
create table tomcat_sessions (
session_id varchar(100) not null primary key,
valid_session char(1) not null,
max_inactive int not null,
last_access bigint not null,
app_name varchar(255),
session_data mediumblob,
KEY kapp_name(app_name)
);

在/lib 中添加了 mysql-connector-java.jar观察到以下错误

观察到的错误-

对于部署在 apache 中的每个应用程序,我都会收到这些错误

SEVERE: Error manager.start()
org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.session.PersistentManager[/tomee]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5499)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1898)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.session.JDBCStore[org.apache.catalina.session.PersistentManager[/tomee]]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.session.PersistentManagerBase.startInternal(PersistentManagerBase.java:864)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 12 more
Caused by: java.lang.NullPointerException
at org.apache.catalina.session.JDBCStore.open(JDBCStore.java:961)
at org.apache.catalina.session.JDBCStore.getConnection(JDBCStore.java:893)
at org.apache.catalina.session.JDBCStore.startInternal(JDBCStore.java:1064)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 14 more



SEVERE: Error manager.start()
org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.session.PersistentManager[/myAppname1]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5499)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1880)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.session.JDBCStore[org.apache.catalina.session.PersistentManager[/myAppname1]]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.session.PersistentManagerBase.startInternal(PersistentManagerBase.java:864)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 12 more
Caused by: java.lang.NullPointerException
at org.apache.catalina.session.JDBCStore.open(JDBCStore.java:961)
at org.apache.catalina.session.JDBCStore.getConnection(JDBCStore.java:893)
at org.apache.catalina.session.JDBCStore.startInternal(JDBCStore.java:1064)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 14 more



SEVERE: Error manager.start()
org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.session.PersistentManager[/myAppname2]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5499)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1880)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.session.JDBCStore[org.apache.catalina.session.PersistentManager[/myAppname2]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.session.PersistentManagerBase.startInternal(PersistentManagerBase.java:864)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 12 more
Caused by: java.lang.NullPointerException
at org.apache.catalina.session.JDBCStore.open(JDBCStore.java:961)
at org.apache.catalina.session.JDBCStore.getConnection(JDBCStore.java:893)
at org.apache.catalina.session.JDBCStore.startInternal(JDBCStore.java:1064)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 14 more


SEVERE: Error manager.start()
org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.session.PersistentManager[/myAppname3]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5499)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1880)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.session.JDBCStore[org.apache.catalina.session.PersistentManager[/myAppname3]]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.session.PersistentManagerBase.startInternal(PersistentManagerBase.java:864)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 12 more
Caused by: java.lang.NullPointerException
at org.apache.catalina.session.JDBCStore.open(JDBCStore.java:961)
at org.apache.catalina.session.JDBCStore.getConnection(JDBCStore.java:893)
at org.apache.catalina.session.JDBCStore.startInternal(JDBCStore.java:1064)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 14 more

最佳答案

不推荐使用 JDBC session 持久性。甚至 Tomcat 手册也不建议这样做。它不稳定、缓慢且容易出错。

驱动程序似乎出了点问题:http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-catalina/7.0.55/org/apache/catalina/session/JDBCStore.java#961

我会首先确保它在您的类路径中。之后,在调试器中设置一个断点并查看实际为 null 的内容。

关于java - TommEE session 持久存储不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36645887/

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