4 Replies Latest reply on Feb 15, 2002 3:03 AM by wolfc

    ejbLoad "NoSuchEntityException" error

    iaguirre

      We have a session bean accessing to an Entity Bean.
      This could be the pseudo-code:
      "
      Take a collection of entities (with find... method)
      for each entity do
      if condition A then
      update value
      else
      remove entity

      end_for
      "

      Two parallel executions of the same call take the same entities collection but one of both removes it and the other one generates an error "NoSuchEntityException" for
      each entity in the collection.


      Jboss should serialize the calls to a method of an EJB, shouldn´t it? It seems that it doesn´t do it.

      Has somebody any idea about wich can be the problem.

      TIA.

      Idoia Aguirre

        • 1. Re: ejbLoad "NoSuchEntityException" error
          jrramon

          Hi,

          May this be a bug?

          Jose R.

          • 2. Re: ejbLoad "NoSuchEntityException" error
            wolfc

            You say the loop runs parallel (in two Threads possibly).
            Let's say the find method returns a collection with 1 entity "MyEntity".
            Thread 1: collection = { "MyEntity" };
            Thread 2: collection = { "MyEntity" };
            Thread 1: remove "MyEntity";
            Thread 2: update/remove/query "MyEntity";

            Since the entity is not in memory (it's removed), Jboss
            will try to load it with ejbLoad. But allas it's also removed from storage, so NoSuchEntityException.

            • 3. Re: ejbLoad "NoSuchEntityException" error
              jrramon


              So, is this a normal behaviour?

              I thougth this shouldn´t happen in the execution of the same method of the same EJB.

              Jose R.

              • 4. Re: ejbLoad "NoSuchEntityException" error
                wolfc

                It is normal behaviour if you have two Threads/clients calling this bean. You can make your session bean a singleton then the problem would be solved. (At the cost of performance.)

                Changing the container configuration in your jboss.xml with the following should do the trick:

                <instance-pool>org.jboss.ejb.plugins.SingletonStatelessSessionInstancePool</instance-pool>

                <container-pool-conf>
                   true
                </container-pool-conf>