Hi darranl,
I'm sure I did not made the fields transient. Only the Log4J Logger object
which is not Serializable that I made it transient. The rest is just normal
instance variable declarations.
I found something strange during activation process. JBoss throws exception
saying my POJO class doesn't have valid constructor. I've tried to
tweak my POJO class to include varies constructors, however, it still shows
me "no valid constructor". Any idea?
--------------------------------------------------------------------------------
2005-06-21 15:35:22,815 DEBUG
[org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager] Attempting to
activate; [EMAIL PROTECTED]
2005-06-21 15:35:22,815 DEBUG
[org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager] Reading session
state
from:
/opt/jboss-4.0/server/default/tmp/sessions/TestStatefulSession-ea7suahx-9/ea7tj4hy-n.ser
2005-06-21 15:35:22,842 DEBUG [org.jboss.ejb.plugins.AbstractInstanceCache]
Activation failure
javax.ejb.EJBException: Could not activate; failed to restore state;
CausedByException is:
com.session.test.StatefulSessPojo; no valid constructor
--------------------------------------------------------------------------------
StatefulSessPojo is a POJO that extends StatefulSessAbs [an abstract class
which implements StatefulSessInf (an interface)]
The stateful session bean has 2 instance variables, a String and a HashMap.
The HashMap stores StatefulSessPojo as the value. In the bean, it has a
remote method to print the HashMap values and a remote method to print a
String. Before passivation, the values are printed OK. It also passivated
successfully. However, during activation, it throws javax.ejb.EJBException
saying "StatefulSessPojo; no valid constructor". Even when I invoke the print
String method first before the print HashMap method.
That's my testing so far, and I'm stuck again. :)
Below is the Stateful session bean class:
public class SimpleStatefulSession implements SessionBean {
/** The SessionContext */
private SessionContext context;
private transient Logger log = Logger.getLogger(getClass().getName());
public EBTestLocalHome entityLocalHome;
public Map groupMap = new HashMap();
public String mapName = "";
public boolean initialized = false;
/**
* @throws CreateException Thrown if the instance could not perform
* the function requested by the container because of an system-level
error.
*
* @ejb.create-method
*/
public void ejbCreate() throws CreateException {
Calendar now = Calendar.getInstance();
log.info(now.getTime() + " [Creating] SimpleStatefulSession EJB");
this.mapName = "Default";
log.info("[Param] map name=" + mapName);
init();
}
/**
* @throws EJBException Thrown if the instance could not perform
* the function requested by the container because of an system-level
error.
*/
public void ejbActivate() throws EJBException {
log = Logger.getLogger(getClass().getName());
Calendar now = Calendar.getInstance();
log.info(now.getTime() + " [Activating] SimpleStatefulSession EJB");
log.info(now.getTime() + " [Activating] Setting initialized to
false");
initialized = false;
log.info(now.getTime() + " [Activating] Calling init()");
init();
}
/**
* @throws EJBException Thrown if the instance could not perform
* the function requested by the container because of an system-level
error.
*/
public void ejbPassivate() throws EJBException {
Calendar now = Calendar.getInstance();
log.info(now.getTime() + " [Passivating] SimpleStatefulSession
EJB");
}
/**
* @throws EJBException Thrown if the instance could not perform
* the function requested by the container because of an system-level
error.
*/
public void ejbRemove() throws EJBException {
Calendar now = Calendar.getInstance();
log.info(now.getTime() + " [Removing] SimpleStatefulSession EJB");
}
/**
* @throws EJBException Thrown if the instance could not perform
* the function requested by the container because of an system-level
error.
*/
public void setSessionContext(SessionContext newContext) throws
EJBException {
context = newContext;
}
/**
* initialize method for the HashMap
*/
public void init() throws EJBException {
log.info("[Enter] public void init()");
log.debug("[Param] initialized once? " + initialized);
if (! initialized) {
for (int i = 0; i < 4; i++) {
log.debug("[Param] StatefulSessPojo x=" + i);
StatefulSessPojo x = new StatefulSessPojo(i,i,i);
log.debug("[Param] Adding to groupMap...");
groupMap.put(new Integer(i), x);
}
initialized = true;
}
log.info("[Exit] public void init()");
}
/**
* @ejb.interface-method view-type = "remote"
*/
public void printGroupMap() throws EJBException {
log.info("[Enter] public void printGroupMap()");
try {
for (Iterator iter= groupMap.entrySet().iterator();
iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
StatefulSessPojo x = (StatefulSessPojo)
entry.getValue();
log.debug( "[Param] siteId=" + x.getSiteId() +
", modId=" + x.getModId() + ", itemId=" + x.getItemId());
}
log.info("[Exit] public void printGroupMap()");
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @ejb.interface-method view-type = "remote"
*/
public String printNewMapName(String name) throws EJBException {
log.info("[Enter] public String printNewMapName(String name)");
log.debug( "[Param] name=" + name);
mapName = name;
log.info("[Exit] public String printNewMapName(String name)");
return mapName;
}
/**
* @ejb.interface-method view-type = "remote"
*/
public void printMapName() throws EJBException {
log.info("[Enter] public void printMapName()");
log.debug( "[Param] mapName=" + mapName);
log.info("[Exit] public void printMapName()");
}
}
p/s: How to attach files to the forum?
Regards,
bb
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3882236#3882236
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3882236
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user