users@glassfish.java.net

Issue with _at_Inject and _at_WebService

From: Noah White <emailnbw_at_gmail.com>
Date: Thu, 31 Jan 2013 16:03:28 -0500

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