users@glassfish.java.net

Re: Issue with _at_Inject and _at_WebService

From: Noah White <emailnbw_at_gmail.com>
Date: Thu, 31 Jan 2013 17:04:58 -0500

Please disregard. I discovered some shenanigans with how this web service was being invoked to begin with. Hint, 'new' was involved.

-Noah

On Jan 31, 2013, at 4:03 PM, Noah White <emailnbw_at_gmail.com> wrote:

>
> From things I've read, including Arun's blog [1], it looks like I should be able to use @Inject with a @WebService annotated class but it is not working for me, though injection of this bean does work in other classes (eg. @RequestScoped JAX-RS/Jersey resource classes).
>
> The bean I am trying to inject into my jax-ws/metro class is an @ApplicationScoped CDI bean. Arun's blog uses a @RequestScoped bean. My setup looks something like this:
>
> @WebService(serviceName = "FooService")
> public class FooService {
>
> @Inject
> BarBean myBarBean;
>
> ...
> }
>
> @ApplicationScoped
> public class BarBean implements Serializable {
>
> ..
>
> @PostConstruct
> public void afterCreate() {
>
> do stuff
> }
>
> ..
>
> }
>
>
> myBarBean is always NULL. This is under GF 3.1.2 b23. Thoughts?
>
> -Noah
>
> [1] - https://blogs.oracle.com/arungupta/entry/totd_124_using_cdi_jpa