1 Reply Latest reply on Sep 4, 2007 11:28 AM by jc7442

    Mail injection with EJB3

    jc7442

      I probably have misunderstood the @Resource annotation. I try to inject my mail session in a EJB3.

      When I write ... Session is not injected

      @Resource(mappedname="java:/Mail" Session session;



      If I write ... it works fine

      @Resource SessionContext ctx;
      public .... (){
      ctx.lookup("java:/Mail")
      }
      


      I believed that this two syntax was equivalent. What did I miss ?

      Is it possible to inject the mail session ? I only find a solution in writting jboss.xml and ejb-jar.xml. But in that case, using injection is much more complex than the lookup.

        • 1. Re: Mail injection with EJB3
          jc7442

          It looks like

          @Resource(name = "Mail", mappedName = "java:/Mail")
          
          works fine.

          What's the difference between
          @Resource(name = "Mail", mappedName = "java:/Mail")
          and @Resource(mappedName = "java:/Mail") ?


          When I inject JMS connectionFactory I jyust do

          @Resource(name = "jmsXA")