I take another test:
@Depends({
  |     "jmx.service.wsmq:service=WSMQ_QXL",
  |     "jmx.service.wsmq:service=WSMQQueueConnectionFactory"
  | })
  | public @Stateless class TestEJBBean implements TestEJB {
  |     private static EJBUtil pu = EJBUtil.getInstance();
  |     
  |     @Resource(mappedName = "WSMQQueueConnectionFactory")
  |     private QueueConnectionFactory qf;
  |     
  |     @Resource(mappedName = "wsmq/QXL")
  |     private Queue qxl;
  |     
  |     @Resource
  |     private SessionContext ctx;
  |     
  |     @PersistenceContext(unitName = "fids")
  |     protected EntityManager em;
  |     
  |     public void dosomthing() {
  |             if(qf != null)
  |                     System.out.println("EJB qf ok");
  |             else
  |                     System.out.println("EJB qf null");
  |             if(qxl != null)
  |                     System.out.println("EJB qxl ok");
  |             else
  |                     System.out.println("EJB qxl null");
  |             if(ctx != null)
  |                     System.out.println("EJB ctx ok");
  |             else
  |                     System.out.println("EJB ctx null");
  |             if(em != null)
  |                     System.out.println("EJB em ok");
  |             else
  |                     System.out.println("EJB em null");
  |             pu.process();
  |     }
  | }
public class EJBUtil {
  |     private static EJBUtil instance;
  |     
  |     @EJB(mappedName = "WSMQQueueConnectionFactory")
  |     private QueueConnectionFactory qf;
  |     
  |     @EJB(mappedName = "wsmq/QXL")
  |     private Queue qxl;
  |     
  |     @Resource
  |     private SessionContext ctx;
  |     
  |     @PersistenceContext(unitName = "fids")
  |     private EntityManager em;
  |     
  |     public synchronized void process() {
  |             if(qf != null)
  |                     System.out.println("qf ok");
  |             else
  |                     System.out.println("qf null");
  |             if(qxl != null)
  |                     System.out.println("qxl ok");
  |             else
  |                     System.out.println("qxl null");
  |             if(ctx != null)
  |                     System.out.println("ctx ok");
  |             else
  |                     System.out.println("ctx null");
  |             if(em != null)
  |                     System.out.println("em ok");
  |             else
  |                     System.out.println("em null");
  |     }
  |     
  |     public static synchronized EJBUtil getInstance() {
  |             if(instance == null)
  |                     instance = new EJBUtil();
  |             return instance;
  |     }
  | }

Class EJBUtil and TestEJBBean in one deploying file (TestEJB.ejb3).
result is:
anonymous wrote : 23:39:16,743 INFO  [STDOUT] EJB qf ok
  | 23:39:16,743 INFO  [STDOUT] EJB qxl ok
  | 23:39:16,743 INFO  [STDOUT] EJB ctx ok
  | 23:39:16,743 INFO  [STDOUT] EJB em ok
  | 23:39:16,743 INFO  [STDOUT] qf null
  | 23:39:16,743 INFO  [STDOUT] qxl null
  | 23:39:16,743 INFO  [STDOUT] ctx null
  | 23:39:16,743 INFO  [STDOUT] em null

so @EJB,@Resource,@PersistenceContext can't working in java bean.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3931608#3931608

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3931608


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to