gpt4 book ai didi

tomcat - 具有使用多个数据源的 spring 安全核心的 Grails 3.1.8

转载 作者:行者123 更新时间:2023-11-28 21:51:43 26 4
gpt4 key购买 nike

我遇到了 grails spring-security-core 插件/spring-ldap 插件的问题。这是我的第一篇文章 link , 和完整的 stacktrace .这是问题所在:

我有一个带有多个数据源和 spring-security-core 插件的应用程序

`build.gradle ` `compile "org.grails.plugins:spring-security-core:3.1.1"`

在 tomcat 服务器中运行这个应用程序,它运行得很好,但是当我尝试在我自己的 tomcat 中部署 war 文件时,它失败并出现错误(在链接中),我一直试图首先找到导致它的原因解决方案是关闭二级缓存,第二种解决方案是从项目中删除 spring-security-core 插件。我不知道这是一个错误还是我缺少一些配置,也许默认配置还不够?。项目在以前的 grails 版本 3.0.x 中工作。如果您想重现错误,只需创建新的 grails 项目 - 使用 Web 配置文件,添加多个数据源(oracle、mssql)并尝试将其部署到 tomcat 上。

我认为这可能是插件依赖性的问题,因为它也使用 ehcache,并且我依赖于 hibernate-ehcache,但排除 ehcache-core 没有帮助。这是带有失败示例项目的 repo link

最佳答案

不确定您是否注意到它,但您的堆栈跟踪清楚地表明您创建了一个重复的 CacheManager。您可能需要检查您的 ehcache.xml 或 ehcache-failsafe.xml

Caused by: org.hibernate.cache.CacheException: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the
ame VM. Please provide unique names for each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessa
y
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]
at org.hibernate.cache.ehcache.EhCacheRegionFactory.start(EhCacheRegionFactory.java:107)
at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:70)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:40)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:35)
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.jav
:91)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:251)
... 74 common frames omitted
Caused by: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names
for each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessa
y
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]

更新:您可能需要考虑这个 similar question 的配置.基本上他们使用的是共享单例 bean,因此可以避免重新创建缓存:

数据源.Groovy:

cache.region.factory_class = 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory'

Config.groovy:

    cacheManager {
shared = true
}

我不确定这是否确实是您的情况(我们没有看到您的配置),但这是一个开始。

关于tomcat - 具有使用多个数据源的 spring 安全核心的 Grails 3.1.8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37749820/

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