[jboss-user] [JNDI/Naming/Network] - Re: EJB3: @Resource name only EJBContext, not in InitialCont

jaikiran do-not-reply at jboss.com
Thu Feb 14 11:17:55 EST 2008


Which version of JBoss do you use? I tested this on my local JBoss-4.2.2 setup with an sample application:


  | @Stateless
  | @Remote ({UserManager.class})
  | @RemoteBinding (jndiBinding = "RemoteUserManagerBean")
  | @Resources( {
  |         @Resource(type = Queue.class, name = "jms/A", mappedName = "queue/A")
  |         })
  | 
  | public class UserManagerBean implements UserManager {
  | 	
  | 	/**
  | 	 * Instance of logger
  | 	 */
  | 	private static Logger logger = Logger.getLogger(UserManagerBean.class);
  | 	
  | 	@PersistenceContext
  | 	private EntityManager entityManager;
  | 	
  | 	@Resource
  | 	private SessionContext sessionContext;
  | 
  | 	/**
  | 	 * @see org.myapp.ejb.UserManager#getUser(long)
  | 	 */
  | 	public User getUser(long id) {
  | 		System.out.println("Entity manager is " + entityManager); 
  | 		return null;
  | 	}
  | 
  | 	/**
  | 	 * @see org.myapp.ejb.UserManager#getUsers(java.lang.String)
  | 	 */
  | 	public List<User> getUsers(String name) {
  | 		Object obj = sessionContext.lookup("jms/A");
  | 		System.out.println("Looked up through session context = " + obj);
  | 		try { 
  | 			Context ctx = new InitialContext();
  | 			Object obj1 = ctx.lookup("java:comp/env/jms/A");
  | 			System.out.println("Looked up java:comp/env/jms/A = " + obj1);
  | 		} catch (Exception e) {
  | 			e.printStackTrace();
  | 		}
  |                //blah blah blah
  |            }
  | 
  | 

Both the lookups (through sessionContext and InitialContext) return me the queue object. 

Can you post your code and also the entire exception stacktrace that you are seeing?

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

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



More information about the jboss-user mailing list