3 Replies Latest reply on Mar 14, 2008 8:19 AM by Manik Surtani

    Exception in thread "main" java.lang.IllegalStateException:

    Bahata Mukhopadhyay Newbie

      Hi
      I am trying to create a cluster of replicated pojo caches.
      My programming logic is:
      The first application instance would start a cache and check whether there is any object under a node (say "datamodel" node) . If it does not find any object, it would conclude that it is the first cache and would attach a complex object datamodel under datamodel node. All subsequent instances would find the object under the node after starting their own caches with the same cluster name, and so would not attach the object again.

      Now sometimes while running the application instance (from eclipse / tomcat)
      I am getting the error
      PojoReference.incrementRefCount(): source fqn ... is already present.
      Sometimes the error is not coming and everything is going through.

      My object datamodel is a complex object with all the other objects needed in the application stored as its field members in collection class hash set.

      I am attaching the object only once.
      Kindly help. It has become a road block for my project.

        • 1. Re: Exception in thread
          Manik Surtani Master

          You need to be a bit more descriptive about the error you see - I can't make out much from what little you have told me.

          • 2. Re: Exception in thread
            Bahata Mukhopadhyay Newbie

            Hi
            I am really sorry for not being clear. But now I have probably pinpointed the problem and could reproduce it and explain it with a simpler example.

            Say I have a Person class with two fields PrimaryAddress and SecondaryAddress. Now say I created a single address object A and assigned both the addresses to that
            address A. Now if I try to attach the Person in my cache, it gives the exception

            " java.lang.IllegalStateException: PojoReference.incrementRefCount(): source fqn: /__JBossInternal__/pg/_ID_/aaa4z-hq7ub6-fdr124m4-1-fdr1256j-9 is already present."

            I understand that, this is because the person object is trying to refer to the Address object twice, because of its two fields .So the PojoInstance.incrementRefCount() method is throwing the exception.

            Now if I assign PrimaryAddress and SecondaryAddress fields of Person to diffrent Address objects, this exception disappears.

            But in our product There are classes where two of its fields need to point to the same object. We are creating the object graph using hibernate association and are implementing pojo cache in front of hibernate(not .as second level cache for certain reasons)

            So can you kindly suggest a fix or any workaround for this problem?
            Thanks a lot for your previous reply.
            Waiting to hear from you.
            Bahata

            • 3. Re: Exception in thread
              Manik Surtani Master

              We've created a new forum for POJO Cache specific questions - I suggest you post this question there.

              http://jboss.org/index.html?module=bb&op=viewforum&f=277