[weld-issues] [JBoss JIRA] (WELD-994) Passivating Beans do not allow Injection of non-serializable Instance injections

Marek Schmidt (JIRA) jira-events at lists.jboss.org
Mon Mar 5 11:45:36 EST 2012


     [ https://issues.jboss.org/browse/WELD-994?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marek Schmidt reopened WELD-994:
--------------------------------



I believe this new behavior is wrong, 
per 6.4.1. 

"An instance of a bean with scope @Dependent obtained by direct invocation of an Instance is a dependent object of the instance of Instance."

but the "instance of Instance" is itself a dependent object of the instance of EmailTester (in the example)

This means all of those instances created with .get() must be kept around so they can be properly destroyed, even if the emailTester has been passivated in the mean time.

Ergo, either Weld is not spec compliant and ignores the dependent objects of Instance, or it doesn't work and will fail during passivation.
                
> Passivating Beans do not allow Injection of non-serializable Instance injections
> --------------------------------------------------------------------------------
>
>                 Key: WELD-994
>                 URL: https://issues.jboss.org/browse/WELD-994
>             Project: Weld
>          Issue Type: Bug
>          Components: Producers (Methods, Fields and Disposers)
>    Affects Versions: 1.1.2.Final
>         Environment: AS 7.0.2
> WELD-000900 1.1.2 (Final)
>            Reporter: Cody Lerum
>            Assignee: Marko Lukša
>             Fix For: 1.2.0.Beta1
>
>
> Given the following Code
> {code:java}
> @ConversationScoped
> @Named
> public class EmailTester implements Serializable {
>     private static final long serialVersionUID = 1L;
>     @Inject
>     private Instance<MailMessage> mailMessage;
>     @Inject
>     private ActiveUser activeUser;
>     @Inject
>     private Messages messages;
>     
>     @Inject 
>     private Instance<Session> session;
>     public void send()
>     {
>         MailMessage m = mailMessage.get();
>         m.from(activeUser.getUser());
>         m.to(activeUser.getUser());
>         m.subject("test");
>         m.bodyText("Blah blah blah");
>         m.send(session.get());
>         messages.info("Message Sent");
>     }
> }
> {code}
> Weld throws
> org.jboss.weld.exceptions.IllegalProductException: WELD-000054 Producers cannot produce non-serializable instances for injection into non-transient fields of passivating beans\\n\\nProducer\:  Producer Method [Session] with qualifiers [@Any @Default] declared as [[method] @Produces @ExtensionManaged public org.jboss.seam.mail.core.MailSessionProducer.getMailSession(MailConfig)]\\nInjection Point\:  org.jboss.weld.bean.builtin.InstanceImpl$InstanceInjectionPoint at 2146ca: javax.faces.FacesException: #{emailTester.send()}: org.jboss.weld.exceptions.IllegalProductException: WELD-000054 Producers cannot produce non-serializable instances for injection into non-transient fields of passivating beans\\n\\nProducer\:  Producer Method [Session] with qualifiers [@Any @Default] declared as [[method] @Produces @ExtensionManaged public org.jboss.seam.mail.core.MailSessionProducer.getMailSession(MailConfig)]\\nInjection Point\:  org.jboss.weld.bean.builtin.InstanceImpl$InstanceInjectionPoint at 2146ca
> Since a new instance is returned each time a get() is called it should not matter that the javax.mail.Session is not non-serializable

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the weld-issues mailing list