Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes EJB and other Java EE Technologies and the fly likes JBoss question: NotSerializable Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JBoss question: NotSerializable Exception" Watch "JBoss question: NotSerializable Exception" New topic
Author

JBoss question: NotSerializable Exception

miguel fuertes
Greenhorn

Joined: Feb 19, 2004
Posts: 4
Hi all,
I am relatively new to JBoss, and I am getting an error when calling a method in a SessionBean from a Servlet, passing a requestEvent obtained from a JSP.
The error I get is "java.rmi.MarshalException: error marshalling arguments; nested exception is:
java.io.NotSerializableException: org.apache.catalina.session.StandardSessionFacade"
I thought is a configuration problem of Jboss, which is not able to understand the request parameters that the servlet is passing, because previously and in the JBoss log I have obtained a Logger class error, so I think it could be a bug from the logj4j package.
Could anyone help me with this? Thanks a lot.
I reproduce the full log I get:
java.rmi.MarshalException: error marshalling arguments; nested exception is:
java.io.NotSerializableException: org.apache.catalina.session.StandardSessionFacade
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:108)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
at org.jboss.proxy.ejb.StatefulSessionInterceptor.invoke(StatefulSessionInterceptor.java:117)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
at $Proxy1.process(Unknown Source)
at esharing.webtier.common.FrontControllerServlet.processRequest(FrontControllerServlet.java:58)
at esharing.webtier.common.FrontControllerServlet.doPost(FrontControllerServlet.java:78)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
Caused by: java.io.NotSerializableException: org.apache.catalina.session.StandardSessionFacade
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
at java.util.Hashtable.writeObject(Hashtable.java:802)
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:324)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:795)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1294)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1330)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1302)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1224)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1050)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
at org.jboss.invocation.MarshalledValue.(MarshalledValue.java:57)
at org.jboss.invocation.MarshalledInvocation.writeExternal(MarshalledInvocation.java:343)
at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1262)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1243)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:265)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:124)
... 41 more
Sergiu Truta
Ranch Hand

Joined: Dec 16, 2003
Posts: 121
It looks like it's trying to serialize some parameter that is not Serializable. Make sure you are using only attributes that implement the Serializable interface.
Maybe showing some code would give us a hint.


...watch me...as I'm walking the path...
miguel fuertes
Greenhorn

Joined: Feb 19, 2004
Posts: 4
Thank you for your answer.
Really I do not understand well which are the attributes I have to take care.
I show you here the code of the FrontControllerServlet ("processRequest" method), which is the servlet that send the request to the Session Bean:
----------
private void processRequest(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException, IOException

{
javax.servlet.http.HttpSession httpsession = httpservletrequest.getSession(true);
RequestProcessor requestprocessor = new RequestProcessor();
ResponseGenerator responsegenerator = new ResponseGenerator();
BLController blcontroller = null;

ServiceLocator servicelocator = ServiceLocator.getInstance();

try
{

BLControllerHome blcontrollerhome = (BLControllerHome)servicelocator.getEJBHome(0);

blcontroller = blcontrollerhome.create();

}
catch(Exception exception)
{

exception.printStackTrace();
}
String s = httpservletrequest.getHeader("user-Agent");

String s1 = "";
RequestEvent requestevent = requestprocessor.processRequest(httpservletrequest);

ResponseEvent responseevent = blcontroller.process(requestevent);
s1 = responsegenerator.process(httpservletrequest, responseevent, s);


dispatch(httpservletrequest, httpservletresponse, s1);
}
-----------
The error is given when calling the "blcontroller.process(requestevent)" method. blcontroller is the remote interface of the BLController stateful SessionBean.
The parameters we are passing in the request are only two text fields, so that is because I thought it could be a JBoss configuration problem to communicate servlets with Session Beans.
Any idea? Thanks in advance.
Miguel
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Can you show us the code for your RequestEvent class?
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
miguel fuertes
Greenhorn

Joined: Feb 19, 2004
Posts: 4
Hi,
The code of the RequestEvent class is the following:
------
package esharing.webtier.common;
import esharing.command.util.*;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.Hashtable;
import org.apache.log4j.Logger;
public class RequestEvent implements Serializable{
private CommandFactory commandFactory = new CommandFactory();
private String actionName;
private Hashtable parameters;
public RequestEvent(){

parameters = new Hashtable();
}
public void setActionName(String aActionName){
actionName = aActionName;
}
public void setParameter(String parameterName, Object parameterValue){
parameters.put(parameterName, parameterValue);
}
public String getActionName(){
return(actionName);
}
public Object getParameterValue(String parameterName){
return(parameters.get(parameterName));
}
public Hashtable getParameters(){
return parameters;
}
public Command getCommand() {
return commandFactory.createCommand(getActionName());
}
public String getJsp(String action) {
return commandFactory.createJsp(action);
}
}
------
And the CommandFactory code is this:
package esharing.command.util;
import java.util.*;
import java.io.Serializable;
public class CommandFactory implements Serializable{

private HashMap _commands = new HashMap();
private HashMap _jsps = new HashMap();
//Modif MAF 16/2:
//private Logger _logger = Logger.getLogger(CommandFactory.class.getName());
private final static StringACTION_MAPPING_PROPERTIES = "actionMapping.properties";
private final static StringJSP_MAPPING_PROPERTIES = "jspMapping.properties";

public CommandFactory(){
Properties properties = new Properties();
try {
properties.load(getClass().getResourceAsStream(ACTION_MAPPING_PROPERTIES));
for(Enumeration e=properties.keys(); e.hasMoreElements(); ) {
String action = (String)e.nextElement();
_commands.put(action, ObjectCreator.createObject(properties.getProperty(action)));
System.out.println("action: " + action);
}
properties.load(getClass().getResourceAsStream(JSP_MAPPING_PROPERTIES));
for(Enumeration e=properties.keys(); e.hasMoreElements(); ) {
String action = (String)e.nextElement();
_jsps.put(action, properties.getProperty(action).toString());
}

} catch( Exception e ) {
System.out.println( "Error: " + e.toString() );
e.printStackTrace();
}
}
/** Creates a Command instance for a specified action and a
* specified set of properties.
* @param action can be one of those included in the actionMapping.properties file
* @param action the properties for the action
*/
public Command createCommand( String action ) {
return (Command)_commands.get(action);
}
public String createJsp(String action) {
return (String)_jsps.get(action);
}
}
-----
Regards,
Miguel
Sergiu Truta
Ranch Hand

Joined: Dec 16, 2003
Posts: 121
ResponseEvent responseevent = blcontroller.process(requestevent);
From this line I get that after processing the request you are returning a responseEvent....my guess is the problem is inside this responseEvent...make sure it is serializable...
If the problem is not here than you have to do more research...track down the way a request take, begining with the moment when it is received until all the processing is finished. Somewhere you are trying to serialize a parameter that is not serializable.
If you have found the answer share it with us.
Good luck
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JBoss question: NotSerializable Exception
 
Similar Threads
Exception when uploading big files
NotSerializableException
NotSerializableException problem...
MarshalException occured when sending socket object to session bean
Accessing Tree Cache AOP classes