Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-994

Passivating Beans do not allow Injection of non-serializable Instance injections

    XMLWordPrintable

Details

    Description

      Given the following Code

      @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");
          }
      
      }
      
      
      

      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@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@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

      Attachments

        Activity

          People

            marko.luksa@gmail.com Marko Luksa (Inactive)
            cody.lerum@gmail.com Cody Lerum
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: