I discussed yesterday with Arne how we should treat the following @SessionScoped has @Inject Depenent1 which has @Inject Dependent2
Initially we had troubles how we should solve this, but I think the solution is pretty easy: We just need to add a boolean passivatingInjection to our OWB CreationalContextImpl. As this is used for all subsequent dependents as well we can easily check this during injection. LieGrue, strub ----- Original Message ----- > From: David Blevins <[email protected]> > To: [email protected] > Cc: > Sent: Saturday, 11 May 2013, 5:31 > Subject: Re: Possibly invalid passivation capability check > > > On May 10, 2013, at 2:03 PM, Arne Limburg <[email protected]> > wrote: > >> Hi David, >> >> Do I read the log correctly and SimpleServlet is @Dependent? Is >> SimpleServlet injected into a passivation-capable bean? >> If not, I agree with you that this is a bug. > > Right. Neither the bean (Car) or the injection target (SimpleServlet > constructor) are passivation capable. > > > -David > >> Am 10.05.13 22:55 schrieb "David Blevins" unter > <[email protected]>: >> >>> Since the upgrade to 1.2.0 in we have a test failure. There's a > servlet >>> with constructor injection like so: >>> >>> >>> @Inject >>> public SimpleServlet(Car car) { >>> this.car = car; >>> } >>> >>> And Car looks like so: >>> >>> public class Car { >>> private final String make = "Lexus", model = "IS > 350"; >>> private final int year = 2011; >>> >>> public String drive(String name) { >>> return name + " is on the wheel of a " + year + > " " + make + >>> " " + model; >>> } >>> } >>> >>> All deploys fine and everything is injected as expected. Now the >>> problem. If you introduce a producer, it fails saying Car is not >>> passivation capable as required by the SimpleServlet injection point. >>> >>> public class Car { >>> private final String make = "Lexus", model = "IS > 350"; >>> private final int year = 2011; >>> >>> public Car(String ignore) { >>> } >>> >>> public String drive(String name) { >>> return name + " is on the wheel of a " + year + > " " + make + >>> " " + model; >>> } >>> } >>> >>> public class Foo { >>> >>> @Produces @Default >>> public Car car() { >>> return new Car("foo"); >>> } >>> } >>> >>> >>> javax.enterprise.inject.IllegalProductException: A producer method or >>> field of scope @Dependent returns an unserializable object for > injection >>> into an injection point Constructor Injection Point, constructor name : >>> org.apache.openejb.arquillian.tests.cdi.constructor.SimpleServlet, Bean >>> Owner : [SimpleServlet, Name:null, WebBeans Type:DEPENDENT, API >>> > Types:[java.io.Serializable,java.lang.Object,javax.servlet.ServletConfig,o >>> > rg.apache.openejb.arquillian.tests.cdi.constructor.SimpleServlet,javax.ser >>> > vlet.http.HttpServlet,javax.servlet.Servlet,javax.servlet.GenericServlet], >>> >>> > Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]] >>> that requires a passivation capable dependency >>> at >>> > org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.ja >>> va:108) >>> at >>> > org.apache.webbeans.inject.InjectableConstructor.doInjection(InjectableCon >>> structor.java:80) >>> at >>> > org.apache.webbeans.portable.InjectionTargetImpl.newInstance(InjectionTarg >>> etImpl.java:253) >>> at >>> > org.apache.webbeans.portable.InjectionTargetImpl.produce(InjectionTargetIm >>> pl.java:180) >>> at >>> > org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java: >>> 119) >>> >>> There's debate as if the test is bad or if the check is incorrect. > Seems >>> like an OWB bug to me. >>> >>> Thoughts? >>> >>> >>> -David >>> >> >> >
