1 2 Previous Next 19 Replies Latest reply on Aug 28, 2008 5:14 PM by ehawthorne Go to original post
      • 15. Re: Migration 4.0.4.CR2 -> 4.0.4.GA problem

        I have used the SortedSet instead of List and the OneToMany relation works when I write or update but when I retrieve my composite object it gives a ClassCastException on the TreeSet Compare. I do not know why as I have my object as a comparator and it implements a compare method??

        public boolean equals(Object obj )
         {
         boolean ret = false;
         if( obj == null ) return false;
         if( obj instanceof Counts )
         {
         Counts other = (Counts)obj;
         if( this.id == other.id &&
         this.wellNumber == other.wellNumber &&
         this.cnts == other.cnts &&
         this.milliSeconds == other.milliSeconds &&
         this.timestamp.equals(other.timestamp))
         {
         ret = true;
         }
         }
        
         return ret;
         }
        
         public int compare( Object arg0, Object arg1 )
         {
         int ret = -1;
         if( arg0 == null || arg1 == null ) return -1;
        
         if( arg0 instanceof Counts && arg1 instanceof Counts )
         {
         Counts c1 = ( Counts ) arg0;
         Counts c2 = ( Counts ) arg1;
        
         if( c1.cnts > c2.cnts ) ret = 1;
         if( c1.cnts < c2.cnts ) ret = -1;
         if( c1.equals(c2) ) ret = 0;
         }
        
         return ret;
         }


        14:07:00,176 ERROR [STDERR] javax.ejb.EJBException: java.lang.ClassCastException: com.theranos.abcs.reader.dmo.Counts
        14:07:00,176 ERROR [STDERR] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
        14:07:00,176 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
        14:07:00,176 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
        14:07:00,176 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        14:07:00,176 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
        14:07:00,176 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        14:07:00,176 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
        14:07:00,176 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        14:07:00,176 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
        14:07:00,176 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        14:07:00,176 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
        14:07:00,176 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        14:07:00,176 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
        14:07:00,176 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        14:07:00,176 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:199)
        14:07:00,176 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
        14:07:00,176 ERROR [STDERR] at $Proxy80.getAll(Unknown Source)
        14:07:00,176 ERROR [STDERR] at com.theranos.abcs.utils.LogParser.parse(LogParser.java:254)
        14:07:00,176 ERROR [STDERR] at com.theranos.abcs.reader.web.servlet.ReaderServer.parseLogs(ReaderServer.java:247)
        14:07:00,176 ERROR [STDERR] at com.theranos.abcs.reader.web.servlet.ReaderServer.doPost(ReaderServer.java:147)
        14:07:00,176 ERROR [STDERR] at com.theranos.abcs.reader.web.servlet.ReaderServer.doGet(ReaderServer.java:105)
        14:07:00,176 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
        14:07:00,176 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        14:07:00,176 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        14:07:00,176 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        14:07:00,176 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        14:07:00,176 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        14:07:00,176 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        14:07:00,176 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        14:07:00,176 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        14:07:00,176 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
        14:07:00,176 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
        14:07:00,176 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        14:07:00,176 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        14:07:00,176 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        14:07:00,176 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        14:07:00,176 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
        14:07:00,176 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
        14:07:00,176 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        14:07:00,176 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
        14:07:00,176 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
        14:07:00,176 ERROR [STDERR] Caused by: java.lang.ClassCastException: com.theranos.abcs.reader.dmo.Counts
        14:07:00,176 ERROR [STDERR] at java.util.TreeMap.compare(Unknown Source)
        14:07:00,176 ERROR [STDERR] at java.util.TreeMap.put(Unknown Source)
        14:07:00,176 ERROR [STDERR] at java.util.TreeSet.add(Unknown Source)
        14:07:00,176 ERROR [STDERR] at java.util.AbstractCollection.addAll(Unknown Source)
        14:07:00,176 ERROR [STDERR] at java.util.TreeSet.addAll(Unknown Source)
        14:07:00,192 ERROR [STDERR] at org.hibernate.collection.PersistentSet.endRead(PersistentSet.java:273)
        14:07:00,192 ERROR [STDERR] at org.hibernate.engine.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:183)
        14:07:00,192 ERROR [STDERR] at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:268)
        14:07:00,192 ERROR [STDERR] at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:249)
        14:07:00,192 ERROR [STDERR] at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:866)
        14:07:00,192 ERROR [STDERR] at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:853)
        14:07:00,192 ERROR [STDERR] at org.hibernate.loader.Loader.doQuery(Loader.java:717)
        14:07:00,192 ERROR [STDERR] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
        14:07:00,192 ERROR [STDERR] at org.hibernate.loader.Loader.loadCollection(Loader.java:1919)
        14:07:00,192 ERROR [STDERR] at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
        14:07:00,192 ERROR [STDERR] at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:541)
        14:07:00,192 ERROR [STDERR] at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
        14:07:00,192 ERROR [STDERR] at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1705)
        14:07:00,192 ERROR [STDERR] at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)
        14:07:00,192 ERROR [STDERR] at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:755)
        14:07:00,192 ERROR [STDERR] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:229)
        14:07:00,192 ERROR [STDERR] at org.hibernate.loader.Loader.doList(Loader.java:2145)
        14:07:00,192 ERROR [STDERR] at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
        14:07:00,192 ERROR [STDERR] at org.hibernate.loader.Loader.list(Loader.java:2024)
        14:07:00,192 ERROR [STDERR] at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:392)
        14:07:00,192 ERROR [STDERR] at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:333)
        14:07:00,192 ERROR [STDERR] at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
        14:07:00,192 ERROR [STDERR] at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
        14:07:00,192 ERROR [STDERR] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
        14:07:00,192 ERROR [STDERR] at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:53)
        14:07:00,192 ERROR [STDERR] at com.theranos.abcs.reader.dao.MeasurementDaoImpl.getAll(MeasurementDaoImpl.java:86)
        14:07:00,192 ERROR [STDERR] at com.theranos.abcs.reader.ejb.MeasurementAccessorBean.getAll(MeasurementAccessorBean.java:113)
        14:07:00,192 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        14:07:00,192 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        14:07:00,192 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        14:07:00,192 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
        14:07:00,192 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
        14:07:00,192 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
        14:07:00,192 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
        14:07:00,192 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        14:07:00,208 ERROR [STDERR] at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
        14:07:00,208 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        14:07:00,208 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
        14:07:00,208 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        14:07:00,208 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
        14:07:00,208 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        14:07:00,208 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
        14:07:00,208 ERROR [STDERR] ... 39 more


        • 16. Re: Migration 4.0.4.CR2 -> 4.0.4.GA problem

          Try implementing Comparable instead of Comparator. TreeMap.compare(), I believe, invokes the class's compareTo() method, after casting to Comparable. I think that's where you're exception is.

          • 17. Re: Migration 4.0.4.CR2 -> 4.0.4.GA problem

            Thanks John and to everyone who have posted their solutions here. It worked, so it is important to implement Comparable (NOT comparator) on your Entities, if you are planning to use SortedSet as I have done.

            Thx
            Vijay

            • 18. Re: Migration 4.0.4.CR2 -> 4.0.4.GA problem
              gus888

              As to changing List to SortedSet on JBoss 4.0.4. GA, I found that the dvdstore example in seam 1.0.1 GA used the List:

              @Entity
              @Table(name="ORDERS")
              public class Order
               implements Serializable
              {
              ...
              List<OrderLine> orderLines = new ArrayList<OrderLine>();
              ...
               @OneToMany(mappedBy="order", cascade=CascadeType.ALL)
               public List<OrderLine> getOrderLines() {
               return orderLines;
               }
               public void setOrderLines(List<OrderLine> lines) {
               this.orderLines = lines;
               }
              ...}

              Since the seam 1.0.1.GA needs JBoss 4.0.4.GA + EJB CR8, I am wondering why the seam example works on JBoss 4.0.4.GA with the List. Can somebody give me an explanation? Thank you in advance.

              GUS



              • 19. Re: Migration 4.0.4.CR2 -> 4.0.4.GA problem
                ehawthorne

                Re: This is not a bug

                Let's just say it is a bug in Hibernate's implementation of the JPA spec then, because there is no reasonable solution if you want an eagerly fetched, orderBy someColumn List collection using JPA interface to
                Hibernate.

                1 2 Previous Next