在JNDI上下文中找不到Glassfish JMS队列

时间:2015-09-19 03:53:04

标签: java glassfish jms jndi glassfish-4

我需要帮助。

下面的Glassfish管理控制台屏幕显示我已经设置了三个JMS目标资源。除名称外,所有内容都相同。但我从本地Java客户端(Glassfish也是本地)的JNDI查找只能看到前两个。客户端代码和控制台输出位于屏幕截图下方。

我甚至不知道在哪里开始弄清楚为什么一两个工作,三个不工作。谁能提出任何建议。这应该是基本的。这三个都是相同的设置。没有任何其他属性设置。我真的需要帮助或指导。

Glassfish Admin Console Screen Shot

CODE:

公共类SrackOverflow1 {

  public static void main(String[] args) {
    Properties env = new Properties();
    env.put ("java.naming.factory.initial", "com.sun.jndi.fscontext.RefFSContextFactory");
    env.put ("java.naming.provider.url","file:///C:/glassfish4/mq/opt/java/my_broker");
    try {
      Context jndiContext = (Context) new InitialContext(env);

      Queue queueOne   = (Queue) jndiContext.lookup("jms/goSendQueue");
      System.out.println("queueOne ok:\n" + queueOne);

      Queue queueTwo   = (Queue) jndiContext.lookup("jms/goReceiveQueue");
      System.out.println("\nqueueTwo ok:\n" + queueTwo);

      Queue queueThree = (Queue) jndiContext.lookup("jms/goTestQueue");
      System.out.println("\nqueueThree ok:\n" + queueThree);

    } catch (NamingException e) {
      System.out.println("\nThrew Naming Exception\nerror msg: " + e.getMessage() +"\n");
      e.printStackTrace();
    }
  }

CONSOLE:

queueOne ok:
Sun Java System MQ Destination
getName():      goSendQueuq
Class:          com.sun.messaging.Queue
getVERSION():       3.0
isReadonly():       false
getProperties():    {imqDestinationName=goSendQueuq, imqDestinationDescription=A Description for the Destination 
Object}

queueTwo ok:
Sun Java System MQ Destination
getName():      goReceiveQueue
Class:          com.sun.messaging.Queue
getVERSION():       3.0
isReadonly():       false
getProperties():    {imqDestinationName=goReceiveQueue, imqDestinationDescription=A Description for the Destinati
on Object}

Threw Naming Exception
error msg: jms/goTestQueue

javax.naming.NameNotFoundException: jms/goTestQueue
    at com.sun.jndi.fscontext.RefFSContext.getObjectFromBindings(RefFSContext.java:400)
    at com.sun.jndi.fscontext.RefFSContext.lookupObject(RefFSContext.java:327)
    at com.sun.jndi.fscontext.RefFSContext.lookup(RefFSContext.java:146)
    at com.sun.jndi.fscontext.FSContext.lookup(FSContext.java:127)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at org.america3.testclasses.SrackOverflow1.main(SrackOverflow1.java:21)

0 个答案:

没有答案