EJB 3 injections and JNDI look-ups do not work in managed beans (java server faces)

"Siarhei Dudzin" <[email protected]> Thu, 20 Jul 2006 02:13:27 +0200
Newsgroups gmane.text.xml.resin.user
Message-ID <[email protected]>
------=_Part_150139_17350650.1153354407633
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi All,


I am trying to use EJB3 on resin 3.0.19. First I was trying to use
dependency injection and all ijnections returned null (and session beans and
EntityManager). After that I tried to perform lookup via InitialContext and
all lookups returned null (no NameNotFound exceptions were thrown). After
that I checked the only difference between my implementaion and the examples
from the website of resin was that in the examples the lookups are done in
servlets. So I simply copied the same dependency injection (
@PersistenceContext(name="example") ) from the managed bean and put it in a
servlet and it worked!
I would be very grateful if somebody could tell me how to resolve this
problem. My resin-web.xml is the following:


<web-app xmlns="http://caucho.com/ns/resin">

    <character-encoding>UTF-8</character-encoding>

    <database jndi-name="jdbc/EDB">
        <driver type="
com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
            <url>jdbc:mysql://localhost:3306/edb</url>
            <user>edb</user>
            <password>edb</password>
        </driver>
    </database>

    <!--
       - configuration for the JNDI server.
      -->
    <ejb-server>
        <jndi-name>java:comp/env/ejb</jndi-name>
        <data-source>jdbc/EDB</data-source>
    </ejb-server>

</web-app>

Thank you in advance,
Sergei

------=_Part_150139_17350650.1153354407633
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi All,<br><br><br>I am trying to use EJB3 on resin 3.0.19. First I was trying to use dependency injection and all ijnections returned null (and session beans and EntityManager). After that I tried to perform lookup via InitialContext and all lookups returned null (no NameNotFound exceptions were thrown). After that I checked the only difference between my implementaion and the examples from the website of resin was that in the examples the lookups are done in servlets. So I simply copied the same dependency injection ( @PersistenceContext(name=&quot;example&quot;) ) from the managed bean and put it in a servlet and it worked!
<br>I would be very grateful if somebody could tell me how to resolve this problem. My resin-web.xml is the following:<br><br><br>&lt;web-app xmlns=&quot;<a href="http://caucho.com/ns/resin">http://caucho.com/ns/resin</a>
&quot;&gt;<br><br>&nbsp;&nbsp; &nbsp;&lt;character-encoding&gt;UTF-8&lt;/character-encoding&gt;<br>&nbsp;&nbsp;  <br>&nbsp;&nbsp; &nbsp;&lt;database jndi-name=&quot;jdbc/EDB&quot;&gt;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;driver type=&quot;com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
&quot;&gt;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;url&gt;jdbc:mysql://localhost:3306/edb&lt;/url&gt;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;user&gt;edb&lt;/user&gt;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;password&gt;edb&lt;/password&gt;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;/driver&gt;<br>&nbsp;&nbsp; &nbsp;&lt;/database&gt;
<br>&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp; &lt;!--<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; - configuration for the JNDI server.<br>&nbsp;&nbsp; &nbsp;&nbsp; --&gt;<br>&nbsp;&nbsp; &nbsp;&lt;ejb-server&gt;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;jndi-name&gt;java:comp/env/ejb&lt;/jndi-name&gt;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;data-source&gt;jdbc/EDB&lt;/data-source&gt;
<br>&nbsp;&nbsp; &nbsp;&lt;/ejb-server&gt;<br>&nbsp;<br>&lt;/web-app&gt;<br><br>Thank you in advance,<br>Sergei<br>

------=_Part_150139_17350650.1153354407633--