You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by David Beer <da...@gmail.com> on 2014/04/04 20:53:43 UTC

Wicket CDI 1.1

Hi All

I am in the process of moving my application to JavaEE7 and CDI 1.1. Things
are going well all except for some CDI values. I have an @Stateless Session
bean used for my DAO which I then Inject into various classes. The issue I
have is that some of the classes don't get the reference Injected properly
and give a NPE. With wicket CDI I was able to call
CdiContainer.get().getNonContextualManager().inject(this); to Inject the
reference properly.

I know CDI 1.1 is different but I can't work out how to Inject the
Component with Wicket CDI 1.1?

Here is the code in my WicketApplication init():

 new CdiConfiguration().setPropagation(NONE).configure(this);

Thanks

David

Re: Wicket CDI 1.1

Posted by David Beer <da...@gmail.com>.
Hi Edmund

Thanks for the info. It appears the problem spanned further down to the
library I am using. This was more related to Apache Shiro not being CDI
aware. In the end I followed this post StackOverflow
http://stackoverflow.com/questions/15605038/unable-to-inject-my-dao-in-a-custom-apache-shiro-authorizingrealm.
I have just confirmed that this works as described.

Wicket CDI works well in injecting values to my components including pages
and panels. Thanks for the tip about NonContextual.of() method that is good
to know.

Thanks

David


On 7 April 2014 14:36, Emond Papegaaij <em...@gmail.com> wrote:

> Did you migrate to wicket-cdi-1.1? To inject a non-managed class, use
> NonContextual.of(MyClass.class).inject(instance). Components, however, are
> injected by wicket-cdi itself. You should not need to inject those
> manually.
>
> Best regards,
> Emond
> Op 4 apr. 2014 20:54 schreef "David Beer" <da...@gmail.com>:
>
> > Hi All
> >
> > I am in the process of moving my application to JavaEE7 and CDI 1.1.
> Things
> > are going well all except for some CDI values. I have an @Stateless
> Session
> > bean used for my DAO which I then Inject into various classes. The issue
> I
> > have is that some of the classes don't get the reference Injected
> properly
> > and give a NPE. With wicket CDI I was able to call
> > CdiContainer.get().getNonContextualManager().inject(this); to Inject the
> > reference properly.
> >
> > I know CDI 1.1 is different but I can't work out how to Inject the
> > Component with Wicket CDI 1.1?
> >
> > Here is the code in my WicketApplication init():
> >
> >  new CdiConfiguration().setPropagation(NONE).configure(this);
> >
> > Thanks
> >
> > David
> >
>

Re: Wicket CDI 1.1

Posted by Emond Papegaaij <em...@gmail.com>.
Did you migrate to wicket-cdi-1.1? To inject a non-managed class, use
NonContextual.of(MyClass.class).inject(instance). Components, however, are
injected by wicket-cdi itself. You should not need to inject those manually.

Best regards,
Emond
Op 4 apr. 2014 20:54 schreef "David Beer" <da...@gmail.com>:

> Hi All
>
> I am in the process of moving my application to JavaEE7 and CDI 1.1. Things
> are going well all except for some CDI values. I have an @Stateless Session
> bean used for my DAO which I then Inject into various classes. The issue I
> have is that some of the classes don't get the reference Injected properly
> and give a NPE. With wicket CDI I was able to call
> CdiContainer.get().getNonContextualManager().inject(this); to Inject the
> reference properly.
>
> I know CDI 1.1 is different but I can't work out how to Inject the
> Component with Wicket CDI 1.1?
>
> Here is the code in my WicketApplication init():
>
>  new CdiConfiguration().setPropagation(NONE).configure(this);
>
> Thanks
>
> David
>