[seam-dev] producing non-serializable beans from producers with passivating scope

Pete Muir pmuir at redhat.com
Tue Apr 20 06:08:09 EDT 2010


On 20 Apr 2010, at 01:54, Tihomir Surdilovic wrote:

> Hi all, I ran into an issue with producing Drools 
> StatefulKnowledgeSession beans from my producers. Basically I need to 
> make sure that each produced session is in Conversation scope which is 
> passivating..but StatefulKnowledgeSession is not serializable which ends 
> up with exception:
> 
> org.jboss.weld.exceptions.IllegalProductException: WELD-000053 Producers 
> cannot declare passivating scope and return a non-serializable class
> 
> One idea was to declare the manager bean which includes the producer 
> method(s) in Conversation scope and make the producers request scoped 
> with a check for example:

You mean put the manager bean in the conversation scoped?

> 
> if(ksession != null) { return ksession;} else { //create a new one and 
> save }

It would be cleaner to do this in the postconstruct. Remember all beans are lazy anyway.

> but my problem is that since I am specializing producer methods in the 
> module beans.xml (and so can the user in their beans.xml) I do not know 
> all possible specialized producer methods at runtime.

Can you explain more?

> 
> Any input on this is much appreciated as currently the following 
> injections for example:
> 
> @Inject @MySession StatefulKnowledgeSession ksession1;
> and
> @Inject @MySession StatefulKnowledgeSession ksession2;
> 
> end up being two different beans because dependent scope producer method 
> gets called twice.

If the manager is conversation scoped, it should be the same one?


More information about the seam-dev mailing list