有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

我需要帮助

下面的Glassfish管理控制台屏幕显示我已经设置了三个JMS目标资源。除了名字外,其他都一样。但是我从本地java客户机(Glassfish也是本地的)查找JNDI时,只能看到前两个。客户端代码和控制台输出在屏幕截图下方

我甚至不知道该从哪里开始找出为什么一个和两个有效,而三个无效。有人能提出什么建议吗。这应该是基本的,因为它得到的。这三个都是相同的设置。没有设置任何其他属性。我真的需要帮助或指导

Glassfish Admin Console Screen Shot

代码:

公共类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();
    }
  }

控制台:

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) 个答案