3 Replies Latest reply on May 16, 2005 12:57 PM by plainkeyman

    help with how to debug

    plainkeyman Newbie

      here's my problem:
      some objects that i'm putting into jboss cache are changing values without my consent. but i cannot tell what it changing them. it is not reliable, but i can reproduce it with my code. basically they change after a significant amount of time, with several accesses of other objects.

      i've put "System.out.println(fqn)" statements in Node.java in methods "put*, getData, remove, clear". after the problem happens, i don't see a corresponding print statement for the object that changed.
      i've done similar techniques in my code and really cannot find it.

      here's my questions:
      how can i be able to spot which code is modifying these objects? i'm currently using jswat 2.X. is there another debugger that can do this? is there a debugger that can make a 'memory breakpoint'?

      i'm not asking for someone to find the problem, but to help me learn how to find it.

      thanks in advance,

        • 1. Re: help with how to debug
          Jimmy Wilson Apprentice

          It is unlikely that something other than your code is making changes to your objects.

          You could implement a TreeCacheListener or use one of the pre-existing TreeCacheListener implementations such as TreeCacheView, TreeCacheView2, or ConsoleListener to give you a peek into cache events. Check out the Javadoc packaged as a part of the JBossCache distribution to have a look at the interface and various implementations mentioned.

          • 2. Re: help with how to debug
            plainkeyman Newbie

            thankyou for your suggestion. i tried adding this to my TreeCache (not aop):

            class debugListener implements TreeCacheListener {
             public void nodeCreated(Fqn fqn) { System.out.println( "** node added: " + fqn);}
             public void nodeRemoved(Fqn fqn) { System.out.println( "** node removed: " + fqn);}
             public void nodeModified(Fqn fqn) { System.out.println( "** node modified: " + fqn);}
             public void nodeLoaded(Fqn fqn) { System.out.println("** node loaded: " + fqn);}
             public void nodeEvicted(Fqn fqn) { System.out.println("*** node evicted: " + fqn);}
             public void nodeVisited(Fqn fqn) {}
             public void cacheStarted(TreeCache cache) {}
             public void cacheStopped(TreeCache cache) {}
             public void viewChange(View new_view) { System.out.println("** view change: " + new_view);

            unfortunately my object still changed without printing a "node modified" statement. so i know it has to be something i'm doing wrong. but how do i find it?
            the actual part of my object that actually changes is a 'private member' (an int[]). the accessor method does not even get called (i tried printing stuff there).
            i tried putting a breakpoint on it but there are hundreds of of these objects -- with hundreds of legitimate accesses.

            the weird part of the problem is that it only happens after like 30 min with other objects being accessed.

            sorry i'm rambling on here... here's my questions:
            1) are there any timeout values in the treecache that i may not know about (this a local cache)
            2) i do implement clone(), hashCode(), toString() in all of my objects... (i've looked at them and they seem ok). does treecache call these methods after a long period of time?
            3) is there a debugger that can show me all instances of an object and let me put a breakpoint on just one of them?
            4) is there a tool the will let me see all of the references to an object (maybe some strange piece of code still has a refeference to my object and i don't know about it)

            • 3. Re: help with how to debug
              plainkeyman Newbie

              ok i think i found it. i was storing several of my entity beans into one object. then i was caching this object in jboss-cache. some how the entity beans were changing (but they still shouldn't have). i got around this by caching a clone of the objects.

              should i not be doing this?