gpt4 book ai didi

java - EhCache "ehcache.disk.store.dir"设置不被接受

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:56:13 32 4
gpt4 key购买 nike

我们在 WebLogic Server 10.3.4 上运行 Spring 3.0.5 Web 应用程序Solaris with Sun JVM 1.6.0_x 64bit 使用 EhCache 2.4.2 作为缓存图书馆。 WLS 被设置为具有 2 个节点的集群,它们都运行在同一物理机,通过标准启动startManagedWebLogic.sh 脚本(不使用 NodeManager/管理控制台)。

在我们的 ehcache.xml 中,我们设置了这样的磁盘存储路径:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
updateCheck="false">

<!-- Location of persistent caches on disk -->
<diskStore path="ehcache.disk.store.dir" />
..

根据 the 2.4 series documentation ofEhCache此设置允许设置 JVM 系统属性,以便指定磁盘存储路径。

系统属性在 startManagedWebLogic.sh 中使用标准 JAVA_OPTIONS 元素:

JAVA_OPTIONS="-Dehcache.disk.store.dir=/var/tmp/EhCache-${SERVER_NAME} <other stuff>"
export JAVA_OPTIONS

SERVER_NAME 在这些之前的同一脚本中定义选项。

在集群节点启动期间,我可以看到正在设置的属性正确(包装以提高可读性):

/usr/jdk/jdk1.6.0_21/bin/java -d64 -server -Xms4096m -Xmx4096m
-XX:PermSize=512m -XX:MaxPermSize=512m -XX:+UseParallelOldGC
-verbose:gc -XX:+PrintGCTimeStamps -Dweblogic.Name=Node2 [..]
-Dehcache.disk.store.dir=/var/tmp/EhCache-Node2 [..]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
weblogic.Server

但是,然后使用该应用程序,我可以看到占位符是没有正确替换,因此使用占位符名称而不是实际路径设置:

2012-08-22 11:52:59,426 DEBUG [net.sf.ehcache.CacheManager] - [Creating new CacheManager with default config]
2012-08-22 11:52:59,429 DEBUG [net.sf.ehcache.CacheManager] - [Configuring ehcache from classpath.]
..
2012-08-22 11:52:59,458 DEBUG [net.sf.ehcache.config.DiskStoreConfiguration] - [Disk Store Path: ehcache.disk.store.dir]
..
2012-08-22 11:52:59,586 DEBUG [net.sf.ehcache.store.DiskStore] - [IOException reading index. Creating new index. ]
2012-08-22 11:52:59,587 DEBUG [net.sf.ehcache.store.DiskStore] - [Index file ehcache.disk.store.dir/bookmarksCountForUserCache.index deleted.]
2012-08-22 11:52:59,588 DEBUG [net.sf.ehcache.store.DiskStore] - [Index file ehcache.disk.store.dir/bookmarksCountForUserCache.index created successfully]
2012-08-22 11:52:59,588 DEBUG [net.sf.ehcache.store.DiskStore] - [Index file dirty or empty. Deleting data file bookmarksCountForUserCache.data]
2012-08-22 11:52:59,597 DEBUG [net.sf.ehcache.store.MemoryStore] - [Initialized net.sf.ehcache.store.LruMemoryStore for bookmarksCountForUserCache]
2012-08-22 11:52:59,600 DEBUG [net.sf.ehcache.store.LruMemoryStore] - [bookmarksCountForUserCache Cache: Using SpoolingLinkedHashMap implementation]
2012-08-22 11:52:59,601 DEBUG [net.sf.ehcache.Cache] - [Initialised cache: bookmarksCountForUserCache]

在我的 WLS 域内的文件系统中,我可以看到一个新文件夹ehcache.disk.store.dir 被创建,所以路径被解释为相对路径。

我也试过使用普通字符串ehcache.disk.store.dir使用标准模式 ${ehcache.disk.store.dir},但这仅更改了要使用 ${..} 创建的文件夹名称。

有没有办法使用系统指定每个节点的磁盘存储路径所有节点的属性和相同的 EhCache 配置?

我们的 ehcache.xml 位于已部署的 .war 文件中,因此将是所有集群节点都一样。更改应用程序代码不是一种选择,因为我们已经结束了此版本的代码卡住。但是,我可以调整服务器的启动设置以如上所述设置系统属性。

感谢您的帮助!

最佳答案

使用 -Dehcache.disk.store.dir 系统属性应该仍然有效。
我在通过 hibernate 配置设置属性时也遇到了问题。

关于java - EhCache "ehcache.disk.store.dir"设置不被接受,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12087935/

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