【问题标题】:How to configure Wildfly 8 to use Infinispan for caching entities如何配置 Wildfly 8 以使用 Infinispan 缓存实体
【发布时间】:2014-09-29 07:53:00
【问题描述】:

我正在尝试创建一个本地 infinispan 缓存,我知道它需要在 wildfly 的 config.xml 中进行更改。我尝试这样做,当我尝试访问该缓存时,它显示缓存不可用。我不知道我做错了什么,任何人都可以帮助我。

config.xml 的变化是

         <subsystem xmlns="urn:jboss:domain:infinispan:2.0">

         <cache-container name="web" aliases="standard-session-cache" default-cache="local-web" module="org.wildfly.clustering.web.infinispan">

         </cache-container>
         <cache-container name="hibernate" default-cache="local-query" module="org.hibernate">

         </cache-container>
    //This is my local cache
       <cache-container name="myCache" default-cache="cachedb">
       <local-cache name="cachedb"/>
       </cache-container>
        </subsystem>

这是访问缓存的代码

        @Stateless 
        public class SimpleCache {

        @Resource(lookup="java:jboss/infinispan/container/myCache")
         private CacheContainer container; 

         private org.infinispan.Cache<String, String> cache;
        @PostConstruct
         public void initCache() {
          this.cache = container.getCache();
         }

         public String get(String key) {
          return this.cache.get(key);
         }

         public void put(String key, String value) {
          this.cache.put(key, value);
         }

        }

错误:

java:global/InfinispanTest/SimpleCache!SimpleCache
    java:app/InfinispanTest/SimpleCache!SimpleCache
    java:module/SimpleCache!SimpleCache
    java:global/InfinispanTest/SimpleCache
    java:app/InfinispanTest/SimpleCache
    java:module/SimpleCache

17:05:09,721 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "InfinispanTest.war" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.InfinispanTest.InfinispanTest.env.SimpleCache.containerjboss.naming.context.java.jboss.infinispan.container.myCacheMissing[jboss.naming.context.java.module.InfinispanTest.InfinispanTest.env.SimpleCache.containerjboss.naming.context.java.jboss.infinispan.container.myCache]"]}
17:05:09,769 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment InfinispanTest.war in 45ms
17:05:09,770 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.naming.context.java.jboss.infinispan.container.myCache (missing) dependents: [service jboss.naming.context.java.module.InfinispanTest.InfinispanTest.env.SimpleCache.container] 

17:05:09,772 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.InfinispanTest.InfinispanTest.env.SimpleCache.containerjboss.naming.context.java.jboss.infinispan.container.myCacheMissing[jboss.naming.context.java.module.InfinispanTest.InfinispanTest.env.SimpleCache.containerjboss.naming.context.java.jboss.infinispan.container.myCache]"]}}}

【问题讨论】:

    标签: java caching jboss infinispan


    【解决方案1】:

    你有没有在你的项目中加入 infinispan 依赖?

    放入您的 META_INF/MANIFEST.MF:

    dependencies: org.infinispan export
    

    【讨论】:

      猜你喜欢
      • 2019-06-15
      • 2016-09-17
      • 2018-06-12
      • 2015-12-13
      • 2018-06-04
      • 2015-08-28
      • 2017-03-26
      • 2017-05-20
      • 2016-06-08
      相关资源
      最近更新 更多