6 Replies Latest reply on Dec 21, 2010 10:45 AM by Hubert Felber

    ClassCastException  JDBCStoreManager2 ->JDBCStoreManager?

    Hubert Felber Newbie

      Hi,

       

      I have set an EJB to use container configuration "cmp2.x jdbc2 pm" from standardjboss.xml which uses JDBCStoreManager2. Upon startup of the application I receive the following error:

       

      12:04:02,089 WARN  [ServiceController] Problem starting service jboss.j2ee:service=EjbModule,module=osworkflow-2.8.1.jar
      java.lang.ClassCastException: org.jboss.ejb.plugins.cmp.jdbc2.JDBCStoreManager2 cannot be cast to org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager
              at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:386)
              at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:172)
              at org.jboss.ejb.EjbModule.startService(EjbModule.java:414)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)

       

      I have other working EJB's configured to use "Standard CMP 2.x EntityBean" which uses JDBCStoreManager -> no problems.

       

      Can anybody please tell me what I am doing wrong?

       

      Thank you

      Hubert

        • 1. Re: ClassCastException  JDBCStoreManager2 ->JDBCStoreManager?
          Wolf-Dieter Fink Master

          I suppose you mix "Standard CMP 2.x EntityBean" and "cmp2.x jdbc2 pm" in one JAR file, right?

          This is not possible!

           

          But what is the reason to use cmp2.x manager?

          • 2. Re: ClassCastException  JDBCStoreManager2 ->JDBCStoreManager?
            Hubert Felber Newbie

            Hi Wolf-Dieter,

             

            I am not sure what you mean by "mix", but yes, there are different EJB's in the same jar. Till now they all used JDBCStoreManager, I now tried to change one to use JDBCStoreManager2. Does that mean, I have to put this in a separate jar?

             

            The reason: I try to solve (without any success till now) a concurrency/caching issue which gives me the following error.

             

            12:57:20,916 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract java.lang.Long com.opensymphony.workflow.spi.ejb.CurrentStepLocal.getId(), causedBy: javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=449944

             

            A thread tries to access an entitiy which was removed by another thread a short time ago.

             

            I have a Webui and two background threads which access and modify the same entities. If a thread removes an entitiy, the others may get the exception above.

            The entity has a PK and all entities have a common group identifier.

            I am doing a findByGroupIdentifier() which gives me a Collection of results. If I access one of the results (direct after find e.g. ent.getId()) I get the exception above.

             

            I saw that this seams to be a common problem (forums), but till now I was unable to solve it. I want to achieve that the entities are up to date if loaded, it seams I get stale results from my find.

             

            I tried to use configuration "Standard CMP 2.x EntityBean" with commit-option B and C, without success.

            neither "Instance Per Transaction CMP 2.x EntityBean" nor "Standard CMP 2.x EntityBean with cache invalidation" helped to solve my issue.

            For the latter I defined

             

            <cache-invalidation>true</cache-invalidation>
                     <cache-invalidation-config>
                         <invalidation-group-name>CurrentSteps</invalidation-group-name>
            </cache-invalidation-config>

             

            in jboss.xml for the entitiy.

             

            Till now I don't have any success. Maybe you can give me a hint what I should do? This would be a great x-mass gift .

             

            Thank you

            Hubert

            • 3. Re: ClassCastException  JDBCStoreManager2 ->JDBCStoreManager?
              Wolf-Dieter Fink Master

              Mix mean:

              Entities with standard and cmp2 configuration .

              YES you must separate in two jars

               

              But with your problem I think it will not help to use cmp2.x!

              If you remove an entity after the commit it will not accessible for the next find...

               

              Does your findByGroupIdent() and ent.getId() run in the same transaction?

              Do you use cluster?

              • 4. Re: ClassCastException  JDBCStoreManager2 ->JDBCStoreManager?
                Hubert Felber Newbie

                Yes, findByGroupIdent() and ent.getId() run in the same transaction, within the same function, maybe there is a problem in my procedure?

                I do a

                {code:java}
                Collection <CurrentEntity> results = CurrentEntityHomeFactory.getLocalHome().findByEntryId(entryId);
                for (CurrentEntity entity : results) {
                  long id = entity.getId().longValue(); 
                   ...
                // bang, as soon as I access the entity I get the "NoSuchObjectLocalException"
                // the item was removed from another thread in another, by this time commited, transaction
                  }                                                              
                {code}

                 

                No I don't use cluster.

                 

                I don't understand the reason of my issue. I am not using findByPrimaryKey for each entity, which (according to spec) looks in the cache first, so the findByEntryId should query the database and return good results. Do you have an explanation?

                 

                For this bean I also use "read-ahead" and all fields in the bean are accessed on-load, but it doesn't make a difference if I ommit this.

                {code:xml} 
                      <read-ahead>
                        <strategy>on-load</strategy>
                        <page-size>10</page-size>           
                        <eager-load-group>some</eager-load-group>
                      </read-ahead>
                {code}
                • 5. Re: ClassCastException  JDBCStoreManager2 ->JDBCStoreManager?
                  Wolf-Dieter Fink Master

                  Mmmh,

                   

                  What you can do is to activate CMP logging:

                  <category name="org.jboss.ejb.plugins.cmp">
                      <priority value="TRACE" />
                    </category>

                   

                  then you see every action.

                  -----------

                  What happen in your case is that Coll=...findByEntryId() fetch only PKey and each entity.getId() will do a cache/findByPKey roundtrip.

                  It looks like that the remove() happen between the findByEntryId and entity.getId().

                  So it might be a application special problem that you run this two threads in parallel.

                  If you set the TxLevel of the Db to 'REPEATABLE READ' (I suppose this is the correct level) the transaction will not see changes from other Tx. But it might be a lesser performance

                   

                  It is not what I expect before you ask for.

                  I think you have to decide what behaviour you accept, if you ignore the ONFExeption you might loose entity creation.

                  • 6. Re: ClassCastException  JDBCStoreManager2 ->JDBCStoreManager?
                    Hubert Felber Newbie
                    What happen in your case is that Coll=...findByEntryId() fetch only PKey and each entity.getId() will do a cache/findByPKey roundtrip.

                    It looks like that the remove() happen between the findByEntryId and entity.getId().

                    hrmpf, I suspected something like this.

                    I will do logging, maybe I see something and try the TRANSACTION_REPEATABLE_READ

                    I think you have to decide what behaviour you accept, if you ignore the ONFExeption you might loose entity creation.

                    hmm, Speed vs reliablility, I guess reliability wins.

                    Hey! Many thanks for helping! I will report the results here.

                    Greets

                    Hubert