I'm having a problem with trying to create a SFSB with an injected EntityManager that
has an EXTENDED context:
@Stateful(name="OrderService", mappedName="OrderService")
| @Local(Order.class)
| public class OrderBean implements Order {
|
| @PersistenceContext(type = PersistenceContextType.EXTENDED, unitName =
"persistence")
| protected EntityManager em;
| Company company = null;
|
| @PersistenceContext(type = PersistenceContextType.EXTENDED, unitName =
"persistence")
| public void setEM(EntityManager em) {
| this.em = em;
| }
|
| public Company getCompany(Integer Id) {
| company = em.find(Company.class, new Integer(1));
| return company;
| }
|
| @Remove
| public void remove(){}
|
| @javax.ejb.PostActivate
| public void postActivate(){
| System.out.println("postactivating order");
| }
|
| @javax.ejb.PrePassivate
| public void prePassivate(){
| System.out.println("passivating order");
| }
|
| public void doSomethingElse() {
| System.out.println("Doing something else");
| }
|
| public Company getCompanyBack() {
| return company;
| }
| }
At first everything works great. I lookup the SFSB from a jsp and call getCompany() which
returns me the company. I then stick the reference to the SFSB interface into the http
session. I hit another jsp which get's the SFSB interface from the session and calls
getCompanyBack() and all is well. I can even walk lazy collections on the company with no
problem.
However, if I wait a while, the SFSB will passivate without error:
2006-08-03 09:56:12,987 DEBUG
[org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager] Attempting to
passivate; id=4sg3q-kqtq3k-eqfaw0yg-1-eqfaxk9s-7
| 2006-08-03 09:56:12,987 INFO [STDOUT] passivating order
| 2006-08-03 09:56:12,987 DEBUG
[org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager] Saving session state
to:
D:\jboss\jboss-4.0.4.GA.P1\server\default\tmp\sessions\OrderService-eqfax4z0-6\4sg3q-kqtq3k-eqfaw0yg-1-eqfaxk9s-7.ser
| 2006-08-03 09:56:13,222 DEBUG [org.hibernate.impl.SessionFactoryImpl] serializing:
2c90839a0cd4b626010cd4b62e660000
| 2006-08-03 09:56:13,222 DEBUG
[org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager] Passivation complete;
id=4sg3q-kqtq3k-eqfaw0yg-1-eqfaxk9s-7
Then I try to hit the jsp page again, and it throws up trying to call getCompanyBack()
complaining that it cannot find the SFSB:
2006-08-03 10:02:38,065 DEBUG
[org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager] Attempting to
activate; id=4sg3q-kqtq3k-eqfaw0yg-1-eqfaxk9s-7
| 2006-08-03 10:02:38,065 DEBUG
[org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager] Reading session state
from:
D:\jboss\jboss-4.0.4.GA.P1\server\default\tmp\sessions\OrderService-eqfax4z0-6\4sg3q-kqtq3k-eqfaw0yg-1-eqfaxk9s-7.ser
| 2006-08-03 10:02:38,112 DEBUG
[org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager] Removing passivated
state file:
D:\jboss\jboss-4.0.4.GA.P1\server\default\tmp\sessions\OrderService-eqfax4z0-6\4sg3q-kqtq3k-eqfaw0yg-1-eqfaxk9s-7.ser
2006-08-03 10:02:38,190 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] lookup:
uid=2c90839a0cd4b626010cd4b62e660000
| 2006-08-03 10:02:38,190 WARN [org.hibernate.impl.SessionFactoryObjectFactory] Not
found: 2c90839a0cd4b626010cd4b62e660000
| 2006-08-03 10:02:38,190 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory]
{2c90839a0cd4b656010cd4b65da40000=org.hibernate.impl.SessionFactoryImpl@1cbcc56}
|
Then there is a long exception ending in:
Caused by: java.io.InvalidObjectException: could not locate session factory by uuid
[2c90839a0cd4b626010cd4b62e660000] during session deserialization
| at org.hibernate.impl.SessionFactoryImpl.deserialize(SessionFactoryImpl.java:1038)
| at org.hibernate.impl.SessionImpl.readObject(SessionImpl.java:1866)
| ... 76 more
I was using JBoss 4.0.4.GA-Patch1, then I tried the same install with EJB-3.0_RC8-FD
installed on top, which also didn't work.
If I remove the EntityManager from the SFSB, (and use other parts of the SFSB) then it
works as expected, passivating and activating.
I even tried making the em transient and marking it @Transient, but it yeilds the same
error.
I've looked around and done some reading, and it seems unclear if I should be able to
do this with an EXTENDED context in an SFSB, but I'm following the example here:
http://docs.jboss.org/ejb3/app-server/tutorial/extended_pc/extended.html
Any help would be appreciated. Can this be done, is it not fully implemented yet? Is
there a work around?
Thanks
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962920#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...