1 Reply Latest reply on Jan 30, 2006 6:11 PM by bill.burke

    Help with injecting simple resources

    jhumble

      I am trying to inject a simple integer value into a field of a session bean. I'd be grateful for any help with this. At present, I am getting the message, "Unbound injected resource" when I deploy the .ejb3 file. I am using jboss-4.0.3SP1.

      The Session Bean interface looks like this:

      package com.foo.bar;
      
      import javax.ejb.Remote;
      
      @Remote
      public interface Inject {
      
       public int bar();
      }
      


      The bean itself is like this:


      package com.foo.bar;
      
      import javax.annotation.Resource;
      import javax.ejb.Stateless;
      
      @Stateless
      public class InjectIt implements Inject {
      
       @Resource(name="jonoo") int jonoo;
      
       public InjectIt() {
       }
      
       public int bar() {
       // TODO Auto-generated method stub
       return 0;
       }
      }
      


      Finally, the ejb-jar.xml file is like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <ejb-jar 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/ejb-jar_3_0.xsd"
       version="3.0">
       <display-name>Foo</display-name>
       <enterprise-beans>
       <session>
       <ejb-name>
       com.foo.bar.InjectIt
       </ejb-name>
       <ejb-class>
       com.foo.bar.InjectIt
       </ejb-class>
       <env-entry>
       <env-entry-name>
       jonoo
       </env-entry-name>
       <env-entry-type>java.lang.Integer</env-entry-type>
       <env-entry-value>11</env-entry-value>
       </env-entry>
       </session>
       </enterprise-beans>
      </ejb-jar>
      


      It seems to be picking up the deployment descriptor, because it complains if I change the <env-entry-name>. I am expecting it to set the value of the "jonoo" field to 11, but it remains unset.

      Advice on fixing this would be most welcome.

      Thanks,

      Jon.