Debugging passivation errors in JBoss AS

Submitted by Jochus on Mon, 06/08/2012 - 21:58 | Posted in: Java

The problem

Did you ever have issues passivating/serializing beans? Was the error/stacktrace very unclear? Do you want to know what exactly goes wrong in the passivation process? Passivation errors can be a real pain in the ass, ... but they can also be simply clarified.

An example

We were constantly getting the following stacktrace when one of our stateful session beans was passivated. The session bean was passivated after idling the application for 5 minutes. So you login into the application, you setup and use the bean. And then, you leave the bean for more then 5 minutes idle.

Example stacktrace:

at org.jboss.ejb3.stateful.StatefulBeanContext.writeExternal(
at org.jboss.serial.persister.ExternalizePersister.writeData(
at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(
at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(
at org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.passivateSession(
at org.jboss.ejb3.cache.simple.SimpleStatefulCache.passivate(
at org.jboss.ejb3.cache.simple.SimpleStatefulCache$
Caused by: java.lang.NoClassDefFoundError: org/jboss/wsf/spi/serviceref/ServiceRefMetaData
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(
at java.lang.Class.getDeclaredMethod(
at org.jboss.serial.classmetamodel.ClassMetaData.lookupMethodOnHierarchy(
at org.jboss.serial.classmetamodel.ClassMetaData.lookupInternalMethods(
at org.jboss.serial.classmetamodel.ClassMetaData.(
at org.jboss.serial.classmetamodel.ClassMetamodelFactory.getClassMetaData(
at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(
at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(
at org.jboss.serial.persister.ArrayPersister.saveObjectArray(
at org.jboss.serial.persister.ArrayPersister.writeData(
at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.describeObject(
at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectOutput.writeObject(
at org.jboss.serial.persister.RegularObjectPersister.writeSlotWithFields(
at org.jboss.serial.persister.ObjectOutputStreamProxy.writeFields(
at org.jboss.serial.persister.ObjectOutputStreamProxy.defaultWriteObject(
at java.util.Vector.writeObject(
... 261 more
at java.util.Vector.writeObject(
... 261 more
Caused by: java.lang.ClassNotFoundException: org.jboss.wsf.spi.serviceref.ServiceRefMetaData from BaseClassLoader@36eb1ba3{vfs:///Applications/jboss-6.1.0.Final/server/default/conf/jboss-service.xml}
at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
... 278 more

You could think you're missing a library. In this case, ServiceRefMetaData is part of the jbossws-spi.jar. I really spent a lot of time figuring out why this class is missing. But my conclusion is: JBoss is putting you into the wrong direction. You are spending time solving an exception, which is actually be thrown by a lot of other exceptions.

The solution

First of all, decrease the idleTimeoutSeconds of statefull session beans. This will speed up the passivation process, as also the generation of stacktraces:

  • go to $JBOSS_HOME/server/default/deploy/ejb3-interceptors-aop.xml
  • search for:
       <domain name="Stateful Bean" extends="Base Stateful Bean" inheritBindings="true">
          <!-- NON Clustered cache configuration -->
          <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Cache) AND !class(@org.jboss.ejb3.annotation.Clustered)">
             @org.jboss.ejb3.annotation.Cache ("SimpleStatefulCache")
          <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.PersistenceManager) AND !class(@org.jboss.ejb3.annotation.Clustered)">
             @org.jboss.ejb3.annotation.PersistenceManager ("StatefulSessionFilePersistenceManager")
          <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.CacheConfig) AND !class(@org.jboss.ejb3.annotation.Clustered)">
             @org.jboss.ejb3.annotation.CacheConfig (maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)
  • change idleTimeoutSeconds from 300 to 30

Next, you need the source code of the JBoss Serialization project. You can get all source code here: If you don't know the version of JBoss Serialization, look into the MANIFEST.MF file of jboss-serialization.jar. JBoss 6.1.0.Final is using JBSER_1_0_3_GA for example.
Once you checked out the source code, add the project to Eclipse (there's a .project file, so importing is easy). Put a breakpoint in the class: org.jboss.serial.persister.RegularObjectPersister on line 127.

Finally, attach your debugger to your JBoss installation. When the stacktrace is generated, the debugger of Eclipse will be activated. Attach the source code by choosing: workspace > jboss-serialization.

Now simply follow the stacktrace to figure out on which property passivation is failing:

Add new comment

The content of this field is kept private and will not be shown publicly.


  • Lines and paragraphs break automatically.
  • You can caption images (data-caption="Text"), but also videos, blockquotes, and so on.
  • Web page addresses and email addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <cpp>, <css>, <html5>, <java>, <javascript>, <php>, <sql>, <xml>. The supported tag styles are: <foo>, [foo].
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.