You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Chris Owens <ct...@chris-owens.com> on 2013/10/28 21:13:58 UTC

CDI Injecting parameterized types

My (beginner's) understanding of JSR-299 is that it recognizes parameterized
types:  

MyInterface.java


Class1.java


Class2.java


Class3.java


I'm expecting var1 to be bound to a bean that implements Class2, but that
isn't happening.   Do I misunderstand how JSR-299 uses generics?



--
View this message in context: http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: CDI Injecting parameterized types

Posted by Kay Wrobel <ka...@gmx.net>.
Hi Romain.

I tested this with 1.6.0 Snapshot from today and injection the 
AbstractFacade<T> inside AbstractController<T> works now. Great! Thanks. 
Can't wait for the new release.

Kay

On 10/29/2013 12:40 PM, Kay Wrobel wrote:
> I shall try that.
>
> On 10/29/2013 11:04 AM, Romain Manni-Bucau wrote:
>> Maybe give it a try on the snapshot, the issue didn't pop out when
>> starting the container on the 1.6.0-SNAPSHOT
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>>
>> 2013/10/29 Kay Wrobel <ka...@gmx.net>:
>>> Here is a test project: https://github.com/kwrobel/WebApplication1
>>>
>>> I uploaded a new commit that uses the @Inject annotation inside
>>> ui.bean.AbstractController
>>> <https://github.com/kwrobel/WebApplication1/blob/master/WebApplication1/src/java/ui/bean/AbstractController.java> 
>>>
>>> instead of ui.bean.MyTestController
>>> <https://github.com/kwrobel/WebApplication1/blob/master/WebApplication1/src/java/ui/bean/MyTestController.java>. 
>>>
>>> I just double-checked my statement that it works with GlassFish and, 
>>> yes, it
>>> works with GlassFish 3.1.2. You can browse the history
>>> <https://github.com/kwrobel/WebApplication1/commit/ba43070d0de4941ab0a4fa84ec0655f11bedd14c> 
>>>
>>> to see the latest change as explained below.
>>>
>>>
>>>
>>> On 10/29/2013 12:59 AM, Mark Struberg wrote:
>>>> I would need a bit more code to understand the problem.
>>>> E.g. how the DiscountCodeFacade does look like.
>>>> Ideally a small sample project.
>>>>
>>>> The message in the log indicates that OWB cannot find a Bean for the
>>>> InjectionPoint.
>>>>
>>>> LieGrue,
>>>> strub
>>>>
>>>>
>>>>
>>>>
>>>> ----- Original Message -----
>>>>> From: Kay Wrobel <ka...@gmx.net>
>>>>> To: users@tomee.apache.org
>>>>> Cc:
>>>>> Sent: Monday, 28 October 2013, 23:06
>>>>> Subject: Re: CDI Injecting parameterized types
>>>>>
>>>>> Interesting that this topic has come up. I just tried to roll out a
>>>>> change to my project where I have following situation:
>>>>> Currently, I have an AbstractController and then a Controller for 
>>>>> each
>>>>> entity class. On the EJB side of things, I have an AbstractFacade 
>>>>> and an
>>>>> entity Facade for each entity, each annotated with @Stateless. Right
>>>>> now, I am injecting an EntityFacade object into an 
>>>>> EntityController and
>>>>> then hand off the actual object to a variable that sits inside the
>>>>> AbstractController. I wanted to change that behavior and perform the
>>>>> injection right inside the abstract controller class. To give you 
>>>>> a more
>>>>> concrete example, this is how it looks like now:
>>>>>
>>>>> AbstractController.java:
>>>>>>    public abstract class AbstractController<T> {
>>>>>>
>>>>>>        private AbstractFacade<T> ejbFacade;
>>>>>>
>>>>>>        public AbstractController() {
>>>>>>        }
>>>>>>
>>>>>>        protected AbstractFacade<T> getFacade() {
>>>>>>            return ejbFacade;
>>>>>>        }
>>>>>>
>>>>>>        protected void setFacade(AbstractFacade<T> ejbFacade) {
>>>>>>            this.ejbFacade = ejbFacade;
>>>>>>        }
>>>>>>    }
>>>>> CustomerController.java:
>>>>>>    @Named(value = "discountCodeController")
>>>>>>    @ViewAccessScoped
>>>>>>    public class DiscountCodeController extends
>>>>>>    AbstractController<DiscountCode> implements Serializable {
>>>>>>
>>>>>>    *    @Inject**
>>>>>>    **    private DiscountCodeFacade ejbFacade;**
>>>>>>    *
>>>>>>        @PostConstruct
>>>>>>        public void init() {
>>>>>>            super.setFacade(ejbFacade);
>>>>>>        }
>>>>>>
>>>>>>    }
>>>>> Now for the change that I had already tested out with Glassfish 
>>>>> 3.1.2:
>>>>>
>>>>> AbstractController.java:
>>>>>>    public abstract class AbstractController<T> {
>>>>>>
>>>>>>    *    @Inject**
>>>>>>    **    private AbstractFacade<T> ejbFacade;**
>>>>>>    *
>>>>>>        public AbstractController() {
>>>>>>        }
>>>>>>
>>>>>>        public AbstractController(Class<T> itemClass) {
>>>>>>            this.itemClass = itemClass;
>>>>>>        }
>>>>>>    }
>>>>> DiscountController.java:
>>>>>>    @Named(value = "discountCodeController")
>>>>>>    @ViewAccessScoped
>>>>>>    public class DiscountCodeController extends
>>>>>>    AbstractController<DiscountCode> implements Serializable {
>>>>>>
>>>>>>        public DiscountCodeController() {
>>>>>>            super(DiscountCode.class);
>>>>>>        }
>>>>>>
>>>>>>    }
>>>>> Notice how I am injecting an AbstractFacade<T> inside
>>>>> AbstractController<T>. This works in Glassfish but fails in
>>>>> Tomee/OpenEJB.
>>>>>
>>>>> Attached is the the deployment log of TomEE: 
>>>>> http://pastebin.com/iZHZqy5d
>>>>>
>>>>> Any input from you guys?
>>>>>
>>>>>
>>>>>
>>>>> On 10/28/2013 04:29 PM, Romain Manni-Bucau wrote:
>>>>>>    I needed it for other reasons. Globally while not using 
>>>>>> producers it
>>>>>> should
>>>>>>    work.
>>>>>>    Le 28 oct. 2013 22:21, "Chris Owens"
>>>>> <ct...@chris-owens.com> a
>>>>>>    écrit :
>>>>>>
>>>>>>>    Thank you, that code is very helpful.  I was hoping to be 
>>>>>>> able to do
>>>>>>> it
>>>>>>>    without the use of an additional qualifier.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>    --
>>>>>>>    View this message in context:
>>>>>>>
>>>>> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html 
>>>>>
>>>>>>>    Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>>>>
>


Re: CDI Injecting parameterized types

Posted by Kay Wrobel <ka...@gmx.net>.
I shall try that.

On 10/29/2013 11:04 AM, Romain Manni-Bucau wrote:
> Maybe give it a try on the snapshot, the issue didn't pop out when
> starting the container on the 1.6.0-SNAPSHOT
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2013/10/29 Kay Wrobel <ka...@gmx.net>:
>> Here is a test project: https://github.com/kwrobel/WebApplication1
>>
>> I uploaded a new commit that uses the @Inject annotation inside
>> ui.bean.AbstractController
>> <https://github.com/kwrobel/WebApplication1/blob/master/WebApplication1/src/java/ui/bean/AbstractController.java>
>> instead of ui.bean.MyTestController
>> <https://github.com/kwrobel/WebApplication1/blob/master/WebApplication1/src/java/ui/bean/MyTestController.java>.
>> I just double-checked my statement that it works with GlassFish and, yes, it
>> works with GlassFish 3.1.2. You can browse the history
>> <https://github.com/kwrobel/WebApplication1/commit/ba43070d0de4941ab0a4fa84ec0655f11bedd14c>
>> to see the latest change as explained below.
>>
>>
>>
>> On 10/29/2013 12:59 AM, Mark Struberg wrote:
>>> I would need a bit more code to understand the problem.
>>> E.g. how the DiscountCodeFacade does look like.
>>> Ideally a small sample project.
>>>
>>> The message in the log indicates that OWB cannot find a Bean for the
>>> InjectionPoint.
>>>
>>> LieGrue,
>>> strub
>>>
>>>
>>>
>>>
>>> ----- Original Message -----
>>>> From: Kay Wrobel <ka...@gmx.net>
>>>> To: users@tomee.apache.org
>>>> Cc:
>>>> Sent: Monday, 28 October 2013, 23:06
>>>> Subject: Re: CDI Injecting parameterized types
>>>>
>>>> Interesting that this topic has come up. I just tried to roll out a
>>>> change to my project where I have following situation:
>>>> Currently, I have an AbstractController and then a Controller for each
>>>> entity class. On the EJB side of things, I have an AbstractFacade and an
>>>> entity Facade for each entity, each annotated with @Stateless. Right
>>>> now, I am injecting an EntityFacade object into an EntityController and
>>>> then hand off the actual object to a variable that sits inside the
>>>> AbstractController. I wanted to change that behavior and perform the
>>>> injection right inside the abstract controller class. To give you a more
>>>> concrete example, this is how it looks like now:
>>>>
>>>> AbstractController.java:
>>>>>    public abstract class AbstractController<T> {
>>>>>
>>>>>        private AbstractFacade<T> ejbFacade;
>>>>>
>>>>>        public AbstractController() {
>>>>>        }
>>>>>
>>>>>        protected AbstractFacade<T> getFacade() {
>>>>>            return ejbFacade;
>>>>>        }
>>>>>
>>>>>        protected void setFacade(AbstractFacade<T> ejbFacade) {
>>>>>            this.ejbFacade = ejbFacade;
>>>>>        }
>>>>>    }
>>>> CustomerController.java:
>>>>>    @Named(value = "discountCodeController")
>>>>>    @ViewAccessScoped
>>>>>    public class DiscountCodeController extends
>>>>>    AbstractController<DiscountCode> implements Serializable {
>>>>>
>>>>>    *    @Inject**
>>>>>    **    private DiscountCodeFacade ejbFacade;**
>>>>>    *
>>>>>        @PostConstruct
>>>>>        public void init() {
>>>>>            super.setFacade(ejbFacade);
>>>>>        }
>>>>>
>>>>>    }
>>>> Now for the change that I had already tested out with Glassfish 3.1.2:
>>>>
>>>> AbstractController.java:
>>>>>    public abstract class AbstractController<T> {
>>>>>
>>>>>    *    @Inject**
>>>>>    **    private AbstractFacade<T> ejbFacade;**
>>>>>    *
>>>>>        public AbstractController() {
>>>>>        }
>>>>>
>>>>>        public AbstractController(Class<T> itemClass) {
>>>>>            this.itemClass = itemClass;
>>>>>        }
>>>>>    }
>>>> DiscountController.java:
>>>>>    @Named(value = "discountCodeController")
>>>>>    @ViewAccessScoped
>>>>>    public class DiscountCodeController extends
>>>>>    AbstractController<DiscountCode> implements Serializable {
>>>>>
>>>>>        public DiscountCodeController() {
>>>>>            super(DiscountCode.class);
>>>>>        }
>>>>>
>>>>>    }
>>>> Notice how I am injecting an AbstractFacade<T> inside
>>>> AbstractController<T>. This works in Glassfish but fails in
>>>> Tomee/OpenEJB.
>>>>
>>>> Attached is the the deployment log of TomEE: http://pastebin.com/iZHZqy5d
>>>>
>>>> Any input from you guys?
>>>>
>>>>
>>>>
>>>> On 10/28/2013 04:29 PM, Romain Manni-Bucau wrote:
>>>>>    I needed it for other reasons. Globally while not using producers it
>>>>> should
>>>>>    work.
>>>>>    Le 28 oct. 2013 22:21, "Chris Owens"
>>>> <ct...@chris-owens.com> a
>>>>>    écrit :
>>>>>
>>>>>>    Thank you, that code is very helpful.  I was hoping to be able to do
>>>>>> it
>>>>>>    without the use of an additional qualifier.
>>>>>>
>>>>>>
>>>>>>
>>>>>>    --
>>>>>>    View this message in context:
>>>>>>
>>>> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html
>>>>>>    Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>>>


Re: CDI Injecting parameterized types

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Maybe give it a try on the snapshot, the issue didn't pop out when
starting the container on the 1.6.0-SNAPSHOT
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2013/10/29 Kay Wrobel <ka...@gmx.net>:
> Here is a test project: https://github.com/kwrobel/WebApplication1
>
> I uploaded a new commit that uses the @Inject annotation inside
> ui.bean.AbstractController
> <https://github.com/kwrobel/WebApplication1/blob/master/WebApplication1/src/java/ui/bean/AbstractController.java>
> instead of ui.bean.MyTestController
> <https://github.com/kwrobel/WebApplication1/blob/master/WebApplication1/src/java/ui/bean/MyTestController.java>.
> I just double-checked my statement that it works with GlassFish and, yes, it
> works with GlassFish 3.1.2. You can browse the history
> <https://github.com/kwrobel/WebApplication1/commit/ba43070d0de4941ab0a4fa84ec0655f11bedd14c>
> to see the latest change as explained below.
>
>
>
> On 10/29/2013 12:59 AM, Mark Struberg wrote:
>>
>> I would need a bit more code to understand the problem.
>> E.g. how the DiscountCodeFacade does look like.
>> Ideally a small sample project.
>>
>> The message in the log indicates that OWB cannot find a Bean for the
>> InjectionPoint.
>>
>> LieGrue,
>> strub
>>
>>
>>
>>
>> ----- Original Message -----
>>>
>>> From: Kay Wrobel <ka...@gmx.net>
>>> To: users@tomee.apache.org
>>> Cc:
>>> Sent: Monday, 28 October 2013, 23:06
>>> Subject: Re: CDI Injecting parameterized types
>>>
>>> Interesting that this topic has come up. I just tried to roll out a
>>> change to my project where I have following situation:
>>> Currently, I have an AbstractController and then a Controller for each
>>> entity class. On the EJB side of things, I have an AbstractFacade and an
>>> entity Facade for each entity, each annotated with @Stateless. Right
>>> now, I am injecting an EntityFacade object into an EntityController and
>>> then hand off the actual object to a variable that sits inside the
>>> AbstractController. I wanted to change that behavior and perform the
>>> injection right inside the abstract controller class. To give you a more
>>> concrete example, this is how it looks like now:
>>>
>>> AbstractController.java:
>>>>
>>>>   public abstract class AbstractController<T> {
>>>>
>>>>       private AbstractFacade<T> ejbFacade;
>>>>
>>>>       public AbstractController() {
>>>>       }
>>>>
>>>>       protected AbstractFacade<T> getFacade() {
>>>>           return ejbFacade;
>>>>       }
>>>>
>>>>       protected void setFacade(AbstractFacade<T> ejbFacade) {
>>>>           this.ejbFacade = ejbFacade;
>>>>       }
>>>>   }
>>>
>>> CustomerController.java:
>>>>
>>>>   @Named(value = "discountCodeController")
>>>>   @ViewAccessScoped
>>>>   public class DiscountCodeController extends
>>>>   AbstractController<DiscountCode> implements Serializable {
>>>>
>>>>   *    @Inject**
>>>>   **    private DiscountCodeFacade ejbFacade;**
>>>>   *
>>>>       @PostConstruct
>>>>       public void init() {
>>>>           super.setFacade(ejbFacade);
>>>>       }
>>>>
>>>>   }
>>>
>>> Now for the change that I had already tested out with Glassfish 3.1.2:
>>>
>>> AbstractController.java:
>>>>
>>>>   public abstract class AbstractController<T> {
>>>>
>>>>   *    @Inject**
>>>>   **    private AbstractFacade<T> ejbFacade;**
>>>>   *
>>>>       public AbstractController() {
>>>>       }
>>>>
>>>>       public AbstractController(Class<T> itemClass) {
>>>>           this.itemClass = itemClass;
>>>>       }
>>>>   }
>>>
>>> DiscountController.java:
>>>>
>>>>   @Named(value = "discountCodeController")
>>>>   @ViewAccessScoped
>>>>   public class DiscountCodeController extends
>>>>   AbstractController<DiscountCode> implements Serializable {
>>>>
>>>>       public DiscountCodeController() {
>>>>           super(DiscountCode.class);
>>>>       }
>>>>
>>>>   }
>>>
>>> Notice how I am injecting an AbstractFacade<T> inside
>>> AbstractController<T>. This works in Glassfish but fails in
>>> Tomee/OpenEJB.
>>>
>>> Attached is the the deployment log of TomEE: http://pastebin.com/iZHZqy5d
>>>
>>> Any input from you guys?
>>>
>>>
>>>
>>> On 10/28/2013 04:29 PM, Romain Manni-Bucau wrote:
>>>>
>>>>   I needed it for other reasons. Globally while not using producers it
>>>> should
>>>>   work.
>>>>   Le 28 oct. 2013 22:21, "Chris Owens"
>>>
>>> <ct...@chris-owens.com> a
>>>>
>>>>   écrit :
>>>>
>>>>>   Thank you, that code is very helpful.  I was hoping to be able to do
>>>>> it
>>>>>   without the use of an additional qualifier.
>>>>>
>>>>>
>>>>>
>>>>>   --
>>>>>   View this message in context:
>>>>>
>>>
>>> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html
>>>>>
>>>>>   Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>>
>

Re: CDI Injecting parameterized types

Posted by Kay Wrobel <ka...@gmx.net>.
Here is a test project: https://github.com/kwrobel/WebApplication1

I uploaded a new commit that uses the @Inject annotation inside 
ui.bean.AbstractController 
<https://github.com/kwrobel/WebApplication1/blob/master/WebApplication1/src/java/ui/bean/AbstractController.java> 
instead of ui.bean.MyTestController 
<https://github.com/kwrobel/WebApplication1/blob/master/WebApplication1/src/java/ui/bean/MyTestController.java>. 
I just double-checked my statement that it works with GlassFish and, 
yes, it works with GlassFish 3.1.2. You can browse the history 
<https://github.com/kwrobel/WebApplication1/commit/ba43070d0de4941ab0a4fa84ec0655f11bedd14c> 
to see the latest change as explained below.


On 10/29/2013 12:59 AM, Mark Struberg wrote:
> I would need a bit more code to understand the problem.
> E.g. how the DiscountCodeFacade does look like.
> Ideally a small sample project.
>
> The message in the log indicates that OWB cannot find a Bean for the InjectionPoint.
>
> LieGrue,
> strub
>
>
>
>
> ----- Original Message -----
>> From: Kay Wrobel <ka...@gmx.net>
>> To: users@tomee.apache.org
>> Cc:
>> Sent: Monday, 28 October 2013, 23:06
>> Subject: Re: CDI Injecting parameterized types
>>
>> Interesting that this topic has come up. I just tried to roll out a
>> change to my project where I have following situation:
>> Currently, I have an AbstractController and then a Controller for each
>> entity class. On the EJB side of things, I have an AbstractFacade and an
>> entity Facade for each entity, each annotated with @Stateless. Right
>> now, I am injecting an EntityFacade object into an EntityController and
>> then hand off the actual object to a variable that sits inside the
>> AbstractController. I wanted to change that behavior and perform the
>> injection right inside the abstract controller class. To give you a more
>> concrete example, this is how it looks like now:
>>
>> AbstractController.java:
>>>   public abstract class AbstractController<T> {
>>>
>>>       private AbstractFacade<T> ejbFacade;
>>>
>>>       public AbstractController() {
>>>       }
>>>
>>>       protected AbstractFacade<T> getFacade() {
>>>           return ejbFacade;
>>>       }
>>>
>>>       protected void setFacade(AbstractFacade<T> ejbFacade) {
>>>           this.ejbFacade = ejbFacade;
>>>       }
>>>   }
>> CustomerController.java:
>>>   @Named(value = "discountCodeController")
>>>   @ViewAccessScoped
>>>   public class DiscountCodeController extends
>>>   AbstractController<DiscountCode> implements Serializable {
>>>
>>>   *    @Inject**
>>>   **    private DiscountCodeFacade ejbFacade;**
>>>   *
>>>       @PostConstruct
>>>       public void init() {
>>>           super.setFacade(ejbFacade);
>>>       }
>>>
>>>   }
>> Now for the change that I had already tested out with Glassfish 3.1.2:
>>
>> AbstractController.java:
>>>   public abstract class AbstractController<T> {
>>>
>>>   *    @Inject**
>>>   **    private AbstractFacade<T> ejbFacade;**
>>>   *
>>>       public AbstractController() {
>>>       }
>>>
>>>       public AbstractController(Class<T> itemClass) {
>>>           this.itemClass = itemClass;
>>>       }
>>>   }
>> DiscountController.java:
>>>   @Named(value = "discountCodeController")
>>>   @ViewAccessScoped
>>>   public class DiscountCodeController extends
>>>   AbstractController<DiscountCode> implements Serializable {
>>>
>>>       public DiscountCodeController() {
>>>           super(DiscountCode.class);
>>>       }
>>>
>>>   }
>> Notice how I am injecting an AbstractFacade<T> inside
>> AbstractController<T>. This works in Glassfish but fails in Tomee/OpenEJB.
>>
>> Attached is the the deployment log of TomEE: http://pastebin.com/iZHZqy5d
>>
>> Any input from you guys?
>>
>>
>>
>> On 10/28/2013 04:29 PM, Romain Manni-Bucau wrote:
>>>   I needed it for other reasons. Globally while not using producers it should
>>>   work.
>>>   Le 28 oct. 2013 22:21, "Chris Owens"
>> <ct...@chris-owens.com> a
>>>   écrit :
>>>
>>>>   Thank you, that code is very helpful.  I was hoping to be able to do it
>>>>   without the use of an additional qualifier.
>>>>
>>>>
>>>>
>>>>   --
>>>>   View this message in context:
>>>>
>> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html
>>>>   Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>


Re: CDI Injecting parameterized types

Posted by Mark Struberg <st...@yahoo.de>.
I would need a bit more code to understand the problem.
E.g. how the DiscountCodeFacade does look like.
Ideally a small sample project.

The message in the log indicates that OWB cannot find a Bean for the InjectionPoint.

LieGrue,
strub




----- Original Message -----
> From: Kay Wrobel <ka...@gmx.net>
> To: users@tomee.apache.org
> Cc: 
> Sent: Monday, 28 October 2013, 23:06
> Subject: Re: CDI Injecting parameterized types
> 
> Interesting that this topic has come up. I just tried to roll out a 
> change to my project where I have following situation:
> Currently, I have an AbstractController and then a Controller for each 
> entity class. On the EJB side of things, I have an AbstractFacade and an 
> entity Facade for each entity, each annotated with @Stateless. Right 
> now, I am injecting an EntityFacade object into an EntityController and 
> then hand off the actual object to a variable that sits inside the 
> AbstractController. I wanted to change that behavior and perform the 
> injection right inside the abstract controller class. To give you a more 
> concrete example, this is how it looks like now:
> 
> AbstractController.java:
>>  public abstract class AbstractController<T> {
>> 
>>      private AbstractFacade<T> ejbFacade;
>> 
>>      public AbstractController() {
>>      }
>> 
>>      protected AbstractFacade<T> getFacade() {
>>          return ejbFacade;
>>      }
>> 
>>      protected void setFacade(AbstractFacade<T> ejbFacade) {
>>          this.ejbFacade = ejbFacade;
>>      }
>>  }
> 
> CustomerController.java:
>>  @Named(value = "discountCodeController")
>>  @ViewAccessScoped
>>  public class DiscountCodeController extends 
>>  AbstractController<DiscountCode> implements Serializable {
>> 
>>  *    @Inject**
>>  **    private DiscountCodeFacade ejbFacade;**
>>  *
>>      @PostConstruct
>>      public void init() {
>>          super.setFacade(ejbFacade);
>>      }
>> 
>>  }
> Now for the change that I had already tested out with Glassfish 3.1.2:
> 
> AbstractController.java:
>>  public abstract class AbstractController<T> {
>> 
>>  *    @Inject**
>>  **    private AbstractFacade<T> ejbFacade;**
>>  *
>>      public AbstractController() {
>>      }
>> 
>>      public AbstractController(Class<T> itemClass) {
>>          this.itemClass = itemClass;
>>      }
>>  }
> DiscountController.java:
>>  @Named(value = "discountCodeController")
>>  @ViewAccessScoped
>>  public class DiscountCodeController extends 
>>  AbstractController<DiscountCode> implements Serializable {
>> 
>>      public DiscountCodeController() {
>>          super(DiscountCode.class);
>>      }
>> 
>>  }
> Notice how I am injecting an AbstractFacade<T> inside 
> AbstractController<T>. This works in Glassfish but fails in Tomee/OpenEJB.
> 
> Attached is the the deployment log of TomEE: http://pastebin.com/iZHZqy5d
> 
> Any input from you guys?
> 
> 
> 
> On 10/28/2013 04:29 PM, Romain Manni-Bucau wrote:
>>  I needed it for other reasons. Globally while not using producers it should
>>  work.
>>  Le 28 oct. 2013 22:21, "Chris Owens" 
> <ct...@chris-owens.com> a
>>  écrit :
>> 
>>>  Thank you, that code is very helpful.  I was hoping to be able to do it
>>>  without the use of an additional qualifier.
>>> 
>>> 
>>> 
>>>  --
>>>  View this message in context:
>>> 
> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html
>>>  Sent from the OpenEJB User mailing list archive at Nabble.com.
>>> 
> 

Re: CDI Injecting parameterized types

Posted by Kay Wrobel <ka...@gmx.net>.
Yeah, since NetBeans bundles the Glassfish application server, I am 
usually testing my app with it. TomEE just showed up on my radar earlier 
this year, but I had a hard time getting NetBeans to even recognize it 
for generating pages from entity classes. Now that I found a workaround 
and that the upcoming NetBeans release (8.0) will support TomEE 
natively, I am testing with it as well. Hence some of the issues I have 
encountered so far. But those were related to OpenJPA really.

But this problem seems more on the CDI implementation of TomEE and it 
seems to be discrepant in this particular regard. I am in no way 
familiar with what the spec is saying about injecting from an abstract 
class. So I hope that some of the more senior TomEE devs have an ear and 
eye for the topic here.

On 10/28/2013 05:30 PM, Howard W. Smith, Jr. wrote:
> Interesting, you're using NetBeans and you have code that looks very
> similar to mine, and it seems as though you did as I did... migrate from
> glassfish 3.1.2(.2) to tomee(+).
>
> at any rate, I think I remember seeing-and-experiencing that exception
> before (some/long time ago[1]...in the past after migrating from
> glassfish-to-tomee and JSF-managed-beans to CDI-managed-beans).
>
> [1]
> http://openejb.979440.n4.nabble.com/TomEE-CDI-adding-Typed-resulted-in-UnsatisfiedResolutionException-td4663062.html
>
>
>
>
>
>
>
>
>
> On Mon, Oct 28, 2013 at 6:11 PM, Kay Wrobel <ka...@gmx.net> wrote:
>
>> For those looking at the log: the error messages start at around line 214.
>>
>>
>> On 10/28/2013 05:06 PM, Kay Wrobel wrote:
>>
>>> Interesting that this topic has come up. I just tried to roll out a
>>> change to my project where I have following situation:
>>> Currently, I have an AbstractController and then a Controller for each
>>> entity class. On the EJB side of things, I have an AbstractFacade and an
>>> entity Facade for each entity, each annotated with @Stateless. Right now, I
>>> am injecting an EntityFacade object into an EntityController and then hand
>>> off the actual object to a variable that sits inside the
>>> AbstractController. I wanted to change that behavior and perform the
>>> injection right inside the abstract controller class. To give you a more
>>> concrete example, this is how it looks like now:
>>>
>>> AbstractController.java:
>>>
>>>> public abstract class AbstractController<T> {
>>>>
>>>>      private AbstractFacade<T> ejbFacade;
>>>>
>>>>      public AbstractController() {
>>>>      }
>>>>
>>>>      protected AbstractFacade<T> getFacade() {
>>>>          return ejbFacade;
>>>>      }
>>>>
>>>>      protected void setFacade(AbstractFacade<T> ejbFacade) {
>>>>          this.ejbFacade = ejbFacade;
>>>>      }
>>>> }
>>>>
>>> CustomerController.java:
>>>
>>>> @Named(value = "discountCodeController")
>>>> @ViewAccessScoped
>>>> public class DiscountCodeController extends AbstractController<**DiscountCode>
>>>> implements Serializable {
>>>>
>>>> *    @Inject**
>>>> **    private DiscountCodeFacade ejbFacade;**
>>>> *
>>>>      @PostConstruct
>>>>      public void init() {
>>>>          super.setFacade(ejbFacade);
>>>>      }
>>>>
>>>> }
>>>>
>>> Now for the change that I had already tested out with Glassfish 3.1.2:
>>>
>>> AbstractController.java:
>>>
>>>> public abstract class AbstractController<T> {
>>>>
>>>> *    @Inject**
>>>> **    private AbstractFacade<T> ejbFacade;**
>>>> *
>>>>      public AbstractController() {
>>>>      }
>>>>
>>>>      public AbstractController(Class<T> itemClass) {
>>>>          this.itemClass = itemClass;
>>>>      }
>>>> }
>>>>
>>> DiscountController.java:
>>>
>>>> @Named(value = "discountCodeController")
>>>> @ViewAccessScoped
>>>> public class DiscountCodeController extends AbstractController<**DiscountCode>
>>>> implements Serializable {
>>>>
>>>>      public DiscountCodeController() {
>>>>          super(DiscountCode.class);
>>>>      }
>>>>
>>>> }
>>>>
>>> Notice how I am injecting an AbstractFacade<T> inside
>>> AbstractController<T>. This works in Glassfish but fails in Tomee/OpenEJB.
>>>
>>> Attached is the the deployment log of TomEE: http://pastebin.com/iZHZqy5d
>>>
>>> Any input from you guys?
>>>
>>>
>>> On 10/28/2013 04:29 PM, Romain Manni-Bucau wrote:
>>>
>>>> I needed it for other reasons. Globally while not using producers it
>>>> should
>>>> work.
>>>> Le 28 oct. 2013 22:21, "Chris Owens" <ct...@chris-owens.com> a
>>>> écrit :
>>>>
>>>>   Thank you, that code is very helpful.  I was hoping to be able to do it
>>>>> without the use of an additional qualifier.
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://openejb.979440.n4.**nabble.com/CDI-Injecting-**
>>>>> parameterized-types-**tp4665761p4665766.html<http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html>
>>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>


Re: CDI Injecting parameterized types

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
Interesting, you're using NetBeans and you have code that looks very
similar to mine, and it seems as though you did as I did... migrate from
glassfish 3.1.2(.2) to tomee(+).

at any rate, I think I remember seeing-and-experiencing that exception
before (some/long time ago[1]...in the past after migrating from
glassfish-to-tomee and JSF-managed-beans to CDI-managed-beans).

[1]
http://openejb.979440.n4.nabble.com/TomEE-CDI-adding-Typed-resulted-in-UnsatisfiedResolutionException-td4663062.html









On Mon, Oct 28, 2013 at 6:11 PM, Kay Wrobel <ka...@gmx.net> wrote:

> For those looking at the log: the error messages start at around line 214.
>
>
> On 10/28/2013 05:06 PM, Kay Wrobel wrote:
>
>> Interesting that this topic has come up. I just tried to roll out a
>> change to my project where I have following situation:
>> Currently, I have an AbstractController and then a Controller for each
>> entity class. On the EJB side of things, I have an AbstractFacade and an
>> entity Facade for each entity, each annotated with @Stateless. Right now, I
>> am injecting an EntityFacade object into an EntityController and then hand
>> off the actual object to a variable that sits inside the
>> AbstractController. I wanted to change that behavior and perform the
>> injection right inside the abstract controller class. To give you a more
>> concrete example, this is how it looks like now:
>>
>> AbstractController.java:
>>
>>> public abstract class AbstractController<T> {
>>>
>>>     private AbstractFacade<T> ejbFacade;
>>>
>>>     public AbstractController() {
>>>     }
>>>
>>>     protected AbstractFacade<T> getFacade() {
>>>         return ejbFacade;
>>>     }
>>>
>>>     protected void setFacade(AbstractFacade<T> ejbFacade) {
>>>         this.ejbFacade = ejbFacade;
>>>     }
>>> }
>>>
>>
>> CustomerController.java:
>>
>>> @Named(value = "discountCodeController")
>>> @ViewAccessScoped
>>> public class DiscountCodeController extends AbstractController<**DiscountCode>
>>> implements Serializable {
>>>
>>> *    @Inject**
>>> **    private DiscountCodeFacade ejbFacade;**
>>> *
>>>     @PostConstruct
>>>     public void init() {
>>>         super.setFacade(ejbFacade);
>>>     }
>>>
>>> }
>>>
>> Now for the change that I had already tested out with Glassfish 3.1.2:
>>
>> AbstractController.java:
>>
>>> public abstract class AbstractController<T> {
>>>
>>> *    @Inject**
>>> **    private AbstractFacade<T> ejbFacade;**
>>> *
>>>     public AbstractController() {
>>>     }
>>>
>>>     public AbstractController(Class<T> itemClass) {
>>>         this.itemClass = itemClass;
>>>     }
>>> }
>>>
>> DiscountController.java:
>>
>>> @Named(value = "discountCodeController")
>>> @ViewAccessScoped
>>> public class DiscountCodeController extends AbstractController<**DiscountCode>
>>> implements Serializable {
>>>
>>>     public DiscountCodeController() {
>>>         super(DiscountCode.class);
>>>     }
>>>
>>> }
>>>
>> Notice how I am injecting an AbstractFacade<T> inside
>> AbstractController<T>. This works in Glassfish but fails in Tomee/OpenEJB.
>>
>> Attached is the the deployment log of TomEE: http://pastebin.com/iZHZqy5d
>>
>> Any input from you guys?
>>
>>
>> On 10/28/2013 04:29 PM, Romain Manni-Bucau wrote:
>>
>>> I needed it for other reasons. Globally while not using producers it
>>> should
>>> work.
>>> Le 28 oct. 2013 22:21, "Chris Owens" <ct...@chris-owens.com> a
>>> écrit :
>>>
>>>  Thank you, that code is very helpful.  I was hoping to be able to do it
>>>> without the use of an additional qualifier.
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://openejb.979440.n4.**nabble.com/CDI-Injecting-**
>>>> parameterized-types-**tp4665761p4665766.html<http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html>
>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>
>>>>
>>
>>
>

Re: CDI Injecting parameterized types

Posted by Kay Wrobel <ka...@gmx.net>.
For those looking at the log: the error messages start at around line 214.

On 10/28/2013 05:06 PM, Kay Wrobel wrote:
> Interesting that this topic has come up. I just tried to roll out a 
> change to my project where I have following situation:
> Currently, I have an AbstractController and then a Controller for each 
> entity class. On the EJB side of things, I have an AbstractFacade and 
> an entity Facade for each entity, each annotated with @Stateless. 
> Right now, I am injecting an EntityFacade object into an 
> EntityController and then hand off the actual object to a variable 
> that sits inside the AbstractController. I wanted to change that 
> behavior and perform the injection right inside the abstract 
> controller class. To give you a more concrete example, this is how it 
> looks like now:
>
> AbstractController.java:
>> public abstract class AbstractController<T> {
>>
>>     private AbstractFacade<T> ejbFacade;
>>
>>     public AbstractController() {
>>     }
>>
>>     protected AbstractFacade<T> getFacade() {
>>         return ejbFacade;
>>     }
>>
>>     protected void setFacade(AbstractFacade<T> ejbFacade) {
>>         this.ejbFacade = ejbFacade;
>>     }
>> }
>
> CustomerController.java:
>> @Named(value = "discountCodeController")
>> @ViewAccessScoped
>> public class DiscountCodeController extends 
>> AbstractController<DiscountCode> implements Serializable {
>>
>> *    @Inject**
>> **    private DiscountCodeFacade ejbFacade;**
>> *
>>     @PostConstruct
>>     public void init() {
>>         super.setFacade(ejbFacade);
>>     }
>>
>> }
> Now for the change that I had already tested out with Glassfish 3.1.2:
>
> AbstractController.java:
>> public abstract class AbstractController<T> {
>>
>> *    @Inject**
>> **    private AbstractFacade<T> ejbFacade;**
>> *
>>     public AbstractController() {
>>     }
>>
>>     public AbstractController(Class<T> itemClass) {
>>         this.itemClass = itemClass;
>>     }
>> }
> DiscountController.java:
>> @Named(value = "discountCodeController")
>> @ViewAccessScoped
>> public class DiscountCodeController extends 
>> AbstractController<DiscountCode> implements Serializable {
>>
>>     public DiscountCodeController() {
>>         super(DiscountCode.class);
>>     }
>>
>> }
> Notice how I am injecting an AbstractFacade<T> inside 
> AbstractController<T>. This works in Glassfish but fails in 
> Tomee/OpenEJB.
>
> Attached is the the deployment log of TomEE: http://pastebin.com/iZHZqy5d
>
> Any input from you guys?
>
>
> On 10/28/2013 04:29 PM, Romain Manni-Bucau wrote:
>> I needed it for other reasons. Globally while not using producers it 
>> should
>> work.
>> Le 28 oct. 2013 22:21, "Chris Owens" <ct...@chris-owens.com> a
>> écrit :
>>
>>> Thank you, that code is very helpful.  I was hoping to be able to do it
>>> without the use of an additional qualifier.
>>>
>>>
>>>
>>> -- 
>>> View this message in context:
>>> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html 
>>>
>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>
>
>


Re: CDI Injecting parameterized types

Posted by Kay Wrobel <ka...@gmx.net>.
Interesting that this topic has come up. I just tried to roll out a 
change to my project where I have following situation:
Currently, I have an AbstractController and then a Controller for each 
entity class. On the EJB side of things, I have an AbstractFacade and an 
entity Facade for each entity, each annotated with @Stateless. Right 
now, I am injecting an EntityFacade object into an EntityController and 
then hand off the actual object to a variable that sits inside the 
AbstractController. I wanted to change that behavior and perform the 
injection right inside the abstract controller class. To give you a more 
concrete example, this is how it looks like now:

AbstractController.java:
> public abstract class AbstractController<T> {
>
>     private AbstractFacade<T> ejbFacade;
>
>     public AbstractController() {
>     }
>
>     protected AbstractFacade<T> getFacade() {
>         return ejbFacade;
>     }
>
>     protected void setFacade(AbstractFacade<T> ejbFacade) {
>         this.ejbFacade = ejbFacade;
>     }
> }

CustomerController.java:
> @Named(value = "discountCodeController")
> @ViewAccessScoped
> public class DiscountCodeController extends 
> AbstractController<DiscountCode> implements Serializable {
>
> *    @Inject**
> **    private DiscountCodeFacade ejbFacade;**
> *
>     @PostConstruct
>     public void init() {
>         super.setFacade(ejbFacade);
>     }
>
> }
Now for the change that I had already tested out with Glassfish 3.1.2:

AbstractController.java:
> public abstract class AbstractController<T> {
>
> *    @Inject**
> **    private AbstractFacade<T> ejbFacade;**
> *
>     public AbstractController() {
>     }
>
>     public AbstractController(Class<T> itemClass) {
>         this.itemClass = itemClass;
>     }
> }
DiscountController.java:
> @Named(value = "discountCodeController")
> @ViewAccessScoped
> public class DiscountCodeController extends 
> AbstractController<DiscountCode> implements Serializable {
>
>     public DiscountCodeController() {
>         super(DiscountCode.class);
>     }
>
> }
Notice how I am injecting an AbstractFacade<T> inside 
AbstractController<T>. This works in Glassfish but fails in Tomee/OpenEJB.

Attached is the the deployment log of TomEE: http://pastebin.com/iZHZqy5d

Any input from you guys?


On 10/28/2013 04:29 PM, Romain Manni-Bucau wrote:
> I needed it for other reasons. Globally while not using producers it should
> work.
> Le 28 oct. 2013 22:21, "Chris Owens" <ct...@chris-owens.com> a
> écrit :
>
>> Thank you, that code is very helpful.  I was hoping to be able to do it
>> without the use of an additional qualifier.
>>
>>
>>
>> --
>> View this message in context:
>> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>


Re: CDI Injecting parameterized types

Posted by Romain Manni-Bucau <rm...@gmail.com>.
I needed it for other reasons. Globally while not using producers it should
work.
Le 28 oct. 2013 22:21, "Chris Owens" <ct...@chris-owens.com> a
écrit :

> Thank you, that code is very helpful.  I was hoping to be able to do it
> without the use of an additional qualifier.
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: CDI Injecting parameterized types

Posted by Chris Owens <ct...@chris-owens.com>.
Thank you, that code is very helpful.  I was hoping to be able to do it
without the use of an additional qualifier.



--
View this message in context: http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665766.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: CDI Injecting parameterized types

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Mon, Oct 28, 2013 at 4:49 PM, Romain Manni-Bucau
<rm...@gmail.com>wrote:

> Ps:
>
> https://github.com/rmannibucau/cdi-converters/blob/master/src/test/java/com/github/rmannibucau/converter/ConverterTest.java
>

put some space in there, since 'does it' immediately followed URL (above)

does it
>

Re: CDI Injecting parameterized types

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Ps:
https://github.com/rmannibucau/cdi-converters/blob/master/src/test/java/com/github/rmannibucau/converter/ConverterTest.javadoes
it
Le 28 oct. 2013 21:44, "Romain Manni-Bucau" <rm...@gmail.com> a
écrit :

> You have a sample?
> Le 28 oct. 2013 21:39, "Chris Owens" <ct...@chris-owens.com> a
> écrit :
>
>> "More or less" scares me.... can you point me to a working example of
>> using
>> CDI to inject a parameterized generic class?  When I try to do it I'm
>> encountering this:
>>
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665763.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>

Re: CDI Injecting parameterized types

Posted by Romain Manni-Bucau <rm...@gmail.com>.
You have a sample?
Le 28 oct. 2013 21:39, "Chris Owens" <ct...@chris-owens.com> a
écrit :

> "More or less" scares me.... can you point me to a working example of using
> CDI to inject a parameterized generic class?  When I try to do it I'm
> encountering this:
>
>
>
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665763.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: CDI Injecting parameterized types

Posted by Chris Owens <ct...@chris-owens.com>.
"More or less" scares me.... can you point me to a working example of using
CDI to inject a parameterized generic class?  When I try to do it I'm
encountering this:







--
View this message in context: http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761p4665763.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: CDI Injecting parameterized types

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

Cdi more or less support it but not ejbs.
Le 28 oct. 2013 21:16, "Chris Owens" <ct...@chris-owens.com> a
écrit :

> My (beginner's) understanding of JSR-299 is that it recognizes
> parameterized
> types:
>
> MyInterface.java
>
>
> Class1.java
>
>
> Class2.java
>
>
> Class3.java
>
>
> I'm expecting var1 to be bound to a bean that implements Class2, but that
> isn't happening.   Do I misunderstand how JSR-299 uses generics?
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: CDI Injecting parameterized types

Posted by "John D. Ament" <jo...@gmail.com>.
The issue is that the CDI spec and EJB specs are not in alignment.  EJB
injection rules are at play here, and since they both implement the same
interface you are running into this issue.

If your classes were not annotated @Stateless this would not happen.


On Mon, Oct 28, 2013 at 4:13 PM, Chris Owens
<ct...@chris-owens.com>wrote:

> My (beginner's) understanding of JSR-299 is that it recognizes
> parameterized
> types:
>
> MyInterface.java
>
>
> Class1.java
>
>
> Class2.java
>
>
> Class3.java
>
>
> I'm expecting var1 to be bound to a bean that implements Class2, but that
> isn't happening.   Do I misunderstand how JSR-299 uses generics?
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/CDI-Injecting-parameterized-types-tp4665761.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>