我想在spring中使用terracotta (terracotta 4.3.3 + ehcache 2.6.8)来实现缓存一些数据。当我尝试运行时,我得到了这个错误:
03:10:10,320 ERROR [ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.interceptor.CacheInterceptor#0': Cannot resolve reference to bean 'cacheManager' while setting bean property 'cacheManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheManager' defined in class path resource [foundationCommonContext-service.xml]: Cannot resolve reference to bean 'ehcache' while setting bean property 'cacheManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ehcache' defined in class path resource [foundationCommonContext-service.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Unable to load class net.sf.ehcache.terracotta.StandaloneTerracottaClusteredInstanceFactory. Initial cause was java.lang.RuntimeException: com.tc.config.schema.setup.ConfigurationSetupException:
*******************************************************************************
The configuration data in the base configuration from server at '127.0.0.1:9510' does not obey the Terracotta schema:
[0]: Line 8, column 9: Expected element 'server' instead of 'mirror-group' here in element servers
[1]: Line 31, column 9: Expected element 'server' instead of 'garbage-collection' here in element servers
[2]: Line 36, column 9: Expected element 'server' instead of 'restartable' here in element servers
[3]: Line 37, column 9: Expected element 'server' instead of 'client-reconnect-window' here in element servers
*******************************************************************************
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:336) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) ~[spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) ~[spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:798) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:444) [jetty-servlet-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:789) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:294) [jetty-servlet-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1341) [jetty-webapp-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp(JettyWebAppContext.java:296) [jetty-maven-plugin-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1334) [jetty-webapp-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:497) [jetty-webapp-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:365) [jetty-maven-plugin-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) [jetty-util-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) [jetty-util-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:163) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) [jetty-util-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) [jetty-util-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) [jetty-util-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.Server.start(Server.java:387) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) [jetty-util-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.Server.doStart(Server.java:354) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.java:73) [jetty-maven-plugin-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:534) [jetty-maven-plugin-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:357) [jetty-maven-plugin-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:167) [jetty-maven-plugin-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) [maven-core-3.2.3.jar:3.2.3]
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) [maven-core-3.2.3.jar:3.2.3]
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) [maven-core-3.2.3.jar:3.2.3]
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) [maven-core-3.2.3.jar:3.2.3]
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) [maven-core-3.2.3.jar:3.2.3]
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) [maven-core-3.2.3.jar:3.2.3]
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) [maven-core-3.2.3.jar:3.2.3]
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) [maven-core-3.2.3.jar:3.2.3]
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347) [maven-core-3.2.3.jar:3.2.3]
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154) [maven-core-3.2.3.jar:3.2.3]
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582) [maven-embedder-3.2.3.jar:3.2.3]
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) [maven-embedder-3.2.3.jar:3.2.3]
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158) [maven-embedder-3.2.3.jar:3.2.3]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_101]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_101]
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) [plexus-classworlds-2.5.1.jar:?]
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) [plexus-classworlds-2.5.1.jar:?]
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) [plexus-classworlds-2.5.1.jar:?]
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) [plexus-classworlds-2.5.1.jar:?]
当我运行我的terracotta服务器时,我没有得到错误:
./start-tc-server.sh -f ../config/tc-config.xml
2016-12-10 03:09:01,931 INFO - Terracotta 4.3.3, as of 20161014-074934 (Revision 27037 from 4.3.3)
2016-12-10 03:09:02,241 WARN -
********************************* WARNING **********************************
* DataStorage offheap size not specified. Using a default of 2g
****************************************************************************
2016-12-10 03:09:02,255 INFO - Successfully loaded base configuration from file at '/home/asyst/Software/terracotta-4.3.3/server/bin/../config/tc-config.xml'.
2016-12-10 03:09:02,378 INFO - Log file: '/home/asyst/terracotta/server-logs/terracotta-server.log'.
2016-12-10 03:09:02,399 INFO - Available Max Runtime Memory: 1963MB
2016-12-10 03:09:08,231 INFO - Becoming State[ ACTIVE-COORDINATOR ]
2016-12-10 03:09:08,274 INFO - Terracotta Server instance has started up as ACTIVE node on 127.0.0.1:9510 successfully, and is now ready for work.
2016-12-10 03:09:09,922 INFO - Management server started on 0.0.0.0:9540
我的tc-config.xml没有在错误中提到的任何元素:
<?xml version="1.0" encoding="UTF-8" ?>
<tc:tc-config xmlns:tc="http://www.terracotta.org/config">
<servers>
<server host="127.0.0.1" name="My Server Name" bind="0.0.0.0">
<data>/home/asyst/terracotta/server-data</data>
<logs>/home/asyst/terracotta/server-logs</logs>
<tsa-port bind="127.0.0.1">9510</tsa-port>
<jmx-port bind="127.0.0.1">9520</jmx-port>
<tsa-group-port bind="127.0.0.1">9530</tsa-group-port>
</server>
</servers>
<clients>
<logs>logs-%i</logs>
</clients>
<tc-properties>
<property name="l2.nha.dirtydb.autoDelete" value="true"/>
<property name="l1.cachemanager.enabled" value="true"/>
<property name="logging.maxLogFileSize" value="1024"/>
</tc-properties>
</tc:tc-config>
这是我的ehcache.xml:
<ehcache updateCheck="false">
<!-- Sets the path to the directory where cache .data files are created.
If the path is a Java System Property it is replaced by
its value in the running VM.
The following properties are translated:
user.home - User's home directory
user.dir - User's current working directory
java.io.tmpdir - Default temp file path -->
<diskStore path="java.io.tmpdir"/>
<!--Default Cache configuration. These will applied to caches programmatically created through
the CacheManager.
The following attributes are required:
maxElementsInMemory - Sets the maximum number of objects that will be created in memory
eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the
element is never expired.
overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache
has reached the maxInMemory limit.
The following attributes are optional:
timeToIdleSeconds - Sets the time to idle for an element before it expires.
i.e. The maximum amount of time between accesses before an element expires
Is only used if the element is not eternal.
Optional attribute. A value of 0 means that an Element can idle for infinity.
The default value is 0.
timeToLiveSeconds - Sets the time to live for an element before it expires.
i.e. The maximum time between creation time and when an element expires.
Is only used if the element is not eternal.
Optional attribute. A value of 0 means that and Element can live for infinity.
The default value is 0.
diskPersistent - Whether the disk store persists between restarts of the Virtual Machine.
The default value is false.
diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value
is 120 seconds.
-->
<terracottaConfig url="127.0.0.1:9510"/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120">
<terracotta />
</defaultCache>
</ehcache>
有人能帮我解决这个问题吗?提前感谢
发布于 2016-12-12 19:54:01
Terracotta 4.3.3需要Ehcache 2.10.3。
问题来自于您尝试使用Ehcache 2.6.8的事实。
对于Terracotta4.3OSS服务器,dot版本可以不同,但major.minor必须匹配,这是4.3.x与2.10.x的强项,不是说差异应该限制在滚动升级的持续时间内,而不是作为一般的运行时配置。
https://stackoverflow.com/questions/41068373
复制相似问题