[
https://issues.jboss.org/browse/JBAS-9198?page=com.atlassian.jira.plugin....
]
Andrig Miller closed JBAS-9198.
-------------------------------
Resolution: Rejected
This wasn't a bug, but just a simple problem on my end, where I didn't save my
changes to web.xml. Everything works after I actually made and saved the change, and
rebuilt my ear.
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