Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-5464

NullPointerException using Hibernate SecondLevel Cache at InitialState phase

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • EAP_EWP 5.2.0
    • EAP 5.0.1
    • Clustering, Hibernate
    • None
    • JBoss EAP 5.1.0, JDK 1.6 Sun/Oracle, Fedora 14

    • Hide

      Attached here simple classes for test. The Entity is cacheable:

      @Entity
      @Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL)
      public class Entity1 implements Serializable {
      ...

      To test:

      • set DEBUG level for JBossCache in JBoss
      • make the deployment of .ear (attached) on two JBoss clustered instances
      • start the first instance
      • execute a lookup to EJB, and insert a entity. For example (Main.class attached):

      public static void main(String[] args) {
      try

      { InitialContext context = new InitialContext(); SessionIF sessionIF = (SessionIF) context.lookup("seamejbtest-ear/Session1/remote"); sessionIF.createEntity(1l, "Alessandro", 19); }

      catch (Exception e)

      { e.printStackTrace(); }

      }

      • look in jmx-console the mbean: config=timestamps-cache,service=Cache and click on the method printCacheDetails. In the tree is visible the entity
      • start the second instance
      • look server.log of the second instance, you should find the exception: "Caught exception integrating state! org.jboss.cache.CacheException: java.lang.NullPointerException"
      • look in jmx-console of your second instance the mbean: config=timestamps-cache,service=Cache and click on the method printCacheDetails. In this tree, the entity is not found, because the cache not caught the previous state of the cluster.
      Show
      Attached here simple classes for test. The Entity is cacheable: @Entity @Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL) public class Entity1 implements Serializable { ... To test: set DEBUG level for JBossCache in JBoss make the deployment of .ear (attached) on two JBoss clustered instances start the first instance execute a lookup to EJB, and insert a entity. For example (Main.class attached): public static void main(String[] args) { try { InitialContext context = new InitialContext(); SessionIF sessionIF = (SessionIF) context.lookup("seamejbtest-ear/Session1/remote"); sessionIF.createEntity(1l, "Alessandro", 19); } catch (Exception e) { e.printStackTrace(); } } look in jmx-console the mbean: config=timestamps-cache,service=Cache and click on the method printCacheDetails. In the tree is visible the entity start the second instance look server.log of the second instance, you should find the exception: "Caught exception integrating state! org.jboss.cache.CacheException: java.lang.NullPointerException" look in jmx-console of your second instance the mbean: config=timestamps-cache,service=Cache and click on the method printCacheDetails. In this tree, the entity is not found, because the cache not caught the previous state of the cluster.
    • Hide

      Disable query cache.
      In persistence.xml:
      <property name="hibernate.cache.use_query_cache" value="false"/>
      or omit altogether (query cache is disabled by default).

      Show
      Disable query cache. In persistence.xml: <property name="hibernate.cache.use_query_cache" value="false"/> or omit altogether (query cache is disabled by default).
    • Using the Hibernate SecondLevel Cache with JBossCache configured to TimestampRegionImpl can occur NullPointerException at cache initialization. This fix adds a Null Pointer checker to allow the cache be initialized successfully
    • Not Required

    Description

      At a JBoss Cluster, when Hibernate is configured to use Second Level Cache in JBossCache2 with timestamp setting, the second JBoss instance to be initialized throws NullPointerException, starting State Integration.

      You just note this exception if change log level category for JBossCache to DEBUG:

      jboss-log4j.xml:

      <category name="org.jboss.cache">
      <priority value="DEBUG"/>
      </category>

      The exception in server.log (full log attached):

      2010-11-24 00:22:35,779 DEBUG [org.jboss.cache.remoting.jgroups.ChannelMessageListener] (Incoming-5,127.0.0.1:55200) Caught exception integrating state!
      org.jboss.cache.CacheException: java.lang.NullPointerException
      at org.jboss.cache.statetransfer.DefaultStateTransferIntegrator.integrateTransientState(DefaultStateTransferIntegrator.java:251)
      at org.jboss.cache.statetransfer.DefaultStateTransferIntegrator.integrateState(DefaultStateTransferIntegrator.java:113)
      at org.jboss.cache.statetransfer.DefaultStateTransferManager.setState(DefaultStateTransferManager.java:201)
      at org.jboss.cache.statetransfer.DefaultStateTransferManager.setState(DefaultStateTransferManager.java:165)
      ...
      Caused by: java.lang.NullPointerException
      at org.hibernate.cache.jbc2.timestamp.TimestampsRegionImpl.nodeModified(TimestampsRegionImpl.java:165)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.jboss.cache.notifications.NotifierImpl$ListenerInvocation$1.run(NotifierImpl.java:720)

      As integration state fails, the new node's cache is not updated with cluster cached values

      Attachments

        1. Main.java
          0.5 kB
        2. persistence.xml
          2 kB
        3. Session1.java
          0.8 kB
        4. SessionIF.java
          0.2 kB
        5. Entity1.java
          1 kB
        6. server.log
          115 kB
        7. seamejbtest-ear.ear
          3.89 MB

        Issue Links

          Activity

            People

              rhn-support-alazarot Alessandro Lazarotti
              rhn-support-alazarot Alessandro Lazarotti
              Russell Dickenson Russell Dickenson (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: