Я новичок в infinispan и хотел бы обратиться за помощью по следующей проблеме.
Я попытался запустить кэш бесконечности на ejb, чтобы он был доступен для нескольких приложений.
@Singleton
public class CSysAppCacheServiceImpl implements CSysAppCacheService {
private DefaultCacheManager cacheManager;
private Cache testingCache;
@EJB(name = "postService")
private CSysPostDao postService;
@EJB(name = "roleService")
private CSysRoleDao roleService;
protected Map<String, List<CSysRole>> sysRoleMap;
protected Map<String, List<CSysPost>> sysPostMap;
protected List<CSysRole> sysRoleList;
protected List<CSysPost> sysPostList;
@PostConstruct
public void init() {
// perform some initialization logic
try {
System.out.println("init CacheManager start");
cacheManager = new DefaultCacheManager("/demo-infinispan.xml");
System.out.println("init CacheManager end");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
testingCache = cacheManager.getCache("testingCache");
preloadCache();
}
// Pre-load cache when server startup
public void preloadCache() {
for (CacheKey ck : CacheKey.values()) {
resetCache(ck);
}
}
public void resetCache(CacheKey key) {
if (key == null) {
for (CacheKey ck : CacheKey.values()) {
resetCache(ck);
}
} else if (key.equals(CacheKey.SYS_ROLE_LIST)) {
this.sysRoleList = roleService.findAllRole();
setupCacheList(CacheKey.SYS_ROLE_LIST, sysRoleList);
} else if (key.equals(CacheKey.SYS_POST_LIST)) {
this.sysPostList = postService.findAllPost();
setupCacheList(CacheKey.SYS_POST_LIST, sysPostList);
}
}
protected <T> void setupCacheList(CacheKey key, List<T> list) {
testingCache.put(key, list);
}
public List<Object> getCacheList(CacheKey key) {
return (List<Object>) testingCache.get(key);
}
public List<Object> getCacheList(String keyString) {
return (List<Object>) testingCache.get(keyString);
}
@SuppressWarnings("unchecked")
public <K, V> Map<K, V> getCacheMap(CacheKey key) {
return (Map<K, V>) testingCache.get(key);
}
public Map<String, List<CSysRole>> getCSysRoleMap() {
sysRoleMap = getCacheMap(CacheKey.SYS_ROLE_LIST);
if (MapUtils.isEmpty(sysRoleMap)) {
resetCache(CacheKey.SYS_ROLE_LIST);
}
return sysRoleMap;
}
public Map<String, List<CSysPost>> getCSysPostMap() {
sysRoleMap = getCacheMap(CacheKey.SYS_POST_LIST);
if (MapUtils.isEmpty(sysPostMap)) {
resetCache(CacheKey.SYS_POST_LIST);
}
return sysPostMap;
}
}
ejb инициируется через следующий класс
@ViewScoped
@Named
public class CacheView implements Serializable {
private static final long serialVersionUID = 1L;
private static final Logger logger = LogManager.getLogger(CacheView.class);
public static final String FNCT_ID = "SAMPLCACH";
private List<String> cacheKeyList;
// private Map<K, V> selectedMap;
private CacheKey selectedKey;
private List<Object> selectedList;
@EJB CSysAppCacheService appScopeCache;
@PostConstruct
public void init() {
appScopeCache.init();
}
...
}}}}
Но при запуске приложения возникает следующее исключение
Caused by: java.lang.NoClassDefFoundError: org/jboss/marshalling/ClassResolver
at org.infinispan.configuration.global.SerializationConfiguration.<clinit>(SerializationConfiguration.java:16)
at org.infinispan.configuration.global.SerializationConfigurationBuilder.<init>(SerializationConfigurationBuilder.java:27)
at org.infinispan.configuration.global.GlobalConfigurationBuilder.<init>(GlobalConfigurationBuilder.java:43)
at org.infinispan.configuration.parsing.ConfigurationBuilderHolder.<init>(ConfigurationBuilderHolder.java:25)
at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:122)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:311)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:286)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:274)
at CSysAppCacheServiceImpl.init(CSysAppCacheServiceImpl.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:96)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.doLifecycleInterception(Jsr299BindingsInterceptor.java:122)
at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:111)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
at org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:72)
at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:89)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:53)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:112)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:112)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.weld.interceptors.Jsr299BindingsCreateInterceptor.processInvocation(Jsr299BindingsCreateInterceptor.java:105)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:237)
... 150 more
проблема должна быть в строке
cacheManager = new DefaultCacheManager ("/ demo-infinispan.xml");
xml - это простой автономный кеш, как показано ниже
<?xml version="1.0" encoding="UTF-8"?>
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:9.0 http://www.infinispan.org/schemas/infinispan-config-9.0.xsd"
xmlns="urn:infinispan:config:9.0">
<cache-container name="testing" default-cache="default">
<local-cache name="default">
<eviction max-entries="5000" strategy="LIRS" />
</local-cache>
</cache-container>
</infinispan>
Я пытался поместить demo-infinispan.xml в любой из следующих путей, но все равно возникло исключение
1) та же папка боба Java
2) папка src пакета
3) та же папка бина вида
Кто-нибудь посоветует, где должен xmlЯ положил?
Спасибо.
С наилучшими пожеланиями,