1 Reply Latest reply on Apr 10, 2006 4:50 AM by Alex

    Simple OneToMany Realtion does't work this cache in Jboss-4.

    Alex Newbie

      I have two simple Enety bean :

      @Entity
      @org.hibernate.annotations.Entity(optimisticLock=OptimisticLockType.DIRTY,dynamicUpdate=true)
      @Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
      public class TestDB implements Serializable {
       Long id;
       String message;
       Set<TestRel> rel;
       @OneToMany(mappedBy="test", cascade=CascadeType.REMOVE)
       public Set<TestRel> getRel() {
       return rel;
       }
       public void setRel(Set<TestRel> rel) {
       this.rel = rel;
       }
       @Id
       @GeneratedValue(strategy=GenerationType.IDENTITY)
       public Long getId() {
       return id;
       }
       public void setId(Long id) {
       this.id = id;
       }
       public String getMessage() {
       return message;
       }
       public void setMessage(String message) {
       this.message = message;
       }
      
      }
      

      @Entity
      @org.hibernate.annotations.Entity(optimisticLock=OptimisticLockType.DIRTY,dynamicUpdate=true)
      @Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
      public class TestRel implements Serializable {
       TestDB test;
       int curindex;
      
       @Id
       public int getCurindex() {
       return curindex;
       }
       public void setCurindex(int curindex) {
       this.curindex = curindex;
       }
       @ManyToOne
       @JoinColumn(name = "id")
       public TestDB getTest() {
       return test;
       }
       public void setTest(TestDB test) {
       this.test = test;
       }
      }
      

      Wile I try load TestDB entity i catch exception :
      2006-04-10 12:27:23,117 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 11446576431
      2006-04-10 12:27:23,117 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
      2006-04-10 12:27:23,117 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Looking for a JTA transaction to join
      2006-04-10 12:27:23,117 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
      2006-04-10 12:27:23,117 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Looking for a JTA transaction to join
      2006-04-10 12:27:23,117 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Transaction already joined
      2006-04-10 12:27:23,117 DEBUG [org.hibernate.cache.TransactionalCache] cache lookup: Test.TestDB#1
      2006-04-10 12:27:23,117 DEBUG [org.jboss.cache.interceptors.TxInterceptor] local transaction exists - registering global tx if not present for Thread[http-0.0.0.0-8080-2,5,jboss]
      2006-04-10 12:27:23,120 DEBUG [org.hibernate.cache.TransactionalCache] cache hit
      2006-04-10 12:27:23,121 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
      2006-04-10 12:27:23,121 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
      2006-04-10 12:27:23,121 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] ************** closing entity managersession **************
      2006-04-10 12:27:23,121 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
      2006-04-10 12:27:23,121 DEBUG [org.jboss.cache.interceptors.TxInterceptor] Running rollback phase
      2006-04-10 12:27:23,121 DEBUG [org.jboss.cache.interceptors.TxInterceptor] Found local TX=TransactionImpl:XidImpl[FormatId=257, GlobalId=manager/42, BranchQual=, localId=42], global TX=GlobalTransaction:<null>:16
      2006-04-10 12:27:23,122 DEBUG [org.jboss.cache.interceptors.TxInterceptor] Found local TX=TransactionImpl:XidImpl[FormatId=257, GlobalId=manager/42, BranchQual=, localId=42], global TX=GlobalTransaction:<null>:16
      2006-04-10 12:27:23,122 DEBUG [org.jboss.cache.interceptors.TxInterceptor] Finished local commit/rollback method for GlobalTransaction:<null>:16
      2006-04-10 12:27:23,122 DEBUG [org.jboss.cache.interceptors.TxInterceptor] Finished rollback phase
      2006-04-10 12:27:23,122 DEBUG [org.jboss.remoting.transport.servlet.ServletServerInvoker] Error thrown calling invoke on server invoker.
      javax.ejb.EJBException: java.lang.ArrayIndexOutOfBoundsException: 1
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:225)
       at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:104)
       at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
       at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
       at org.jboss.remoting.transport.servlet.ServletServerInvoker.processRequest(ServletServerInvoker.java:211)
       at sun.reflect.GeneratedMethodAccessor109.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:201)
       at $Proxy54.processRequest(Unknown Source)
       at org.jboss.remoting.transport.servlet.web.ServerInvokerServlet.processRequest(ServerInvokerServlet.java:139)
       at org.jboss.remoting.transport.servlet.web.ServerInvokerServlet.doPost(ServerInvokerServlet.java:168)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
       at org.hibernate.type.TypeFactory.assemble(TypeFactory.java:393)
       at org.hibernate.cache.entry.CacheEntry.assemble(CacheEntry.java:96)
       at org.hibernate.cache.entry.CacheEntry.assemble(CacheEntry.java:82)
       at org.hibernate.event.def.DefaultLoadEventListener.assembleCacheEntry(DefaultLoadEventListener.java:520)
       at org.hibernate.event.def.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.java:474)
       at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:328)
       at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
       at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
       at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
       at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:866)
       at org.hibernate.impl.SessionImpl.get(SessionImpl.java:803)
       at org.hibernate.impl.SessionImpl.get(SessionImpl.java:796)
       at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:156)
       at org.jboss.ejb3.entity.TransactionScopedEntityManager.find(TransactionScopedEntityManager.java:164)
       at Test.HelloBean.getWorkd(HelloBean.java:36)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       ... 50 more
      


      When I disable using second level cache it's work good.
      I use Jboss-4.0.4CR2(this embeded EJB3.0) and JbossCache(1.3.0.GA)