[
https://issues.jboss.org/browse/JBAS-9198?page=com.atlassian.jira.plugin....
]
Remy Maucherat commented on JBAS-9198:
--------------------------------------
The code in the SessionManager has not changed, and reads:
if ((manager != null) && manager.getDistributable() &&
!(value instanceof Serializable))
throw new IllegalArgumentException
(sm.getString("standardSession.setAttribute.iae", name));
So I think (value instanceof Serializable) returns false, and since the context is
distributable (apparently), it causes an error.
Cannot store reference to a stateful session bean in the HTTP
session
---------------------------------------------------------------------
Key: JBAS-9198
URL:
https://issues.jboss.org/browse/JBAS-9198
Project: JBoss Application Server
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Web (Tomcat) service
Affects Versions: 7.0.0.Beta1
Reporter: Andrig Miller
Assignee: Remy Maucherat
Fix For: 7.0.0.Beta2
I have ported an application from AS 5/EAP 5.1 to AS 7 (a snapshot of Beta 2 actually),
and in that application I am looking up a reference to a stateful session bean, to store
it in the HTTP session, and the actual storage of the reference, gets the following:
javax.servlet.ServletException: java.lang.IllegalArgumentException: setAttribute:
Non-serializable attribute sfsbOrderInquiry
services.web.OrderInquiryServlet.doGet(OrderInquiryServlet.java:78)
javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
root cause
java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute
sfsbOrderInquiry
org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1289)
org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1250)
org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:130)
services.web.OrderInquiryServlet.doGet(OrderInquiryServlet.java:74)
javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
It's saying that my attribute is not serializable, but the OrderInquiryBean in the
lookup implements Serializable.
The code in the servlet is as such, and it fails on the
session.setAttribute("sfsbOrderInquiry", orderInquiry):
HttpSession session = request.getSession();
OrderInquiry orderInquiry = (OrderInquiry)
session.getAttribute("sfsbOrderInquiry");
if (orderInquiry == null) {
InitialContext context = null;
try {
context = new InitialContext();
orderInquiry = (OrderInquiry)
context.lookup("java:app/OrderManagerEJB/OrderInquiryBean!services.ejb.OrderInquiry");
session.setAttribute("sfsbOrderInquiry", orderInquiry);
} catch(Exception lookupError) {
logger.log(Level.ERROR, lookupError.getStackTrace().toString());
response.setStatus(500);
throw new ServletException(lookupError);
}
}
The top of OrderInquireBean looks like:
@Stateful
public class OrderInquiryBean implements OrderInquiry, Serializable {
/** The serialVersionUID */
private static final long serialVersionUID = -9113338082170911949L
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira