Note that there are some explanatory texts on larger screens.

plurals
  1. PO@EJB not injected to JAX-RS
    primarykey
    data
    text
    <p>I have <code>@LocalBean</code>s and JAX-RS resources in different packages in a single ear.</p> <p>And I also have a ServletFilter filtering before those resources.</p> <p>I found that <code>@EJB</code> works for the ServletFilter but not for those resources.</p> <pre class="lang-java prettyprint-override"><code>@Stateless @LocalBean class MyBean { // in ejb jar } @WebFilter(urlPatterns = {"/*"}) class MyFilter implements Filter { // in the same war @EJB MyBean myBean; // not null } @ApplicationPath("/") class MyApplication extends Application { // in the same war } @Path("/my") class MyResource { // in the same war @EJB MyBean myBean; // null } </code></pre> <p>No logs special, just an NPE in MyResource's method. Can anybody help me?</p> <p>UPDATE -----------------------------------------------</p> <p>Making those resource classes as <code>@Stateless</code> do works.</p> <p>But I just curious that those ejb-jar and web-war are assembled into a single ear.</p> <p>And then the web-war is a web component, isn't it?</p> <p>UPDATE2 ------------------------------------------------------</p> <p>Oh, I'm sorry. There is also <code>MyApplication</code> that makes MyResource as a JAX-RS resource.</p> <p>When I deploy the <code>ear</code> GF detect it as an 'Enterprise Application'.</p> <p>UPDATE3 ---------------------------------------------------------------</p> <p>Here comes my application.xml</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6"&gt; &lt;display-name&gt;sngp-v0-ear&lt;/display-name&gt; &lt;module&gt; &lt;!-- EJBs are here --&gt; &lt;ejb&gt;sngp-v0-beans-1.0-alpha-1-SNAPSHOT.jar&lt;/ejb&gt; &lt;/module&gt; &lt;module&gt; &lt;web&gt; &lt;!-- JAX-RS are here --&gt; &lt;web-uri&gt;sngp-v0-mobile-resources-1.0-alpha-1-SNAPSHOT.war&lt;/web-uri&gt; &lt;context-root&gt;/sngp-v0-mobile-resources&lt;/context-root&gt; &lt;/web&gt; &lt;/module&gt; &lt;library-directory&gt;lib&lt;/library-directory&gt; &lt;/application&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload