ejb - @Resource(name="jms/StockQueue", type=javax.jms.Queue) @Stateless public class StockServiceBean{} JNDI lookup does not work -


I am trying to run an example from page 281 of the EJB 3.2 specification, but it creates an error. In short, I have made a queue JMS / StockQueue in Glassfish 4 and I can make a reference about it with @resources (Lookup = "Jms / Stockquay"). So my stateless bean myban successfully received the reference of the queue

  @Stateless Public Class MyBean {@Resource (lookup = "jms / stockQueue") Personal queue queue; Public zip send message () {System.out.println (queue); }}   

But the specification does not provide reference to the stock service service queue.

  @Resource (name = "jms / stockQueue", type = javax.jms.Queue.class) @Stateless public class StockServiceBean {public void processStockInfo () {try context initCtx = new InitialContext ( ); System.out.print (initCtx.lookup ("Java: Computer Application / env / jms / StockQueue")); } Hold (naming exceptions) {ex.printStackTrace (); Instead, it generates an error:  
  SEVERE: javax.naming.NamingException: 'java: comp / env / jms / stockquote' in serialcontact [myEnv = {java.naming.factory. Initial = com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state = com.sun.corba.ee.impl.presentation.rmi JNDIStateFactoryImpl, java.naming.factory.url.pkgs = com.sun .enterprise.naming} [Route exception javax.naming.NameNotFoundException: There is no object bound to Java: comp / env / jms / stockquueue [root exception is java.lang. NullPointerException]]   

Strangely, if instead of the queue, I see ConnectionFactory, as the example works, hopes someone helps me run this example? I appreciate your suggestions thank you Best regards, Marian

I had the same problem with connectionFactory / @Resource / @Stateless on Deploiement @resource injection tries to inject on my service bean, but it has not yet been installed by weld (because they have a @Dependent scope)

I have a manual look up on this function Has decided to do the connection factor and it works

Also see:

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -