java - Stateful bean passivation fails because of Stateless beans references -


i using weblogic 12c (12.1.3 specific) deploy (ejb 3.1) application.

in application, have @stateful bean, holds references entitymanager , other @stateless beans, injected using @persistencecontext , @ejb annotations respectively.

my issue when stateful bean being passivated , serialized disk, weblogic tries serialize references stateless beans well, , throws notserializableexception referring bean's proxy injected weblogic. comparison - entitymanager reference passivated , reactivated without issue @ all. stateless beans cause issues.

i know can define @prepassivate , @postactivate methods make code work, there way can make container handle stateless beans references on own?

attaching sample code reproduces problem me.

remote bean interface:

import javax.ejb.remote;  @remote public interface passivate {      public void dosomething();  } 

stateful bean implementation:

import javax.ejb.ejb; import javax.ejb.postactivate; import javax.ejb.prepassivate; import javax.ejb.stateful;  @stateful(mappedname = "passivatebean") public class passivatebean implements passivate {      @ejb(mappedname = "nostatebean")     private nostate nostatebean;      @override     public void dosomething() {         system.out.println("hello world");     }      @prepassivate     public void prepassivate() {         // workaround - can set nostatebean null here     }      @postactivate     public void postactivate() {         // workaround - can lookup , set nostatebean here manually     } } 

nostate local interface:

import javax.ejb.local;  @local public interface nostate {      public void foo();  } 

nostate bean implementation:

import javax.ejb.stateless;  @stateless(mappedname = "nostatebean") public class nostatebean implements nostate {      @override     public void foo() {         system.out.println("foo");     }  } 

and finally, exception getting when passivatebean being passivated disk:

<jul 14, 2015 2:36:20 pm idt> <error> <ejb> <bea-010024> <error occurred during passivation: java.io.notserializableexception: passivatetest.nostatebean_i02rk_impl     @ java.io.objectoutputstream.writeobject0(objectoutputstream.java:1184)     @ java.io.objectoutputstream.writeobject(objectoutputstream.java:348)     @ weblogic.ejb.container.utils.serializer.writeobject(serializer.java:52)     @ passivatetest.passivatebean_dmn8u8_impl.writeobject(unknown source)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:483)     @ java.io.objectstreamclass.invokewriteobject(objectstreamclass.java:988)     @ java.io.objectoutputstream.writeserialdata(objectoutputstream.java:1496)     @ java.io.objectoutputstream.writeordinaryobject(objectoutputstream.java:1432)     @ java.io.objectoutputstream.writeobject0(objectoutputstream.java:1178)     @ java.io.objectoutputstream.writeobject(objectoutputstream.java:348)     @ weblogic.ejb.container.swap.passivationutils.write(passivationutils.java:84)     @ weblogic.ejb.container.swap.diskswap.write(diskswap.java:173)     @ weblogic.ejb.container.manager.statefulsessionmanager.swapout(statefulsessionmanager.java:1246)     @ weblogic.ejb.container.cache.lrucache.passivatenode(lrucache.java:199)     @ weblogic.ejb.container.cache.lrucache.timerexpired(lrucache.java:187)     @ weblogic.timers.internal.timerimpl.run(timerimpl.java:304)     @ weblogic.work.selftuningworkmanagerimpl$workadapterimpl.run(selftuningworkmanagerimpl.java:548)     @ weblogic.work.executethread.execute(executethread.java:311)     @ weblogic.work.executethread.run(executethread.java:263) 

as of now, seems actual bug/limitation in weblogic 12.1.3 posting workaround possible solution.

to make stateful bean go through passivation successfully, 1 needs implement methods annotated javax.ejb.prepassivate , javax.ejb.postactivate. @prepassivate method make stateless bean reference point null, , @postactivate method perform lookup bean when bean being activated again.

@prepassivate public void prepassivate() {     nostatebean = null; }  @postactivate public void postactivate() {     // lookup string correct assuming ejb module deployed within ear. if setup different jndi lookup name may different.     nostatebean = initialcontext.dolookup("java:module/nostatebean!nostate"); } 

if there no comments or other answers in next couple of weeks or so, mark answer solution.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -