Glassfish 3.1.2 with Infinispan 5.1.2

时间:2012-03-20 13:47:23

标签: glassfish infinispan

我正在使用Glassfish 3.1.2和Infinispan 5.1.2。 我想覆盖默认缓存管理器的配置并提前启动一些命名缓存。然后我想将该缓存管理器注入无状态EJB并使用名称缓存。 我有的代码:

Config.java:

@Produces
@ApplicationScoped
public EmbeddedCacheManager defaultEmbeddedCacheManager() {
    DefaultCacheManager returnCacheManager;

    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.eviction().strategy(EvictionStrategy.NONE)
            .maxEntries(Integer.MAX_VALUE)
            .transaction().transactionManagerLookup(new GenericTransactionManagerLookup())
            .expiration().lifespan(Long.valueOf(-1)).maxIdle(Long.valueOf(-1));
    Configuration config = builder.build();

    returnCacheManager = new DefaultCacheManager(config);
    String cacheNames[] = new String[2];
    cacheNames[0] = "cache1";
    cacheNames[1] = "cache2";
    returnCacheManager.startCaches(cacheNames);

    return returnCacheManager;
}

CacheBean.java:

@Stateless
public class CacheBean implements CacheBeanLocal {
    public static final String _rev = "$Id";
    @Inject
    private EmbeddedCacheManager defaultCacheManager;

    @Override
    public void addToCache1(String key, String value) {
        Cache<String, String> cache1 = defaultCacheManager.getCache("cache1", true);
        cache1.put(key, value);
    }
}

当我将EAR部署到Glassfish服务器时,我得到了这个:

org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [CacheContainer] with qualifiers [@Default] at injection point [[field] @Inject private org.infinispan.cdi.AdvancedCacheProducer.defaultCacheContainer]
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:274)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:243)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:106)
    at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:347)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:330)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:366)
    at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:199)
    at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:313)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)

我做错了什么?

0 个答案:

没有答案