6 Replies Latest reply on Sep 10, 2004 3:14 AM by kburns

    2nd cache not replicated at startup

    kburns Newbie

      Hi,

      I'm having problems with replication at startup of a second cache.

      Using the code below, I'm starting 2 CacheTest applications (each configured as a replicated asyn service), one as a server the other as a client.

      1. I start the server first, it adds objects into the cache (under /a/b) ok. After these objects have been added, I start the client and query it for objects under /a/b. The getChildrenNames() returns null.

      2. I start the client first, then start the server, objects are added into both caches ok.

      The xml config file "META-INF/replAsync-service.xml" is unchanged from the release.

      Each CacheTest is started from a separate DOS window under Windows XP with Java 1.4.2 under the same host (PC).

      I'm at a loss for why the client is not being replicated upon its startup (case 1).

      Any help is much appreciated.

      Many Thanks.



      import org.jboss.cache.*;
      import org.jboss.cache.aop.TreeCacheAop;
      import org.jboss.cache.lock.*;

      import java.lang.System.*;
      import java.io.InputStreamReader;
      import java.io.BufferedReader;
      import java.io.IOException;
      import java.util.Set;

      public class CacheTest implements TreeCacheListener
      {
      public TreeCacheAop myTree;
      public String myType;

      public CacheTest(String theCacheType)
      {
      System.out.println("Start");
      myType = theCacheType;

      try
      {
      myTree = new TreeCacheAop();
      myTree.addTreeCacheListener(this);
      PropertyConfigurator config = new PropertyConfigurator(); // configure tree cache.
      config.configure(myTree, "META-INF/replAsync-service.xml");
      myTree.setClusterName("vtest");

      long time0 = System.currentTimeMillis();

      myTree.start();

      if (theCacheType.compareTo("server") == 0)
      {
      createObjects();
      }

      long time1 = System.currentTimeMillis();
      long time = time1 - time0;
      System.out.println("Start Service took [" + time + "]");

      }
      catch (Exception excep)
      {
      System.out.println("Exception");
      }

      System.out.println("End");

      }

      public void cacheStopped(TreeCache theCache)
      {
      }

      public void cacheStarted(TreeCache theCache)
      {
      System.out.println("cacheStarted");
      }

      public void nodeCreated(Fqn theFqn)
      {
      System.out.println("nodeCreated");
      }

      public void nodeVisited(Fqn theFqn)
      {
      }

      public void nodeRemoved(Fqn theFqn)
      {
      }

      public void nodeEvicted(Fqn theFqn)
      {
      }

      public void nodeLoaded(Fqn theFqn)
      {
      System.out.println("nodeLoaded");
      }

      public void nodeModified(Fqn theFqn)
      {
      }

      public void viewChange(org.jgroups.View new_view)
      {
      }

      public void queryCache()
      {
      try
      {
      // Query for names
      Set aset = myTree.getChildrenNames("/a/b");
      if (aset == null)
      {
      System.out.println("Cache contents is EMPTY");
      }
      else
      {
      System.out.println("Cache contents = " + aset.toString());
      }
      }
      catch (LockingException excep)
      {
      System.out.println("query cache LockingException");
      }
      catch (TimeoutException excep)
      {
      System.out.println("query cache TimeoutException");
      }

      }

      public void stopCache()
      {
      myTree.stop();
      }

      public static void main(String args[])
      {
      System.out.println("args=" + args[0]);
      CacheTest ct = new CacheTest(args[0]);
      String line;
      BufferedReader keyInput = new BufferedReader(new InputStreamReader(System.in));

      System.out.println("Options:");
      System.out.println("1 exit");
      System.out.println("2 ...");

      try
      {
      while ((line = keyInput.readLine()) != null)
      {

      if (line.compareTo("1") == 0)
      {
      ct.stopCache();
      break;
      }
      else if (line.compareTo("3") == 0)
      {
      ct.queryCache();
      }
      System.out.println("Options:");
      System.out.println("1 = exit");
      System.out.println("2 = start cache");
      System.out.println("3 = query cache");
      System.out.print("Enter Option: ");

      }
      }
      catch (IOException exception)
      {
      }
      }


      public void createObjects()
      {
      .... create an object, "object" ...
      try
      {
      myTree.putObject("/a/b", object);
      }
      catch (Exception excpt)
      {

      }

      }
      }

        • 1. 3854976
          kburns Newbie


          Hello

          thanks for considering my problem....

          well!

          when i have deployed the firebird-ds.xml and firebirdsql.jar jboss gives the following message in its context:

          00:32:38,562 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
           MBeans waiting for other MBeans:
           ObjectName: jboss.jca:service=TxCM,name=FirebirdDS
           state: CREATED
           I Depend On: jboss.jca:service=ManagedConnectionPool,name=FirebirdDS
           jboss.jca:service=CachedConnectionManager
           jboss:service=TransactionManager
          
           Depends On Me: jboss.jca:service=ConnectionFactoryBinding,name=FirebirdDS
          
           ObjectName: jboss.jca:service=ManagedConnectionPool,name=FirebirdDS
           state: CREATED
           I Depend On: jboss.jca:service=ManagedConnectionFactory,name=FirebirdDS
          
           Depends On Me: jboss.jca:service=TxCM,name=FirebirdDS
          
           ObjectName: jboss.jca:service=ManagedConnectionFactory,name=FirebirdDS
           state: FAILED
           I Depend On: jboss.jca:service=RARDeployment,name='firebirdsql.rar'
          
           Depends On Me: jboss.jca:service=ManagedConnectionPool,name=FirebirdDS
           org.jboss.deployment.DeploymentException: couldn't get oldRarDeployment! jboss.jca:service=RARDeployment,name='firebirdsql.rar'; - nested throwable: (org.jboss.deployment.DeploymentException: ConnectionDefinition 'null' not found in rar 'firebirdsql.rar')
           ObjectName: jboss.jca:service=ConnectionFactoryBinding,name=FirebirdDS
           state: CREATED
           I Depend On: jboss.jca:service=TxCM,name=FirebirdDS
          
           Depends On Me:
          
           MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM:
           ObjectName: jboss.jca:service=ManagedConnectionFactory,name=FirebirdDS
           state: FAILED
           I Depend On: jboss.jca:service=RARDeployment,name='firebirdsql.rar'
          
           Depends On Me: jboss.jca:service=ManagedConnectionPool,name=FirebirdDS
           org.jboss.deployment.DeploymentException: couldn't get oldRarDeployment!jboss.jca:service=RARDeployment,name='firebirdsql.rar'; - nested throwable: (org.jboss.deployment.DeploymentException: ConnectionDefinition 'null' not found in rar 'firebirdsql.rar')


          and in addition when i used java:/FirebirdDS in my jboss.xml file i got the follwoing message at jboss server console:

          00:36:43,203 INFO [STDOUT] ejbCreate()
           00:36:43,296 INFO [STDOUT]
           Day 9: Demonstrate the use of JDBC...
           00:36:43,296 INFO [STDOUT] initDB: Get initial context from the JNDI service...
          
           00:36:43,312 INFO [STDOUT] Lookup the DataSource as configured by administrator
           ...
           00:36:43,343 INFO [STDOUT] Exception was thrown: Could not dereference object
           00:36:43,359 INFO [STDOUT] Run some DDL statements:



          But it worked out fine when i used java:/DefaultDS(which is set to hypersonic database) in jboss.xml file and it gives the following message

          00:43:09,656 INFO [STDOUT] ejbCreate()
           00:43:09,796 INFO [STDOUT]
           Day 9: Demonstrate the use of JDBC...
           00:43:09,796 INFO [STDOUT] initDB: Get initial context from the JNDI service...
          
           00:43:09,796 INFO [STDOUT] Lookup the DataSource as configured by administrator
           ...
           00:43:09,812 INFO [STDOUT] Getting a Connection from the pool...
           00:43:09,812 INFO [STDOUT] Connection is obtained...
           00:43:09,828 INFO [STDOUT] Run some DDL statements:
           00:43:09,828 INFO [STDOUT] Query Database Metadata:
           00:43:10,000 INFO [STDOUT] Product Name: HSQL Database Engine
           00:43:10,000 INFO [STDOUT] Driver Name: HSQL Database Engine Driver
           00:43:10,000 INFO [STDOUT] Database Schemas:
           00:43:10,140 INFO [STDOUT] TABLE_SCHEM
           00:43:10,140 INFO [STDOUT] ,
           00:43:10,140 INFO [STDOUT] TABLE_CATALOG
           00:43:10,140 INFO [STDOUT] Printing all Data Tables for Schema: TABLE_SCHEM
           00:43:10,156 INFO [STDOUT] Hello world method called
           00:36:43,375 INFO [STDOUT] Query Database Metadata:
           00:36:43,375 INFO [STDOUT] Exception was thrown: null
           00:36:43,375 INFO [STDOUT] Hello world method called


          you can see the code for bean impleantation class and Client in QueryDBBean.java and Client.java respectively in my last query posted with sender name ishq.

          thanks again for considering my query
          ishq




          • 2. Re: 2nd cache not replicated at startup
            Ben Wang Master

            Best way is turn on DEBUG log tracing in org.jboss.cache to see how it actually works. If it is doing replication, you should see it something like _put()...

            Or opening up a TreeCacheView GUI (see build.xml for details) to be in the same group. You will see it visually.

            -Ben

            • 3. Re: 2nd cache not replicated at startup
              kburns Newbie

              Hi Ben,

              I've been looking through the logs. After adding the flag:

              -Djava.system.class.loader=org.jboss.aop.standalone.SystemClassLoader

              when running my test apps, I can see that when starting the client app, a:

              java.io.NotSerializableException: MyClass

              is appearing on the server console logging - where "MyClass" is the classname of the object I have added to the server cache. From reading through the TreeCacheAop tutorial, I can see that I need to create a jboss-aop.xml file for my class "MyClass" to be used in conjunction with the new class loader.

              I've tried adding the "aopc" target to my ant build file so that I can create the jboss-aop.xml file as per the build.xml file in the root directory of the release.

              But am getting the following build error:

              aopc:
              [aopc] [deploying] file:/H:/java/source/build/etc/META-INF/jboss-aop.xml
              [aopc] java.lang.RuntimeException: [error] failed to load aop path: H:\java\source\build\etc\META-INF\jboss-aop.xml

              I thought that the aopc target created the jboss-aop.xml file, but from the error it appears that it requires it as an input?

              Can you shed some light on what I am seeing? I've dug around the AOP wiki site for the jboss-aop.xml file format (so I can manually create it) but can't find it.

              Many thanks,

              Ken

              • 4. Re: 2nd cache not replicated at startup
                Ben Wang Master

                No, you will need create jboss-aop.xml for aopc as well. Idea of aopc is to pre-generate the byte code so you don't further class loader and jboss-aop.xml during runtime.

                Look into the etc directory, there is an example of jboss-aop.xml for Person.

                -Ben

                • 5. Re: 2nd cache not replicated at startup
                  kburns Newbie

                  Hi Ben,

                  To sort out my problems I've gone back to a simple example. I'm still using the server/client framework, but am now using the Person / Student / Address class examples that come with the "standAloneAop" directory to populate my Server's cache with.

                  I'm using the aop compiler to compile the classes using the following lines in the jboss-aop.xml file:

                  prepare expr="all(Student)"
                  prepare expr="all(Person)"
                  prepare expr="all(Address)"

                  (xml code around the lines has been omitted)

                  My server and client compile and run without any problems. My client replicates the servers cache upon startup successfully.

                  However, when I add a constructor to the "Student" class (which is derived from the "Person" class) and this constructor declares a parameter (theCourse), as below:

                  public class Student extends Person
                  {
                  private String year;

                  public String getYear() { return year; }
                  public void setYear(String year) { this.year = year; }

                  public Student(String theCourse)
                  {
                  }
                  ....
                  }

                  my Client does not replicate the Server's cache upon startup. This is the same behaviour I saw with my own classes in the first posting.

                  The logging at the client side for a getObject() followed by a query (getName() and getAddress()) on the successful replication looks something like:

                  102172 [main] TRACE org.jboss.cache.aop.TreeCacheAop - calling method _get
                  102172 [main] DEBUG org.jboss.cache.aop.TreeCacheAop - get(, "/a/b/obj1", AOPInstance, "false")
                  102172 [main] TRACE org.jboss.cache.aop.TreeCacheAop - calling method _get
                  102172 [main] DEBUG org.jboss.cache.aop.TreeCacheAop - get(, "/a/b/obj1", AOPInstance, "false")
                  102172 [main] TRACE org.jboss.cache.aop.TreeCacheAop - calling method _get
                  102172 [main] DEBUG org.jboss.cache.aop.TreeCacheAop - get(, "/a/b/obj1", name, "true")
                  102172 [main] TRACE org.jboss.cache.aop.TreeCacheAop - calling method _get
                  102172 [main] DEBUG org.jboss.cache.aop.TreeCacheAop - get(, "/a/b/obj1", AOPInstance, "false")
                  102172 [main] TRACE org.jboss.cache.aop.TreeCacheAop - calling method _get
                  102172 [main] DEBUG org.jboss.cache.aop.TreeCacheAop - get(, "/a/b/obj1", name, "true")


                  whereas when the constructor has a parameter, the logging for the getObject() and queries appears as:

                  12250 [main] TRACE org.jboss.cache.aop.TreeCacheAop - calling method _get
                  12250 [main] DEBUG org.jboss.cache.aop.TreeCacheAop - get(, "/a/b/obj1", AOPInstance, "false")
                  12264 [main] TRACE org.jboss.cache.aop.TreeCacheAop - calling method _get
                  12265 [main] DEBUG org.jboss.cache.aop.TreeCacheAop - get(, "/a/b/obj1", jboss:internal:class, "false")

                  and an Exception is throw as a result of the getObject() call.


                  Why is having a parameter in the constructor a problem?

                  Is this a limitation with AOP or have I missed something (in my jboss-aop.xml file or somewhere else). Note that having a constructor without the parameter works fine, even with data members in the constructor body being initialised to some value.

                  Many thanks for your help,

                  Regards

                  Ken

                  • 6. Re: 2nd cache not replicated at startup
                    Ben Wang Master

                    Ken,

                    I don't see you have also defined a default no arg constructor for Student. Just like class that implements Serializable, it will require a such constructor to be able to re-construct on the other end.

                    -Ben