2012-08-01 4 views
0

내 응용 프로그램에서 Infinispan 5.1.5 Final을 사용하려고합니다. 나는 다음과 같은 환경에서 사용Hibernate-Infinispan CacheKey.equals 메소드의 NullPointerException

  • 보스를 7.1.1 최종
  • 최대 절전 모드 코어 4.1.5.SP1
  • 최대 절전 모드 검색 4.1.1 최종
  • Infinispan 5.1.5 최종
  • 제이보스 심 AS 2.3.0 Beta2

응용 프로그램이 시작될 때 관리자 사용자 계정이 존재하는지 확인하고, 사용자 계정이 없는지 확인하려고합니다. 다음과 같이

private void initDefaultUsersAndRoles(){ 

     log.info("Initializing Default Roles And Passwords"); 

     Role adminRole = roleDAO.getByName("administrator"); 

     if (adminRole == null) { 
      //create new admin role 
     } 


     User admin = userDAO.findByUsername("admin "); 

     if (admin == null) { 
      //create new admin user 
     } 
} 

를 I을 아래에 나타낸다 userDAO.findByUsername 방법의 예외가 :

I가 다음 오류

user = (User) q.getSingleResult() 

의 실행시

public User findByUsername(String username) { 
     User user; 
     try{ 
      Query q = getEm().createQuery("SELECT e FROM " 
          + entityClass.getName() + " e WHERE username = :username"); 
           q.setParameter("username", username); 
           q.setHint("org.hibernate.cacheable", "true"); 

           user = (User) q.getSingleResult(); 
     } 
     catch(NoResultException e){ 
      return null; 
     } 

     return user; 
} 

:

Caused by: java.lang.NullPointerException 
    at org.hibernate.cache.spi.CacheKey.equals(CacheKey.java:81) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.infinispan.context.SingleKeyNonTxInvocationContext.lookupEntry(SingleKeyNonTxInvocationContext.java:93) 
    at org.infinispan.container.EntryFactoryImpl.getFromContext(EntryFactoryImpl.java:204) 
    at org.infinispan.container.EntryFactoryImpl.wrapEntryForReading(EntryFactoryImpl.java:80) 
    at org.infinispan.interceptors.EntryWrappingInterceptor.visitGetKeyValueCommand(EntryWrappingInterceptor.java:112) 
    at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:60) 
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116) 
    at org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor.visitGetKeyValueCommand(NonTransactionalLockingInterceptor.java:57) 
    at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:60) 
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116) 
    at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:130) 
    at org.infinispan.commands.AbstractVisitor.visitGetKeyValueCommand(AbstractVisitor.java:104) 
    at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:60) 
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116) 
    at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:132) 
    at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:91) 
    at org.infinispan.commands.AbstractVisitor.visitGetKeyValueCommand(AbstractVisitor.java:104) 
    at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:60) 
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116) 
    at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:130) 
    at org.jboss.as.clustering.infinispan.DefaultEmbeddedCacheManager$ClassLoaderAwareCommandInterceptor.handleDefault(DefaultEmbeddedCacheManager.java:410) 
    at org.infinispan.commands.AbstractVisitor.visitGetKeyValueCommand(AbstractVisitor.java:104) 
    at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:60) 
    at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:345) 
    at org.infinispan.CacheImpl.containsKey(CacheImpl.java:259) 
    at org.infinispan.DecoratedCache.containsKey(DecoratedCache.java:309) 
    at org.infinispan.AbstractDelegatingCache.containsKey(AbstractDelegatingCache.java:293) 
    at org.hibernate.cache.infinispan.util.CacheAdapterImpl.containsKey(CacheAdapterImpl.java:214) [hibernate-infinispan-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.cache.infinispan.access.TransactionalAccessDelegate.putFromLoad(TransactionalAccessDelegate.java:87) [hibernate-infinispan-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.cache.infinispan.entity.TransactionalAccess.putFromLoad(TransactionalAccess.java:52) [hibernate-infinispan-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:224) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:134) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:998) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.loader.Loader.doQuery(Loader.java:877) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:292) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.loader.Loader.doList(Loader.java:2381) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2226) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.loader.Loader.list(Loader.java:2189) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1248) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) [hibernate-core-4.1.5.SP1.jar:4.1.5.SP1] 
    at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:285) [hibernate-entitymanager-4.1.5.SP1.jar:4.1.5.SP1] 
    at com.cano.pxt.dao.UserDAO.findByUsername(UserDAO.java:35) [pxt-ejb.jar:] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_01] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_01] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_01] 
    at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_01] 
    at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final] 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 
    at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 
    at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:29) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:30) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) [jboss-seam.jar:2.3.0.Beta2] 
    at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50) [jboss-seam.jar:2.3.0.Beta2] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_01] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_01] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_01] 
    at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_01] 
    at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptorFactory$ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptorFactory.java:123) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final] 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 
    at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 
    at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final] 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 
    at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final] 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 
    at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 
    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 
    at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final] 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 
    at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final] 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final] 
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:202) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final] 
    ... 101 more 

내 persistence.xml을 최대 절전 모드 쿼리 및 2 레벨 캐싱에 대한 다음 행이 포함

<property name="hibernate.cache.region.factory_class" value="org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory" /> 
<property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/hibernate" /> 

내 사용자 엔티티 클래스 구현 equals 메소드와 hashCode 메소드를 가지고있다.

누구에게 잘못된 생각이 있습니까? 미리 감사드립니다.

답변