7 Replies Latest reply on Dec 15, 2005 11:56 AM by Raúl Costa

    TreeCache - JDBCCacheLoader - Failed to lookup datasource!

    Raúl Costa Newbie

      Hi!

      I'm trying to put toghether the JDBCCacheLoader, but when I do it JBoss TreeCache MBean isn´t deployed. I've already tryed to specify a dependency on the datasource but it still doesn't work.

      Output
      11:50:00,312 INFO [TreeCache] new cache is null (may be first member in cluster)
      11:50:00,312 INFO [TreeCache] state could not be retrieved (must be first member in group)
      11:50:00,312 ERROR [JDBCCacheLoader] Failed to lookup datasource java:/DefaultDS: DefaultDS not bound
      javax.naming.NameNotFoundException: DefaultDS not bound

      <attribute name="CacheLoaderClass">org.jboss.cache.loader.JDBCCacheLoader</attribute>
       <attribute name="CacheLoaderShared">true</attribute>
       <attribute name="CacheLoaderPreload">/</attribute>
       <attribute name="CacheLoaderFetchTransientState">true</attribute>
       <attribute name="CacheLoaderFetchPersistentState">true</attribute>
       <attribute name="CacheLoaderConfig">
       cache.jdbc.datasource=java:/DefaultDS
       </attribute>


      My final purpose is to redefine JDBCacheLoader's setCache method to include my own datasource to preload treecache with a bunch of data from a Oracle database. I don't want to have just persistence, but a class that gets from the database specific data and puts it into the TreeCache.

      Could you please help me!

        • 1. Re: TreeCache - JDBCCacheLoader - Failed to lookup datasourc
          Brian Stansberry Master

          Are you using JBossCache 1.2.4 beta? This sounds like http://jira.jboss.com/jira/browse/JBCACHE-303, which was fixed in the final 1.2.4 release.

          • 2. Re: TreeCache - JDBCCacheLoader - Failed to lookup datasourc
            Raúl Costa Newbie

            I've checked my version and I even downloaded it again. I'm using JBossCache 1.2.4 version released on 20 October, so it is the final version.

            Is it possible that the bug wasn't completely solved or am I doing something wrong? The error I'm having is exactely the same reported in http://jira.jboss.com/jira/browse/JBCACHE-303.

            Thanks again.

            • 3. Re: TreeCache - JDBCCacheLoader - Failed to lookup datasourc
              Brian Stansberry Master

              <p>How were you specifying the cache dependency?  With 4.0.3SP1, adding this to a treecache's -service.xml file worked. <br/> <br/>[<depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends> | <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>]</p>

              • 4. Re: TreeCache - JDBCCacheLoader - Failed to lookup datasourc
                Brian Stansberry Master

                Sorry, forgot the forum hates xml :-)

                Imagine it was surrounded by a "depends" tag

                • 5. Re: TreeCache - JDBCCacheLoader - Failed to lookup datasourc
                  Raúl Costa Newbie

                  I have my problem solved with this include as the lookup() of my DataSource works fine now thaks to the include you recommended.

                  But I find curious the fact that I have a Oracle datasource defined by my self and if I try to stablish the dependency on that DataSource on the -service.xml file that datasource isn't bound before the TreeCache setCache() method in the CacheLoader, as it should be.

                  My DataSource is defined this way

                  <datasources>
                   <local-tx-datasource>
                   <jndi-name>agorang/alarmMonitorDB</jndi-name>
                   <connection-url>jdbc:oracle:thin:@localhost_IP:PORT:SEQ9i</connection-url>
                   <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
                   <user-name>123</user-name>
                   <password>xxx</password>
                   <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
                   <blocking-timeout-millis>0</blocking-timeout-millis>
                   <idle-timeout-minutes>1</idle-timeout-minutes>
                   <max-pool-size>100</max-pool-size>
                   <min-pool-size>10</min-pool-size>
                   </local-tx-datasource>
                  </datasources>


                  The "debug", when I include the dependency on my datasource looks like this:
                  14:25:57,546 INFO [STDOUT] super setCache
                  14:25:57,546 INFO [STDOUT] init()
                  14:25:57,562 ERROR [main][agorang.helpers.MyCacheLoader] - javax.naming.NameNotFoundException: agorang not bound
                  14:25:57,562 ERROR [MyCacheLoader] javax.naming.NameNotFoundException: agorang not bound
                  14:25:57,562 ERROR [main][agorang.helpers.MyCacheLoader] - java.lang.NullPointerException
                  14:25:57,562 ERROR [MyCacheLoader] java.lang.NullPointerException
                  14:25:57,562 INFO [STDOUT]
                  cacheAllOperators(/pt/ptinovacao/agorang/catOperadores/)
                  14:25:57,562 ERROR [main][agorang.helpers.MyCacheLoader] - java.lang.NullPointerException
                  14:25:57,562 ERROR [MyCacheLoader] java.lang.NullPointerException
                  14:25:57,562 INFO [STDOUT] setCache method succeeded.
                  14:25:57,593 INFO [TreeCache] interceptor chain is:
                  class org.jboss.cache.interceptors.CallInterceptor
                  class org.jboss.cache.interceptors.PessimisticLockInterceptor
                  class org.jboss.cache.interceptors.CacheLoaderInterceptor
                  class org.jboss.cache.interceptors.UnlockInterceptor
                  class org.jboss.cache.interceptors.ReplicationInterceptor
                  class org.jboss.cache.interceptors.CacheStoreInterceptor
                  14:25:57,593 INFO [TreeCache] cache mode is REPL_SYNC
                  14:25:57,703 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=a
                   gorang/alarmMonitorDB' to JNDI name 'java:agorang/alarmMonitorDB'


                  Note that the binding of the DataSource is done after is has been looked up wich causes the ERROR.

                  I would like to be sure thad including the dependency on the DefaultDatasource all other DataSources are bound in time to be used by methods in CacheLoader classes.

                  Thanks for your attention.

                  • 6. Re: TreeCache - JDBCCacheLoader - Failed to lookup datasourc
                    Brian Stansberry Master

                    I don't understand -- did you make your depends on "'jboss.jca:service=DataSourceBinding,name=agorang/alarmMonitorDB"?? If not, that's what you need to do.

                    • 7. Re: TreeCache - JDBCCacheLoader - Failed to lookup datasourc
                      Raúl Costa Newbie

                      Sorry if I didn't make myself clear.

                      When I include the dependency on agorang/alarmMonitorDB it doesn't work!

                      When I include the dependency on DefaultDS JBoss binds the DefaultDS and the agorang/alarmMonitorDB DataSources.
                      So I can use my DataSource to preload TreeCache with MyCacheLoader class.