7 Replies Latest reply on May 24, 2012 4:56 AM by Martin Gencur

    Cacheloaders with RDBMS

    Frederic Hornain Newbie

      Dear *,

       

      Well, I tried to use infinispan in association with RDBMS like Postgresql.

      So I followed the documentation written at the following URL : https://docs.jboss.org/author/display/ISPN/CacheLoaders

       

      However I was not able to make it work with Postgresql.

      Then I tried with HSQLDB - HyperSQL - with the stanza provided in the infinispan documentation at the following URL : https://docs.jboss.org/author/display/ISPN/CacheLoaders

      Unfortunately, it did not work.

      Finally,  I tried with flat file and that time it worked perfectly.

       

      So what did I do wrong/ forgot ?

      Do I have to put a Postgresql/HSQLDB jdbc 4 in a specific directory - e.g. infinispan/modules/... - ?

      I assume that if I am able to make it work with h2 (HSQLDB) I would be able to make it work with Postgresql.

      However, if you have the procedure or the correct loaders stanza for Postgresql I would be happy.

       

      Rem : FYI, I tried the configuration mentionned in the following posts : https://community.jboss.org/message/724955 , https://community.jboss.org/thread/173047 in modifing some elements without success.

       

      Thanks in adavnce for your great help and your support.

       

      Best Regards

      Frederic

        • 1. Re: Cacheloaders with RDBMS
          Tristan Tarrant Master

          Hi Frederic,

           

          your JDBC driver JAR should be in the classpath. You don't mention how you are running the application: standalone JVM, application server, etc.

           

          Tristan

          • 2. Re: Cacheloaders with RDBMS
            Frederic Hornain Newbie

            Hi Tristan,

             

            Well, I assume I ran infinispan in a standalone JVM casue I ran it from the startServer.sh command from the  infinispan-5.1.4.CR1 packages.

            - Assuming the infinispan-5.1.4.CR1 package do not contain hidden application server -

             

            In regards of the classpath, I add the path where my jdbc are in the script file functions.sh

            But I still have the same behaviour ->

             

            Failed to boot JBoss:

            java.lang.reflect.InvocationTargetException

                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

                at java.lang.reflect.Constructor.newInstance(Constructor.java:525)

                at org.infinispan.server.core.Main$.createCacheManager(Main.scala:176)

                at org.infinispan.server.core.Main$.instantiateCacheManager(Main.scala:154)

                at org.infinispan.server.core.Main$.boot(Main.scala:134)

                at org.infinispan.server.core.Main$$anon$1.call(Main.scala:94)

                at org.infinispan.server.core.Main$$anon$1.call(Main.scala:91)

                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

                at java.util.concurrent.FutureTask.run(FutureTask.java:166)

                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)

                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

                at java.lang.Thread.run(Thread.java:722)

            Caused by: org.infinispan.config.ConfigurationException: org.infinispan.CacheConfigurationException: Unable to instantiate class org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore

                at org.infinispan.configuration.parsing.Parser.parse(Parser.java:149)

                at org.infinispan.configuration.parsing.Parser.parse(Parser.java:111)

                at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:368)

                at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:340)

                at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:327)

                ... 16 more

            Caused by: org.infinispan.CacheConfigurationException: Unable to instantiate class org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore

                at org.infinispan.util.Util.loadClass(Util.java:89)

                at org.infinispan.util.Util.getInstance(Util.java:207)

                at org.infinispan.configuration.parsing.Parser.parseLoader(Parser.java:527)

                at org.infinispan.configuration.parsing.Parser.parseLoaders(Parser.java:505)

                at org.infinispan.configuration.parsing.Parser.parseCache(Parser.java:276)

                at org.infinispan.configuration.parsing.Parser.parseDefaultCache(Parser.java:241)

                at org.infinispan.configuration.parsing.Parser.doParse(Parser.java:169)

                at org.infinispan.configuration.parsing.Parser.parse(Parser.java:135)

                ... 20 more

            Caused by: java.lang.ClassNotFoundException: org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore

                at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

                at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

                at java.security.AccessController.doPrivileged(Native Method)

                at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

                at java.lang.ClassLoader.loadClass(ClassLoader.java:423)

                at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

                at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

                at java.lang.Class.forName0(Native Method)

                at java.lang.Class.forName(Class.java:264)

                at org.infinispan.util.Util.loadClassStrict(Util.java:126)

                at org.infinispan.util.Util.loadClass(Util.java:87)

                ... 27 more

            Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.reflect.InvocationTargetException

                at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)

                at java.util.concurrent.FutureTask.get(FutureTask.java:111)

                at org.infinispan.server.core.Main$.main(Main.scala:112)

                at org.infinispan.server.core.Main.main(Main.scala)

            Caused by: java.lang.reflect.InvocationTargetException

                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

                at java.lang.reflect.Constructor.newInstance(Constructor.java:525)

                at org.infinispan.server.core.Main$.createCacheManager(Main.scala:176)

                at org.infinispan.server.core.Main$.instantiateCacheManager(Main.scala:154)

                at org.infinispan.server.core.Main$.boot(Main.scala:134)

                at org.infinispan.server.core.Main$$anon$1.call(Main.scala:94)

                at org.infinispan.server.core.Main$$anon$1.call(Main.scala:91)

                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

                at java.util.concurrent.FutureTask.run(FutureTask.java:166)

                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)

                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

                at java.lang.Thread.run(Thread.java:722)

            Caused by: org.infinispan.config.ConfigurationException: org.infinispan.CacheConfigurationException: Unable to instantiate class org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore

                at org.infinispan.configuration.parsing.Parser.parse(Parser.java:149)

                at org.infinispan.configuration.parsing.Parser.parse(Parser.java:111)

                at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:368)

                at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:340)

                at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:327)

                ... 16 more

            Caused by: org.infinispan.CacheConfigurationException: Unable to instantiate class org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore

                at org.infinispan.util.Util.loadClass(Util.java:89)

                at org.infinispan.util.Util.getInstance(Util.java:207)

                at org.infinispan.configuration.parsing.Parser.parseLoader(Parser.java:527)

                at org.infinispan.configuration.parsing.Parser.parseLoaders(Parser.java:505)

                at org.infinispan.configuration.parsing.Parser.parseCache(Parser.java:276)

                at org.infinispan.configuration.parsing.Parser.parseDefaultCache(Parser.java:241)

                at org.infinispan.configuration.parsing.Parser.doParse(Parser.java:169)

                at org.infinispan.configuration.parsing.Parser.parse(Parser.java:135)

                ... 20 more

            Caused by: java.lang.ClassNotFoundException: org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore

                at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

                at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

                at java.security.AccessController.doPrivileged(Native Method)

                at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

                at java.lang.ClassLoader.loadClass(ClassLoader.java:423)

                at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

                at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

                at java.lang.Class.forName0(Native Method)

                at java.lang.Class.forName(Class.java:264)

                at org.infinispan.util.Util.loadClassStrict(Util.java:126)

                at org.infinispan.util.Util.loadClass(Util.java:87)

                ... 27 more

             

            Thanks for your help.

             

            Best Regards

            Frederic

            • 3. Re: Cacheloaders with RDBMS
              Frederic Hornain Newbie

              Dear *,

               

              Well, it seems I did a mistake I made a confusion between h2 database and HSQLDB - HyperSQL -.

              I am going to redo my tests.

               

              BR

              Frederic

              • 4. Re: Cacheloaders with RDBMS
                Galder Zamarreño Master

                That ClassNotFoundException means that you're missing modules/cachestores/jdbc/infinispan-cachestore-jdbc.jar in the path of startServer.sh. This jar is shipped in our distro.

                • 5. Re: Cacheloaders with RDBMS
                  Frederic Hornain Newbie

                  Hi Galder,

                   

                  Well, I try your tip and it brang me to a next error message :

                   

                  Caused by: org.infinispan.config.ConfigurationException: Couldn't find a setter named [setCreateTableOnStartForStrings] which takes a single parameter, for parameter createTableOnStartForStrings on class [class org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStoreConfig]

                   

                  BTW, I am using infinispan-5.1.5.CR1.

                   

                  Thanks for your help and your time.

                   

                  Sincerly

                  Frederic

                  • 6. Re: Cacheloaders with RDBMS
                    Martin Gencur Novice

                    createTableOnStartForStrings property is only applicable to JdbcMixedCacheStore. I see the StringBased one being used in your error. Use "createTableOnStart" for StringBased Jdbc cache store.

                    • 7. Re: Cacheloaders with RDBMS
                      Martin Gencur Novice

                      Btw, I recently wrote an article about configuring Jdbc cache stores. That might help you as well: http://martingencur.blogspot.com/