5 Replies Latest reply on Nov 8, 2010 11:48 AM by liumin hu

    JDBCCacheLoader failed to obtain connection with JNDI naming

    Alan Feng Novice

      I am using:
      - JBoss AS 4.2.3.GA
      - JBoss Cache 3.2.0

      in the configuration, I am setting the loader as:

       <loaders passivation="false" shared="false">
       <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">

      But this throws exception during startup due to not able to grab a connection using the datasource specified above, and when I inspect the JNDI tree, the DefaultDS does exist.

      So I traced into it, it seems that, when retrieving the datasource using the JNDI name, it can not find the the factory class org.jboss.naming.NonSerializableFactory class, which included in the jboss-common-core.jar file and deployed with my EAR file, and therefore, returns a null. The original ClassNotFound exception is ignored in the javax.naming.spi.NamingManager class when it tries to instantiate the factory class.

      I don't understand why this class is not found, as it is already included in the EAR/lib folder. The class that tries to lookup the JNDI datasource is org.jboss.cache.loader.ManagedConnectionFactory, which is in the jbosscache-core.jar file, and is in the same EAR/lib folder. So it should be able to see the NonSerializableFactory class just fine.

      I wonder if I am the only one having this problem using the JDBCCacheLoader with JNDI name. Any help is appreciated.


        • 1. Re: JDBCCacheLoader failed to obtain connection with JNDI na
          Alan Feng Novice

          I put a simple test class to lookup the "java:/DefaultDS" and it failed as well. It seems more of a JNDI naming issue, so I'll post a new thread in the JNDI forum.

          • 2. Re: JDBCCacheLoader failed to obtain connection with JNDI na
            Alan Feng Novice

            So I created a test EAR that contains only one simple Servlet that looks up the DataSource using the JNDI name to verify that the problem is with JNDI lookup. This time it worked just fine. I am guessing that my problem is related to the EAR. I'll post my updates after I examine the EAR closely.

            • 3. Re: JDBCCacheLoader failed to obtain connection with JNDI na
              Alan Feng Novice

              After some trial and error, I finally located the problem. It seems that the org.jboss.util.naming.NonSerializableFactory class in the required jboss-common-core.jar dependent library is causing any JNDI lookup to fail.

              I've created a issue with the JBoss Common project:

              • 4. Re: JDBCCacheLoader failed to obtain connection with JNDI na
                Srinivas Chamarthi Newbie

                I should have seen this before posting another similar issue. I have the same problem with jboss-common-core.jar with Jboss Portal 2.7.2(Base Jboss 4.2.3) , Spring 3.0.0.M3. When included, my other datasource, queue looks in Spring Context file are not recognized.

                i been struggling for last two weeks to get around this problem.

                However after removing the factory class from jar file as you have suggested in the JIRA issue, when I bind the cache to JNDI, I am getting the following exception

                caused by: java.io.NotSerializableException: org.jboss.cache.invocation.CacheInvocationDelegate
                 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
                 at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
                 at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
                 at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
                 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
                 at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
                 at java.rmi.MarshalledObject.<init>(MarshalledObject.java:92)
                 at org.jnp.interfaces.MarshalledValuePair.<init>(MarshalledValuePair.java:65)
                 at org.jnp.interfaces.NamingContext.rebind(NamingContext.java:508)

                Can you tell me what is wrong with this ?

                Appreciate any help in this regard.

                thx & rgds,

                • 5. Re: JDBCCacheLoader failed to obtain connection with JNDI na
                  liumin hu Master



                  i see the bug is not resolved. I have the same problem. I want to know if jboss cache can work with jboss AS 4.2?


                  thanks in advance