为什么这些属性无法从glassfish查找ConnectionFactory?

时间:2015-08-12 22:24:50

标签: jms jndi glassfish-4

当本地java客户端使用此代码从localhost上运行的Glassfish服务器查找JMS ConnectionFactory时,此代码失败。

谁能告诉我为什么?我是如此绝望甚至有用的侮辱是受欢迎的。 我把控制台输出放在下面(由我的程序格式化)。

 InitialContext ctx = null;
 ConnectionFactory factory = null;

 // properties - set One
 Hashtable<String,String> env = new Hashtable<String,String> ();
 envTwo.put(Context.INITIAL_CONTEXT_FACTORY,
   "com.sun.enterprise.naming.impl.SerialInitContextFactory");

 env.put(Context.URL_PKG_PREFIXES, 
   "com.sun.enterprise.naming");

 env.put("org.omg.CORBA.ORBInitialPort",
   "3700");

 env.put("org.omg.CORBA.ORBInitialHost",
   "localHost");

 ctx = new InitialContext(env);
 factory = (ConnectionFactory) ctx.lookup("jms/goConnectionFactory");

控制台输出

Properties:
    key: org.omg.CORBA.ORBInitialPort   
    value: 3700
    key: java.naming.factory.initial    
    value: com.sun.enterprise.naming.impl.SerialInitContextFactory
    key: org.omg.CORBA.ORBInitialHost   
    value: localHost
    key: java.naming.factory.url.pkgs   
    value: com.sun.enterprise.naming

InitialContext returned: javax.naming.InitialContext@59494225

 calling ctx.lookup()

The following was written to the .err stream.  All else to .out stream by my program)
-------------------------------------------------------------
java.lang.NullPointerException
    at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:347)
    at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:354)
    at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:384)
    at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:329)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:477)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at org.america3.testclasses.OracleForumTestClass.main(OracleForumTestClass.java:59)
-------------------------------------------------------------
  CAUGHT EXCEPTION: javax.naming.NamingException
  MESSAGE       : Lookup failed for 'jms/goConnectionFactory' in SerialContext[myEnv={org.omg.CORBA.ORBInitial
Port=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, org.omg.CORBA.
ORBInitialHost=localHost, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImp
l, java.naming.factory.url.pkgs=com.sun.enterprise.naming}

  CAUSE         : javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEn
v={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitCon
textFactory, org.omg.CORBA.ORBInitialHost=localHost, java.naming.factory.state=com.sun.corba.ee.impl.presentat
ion.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is java.
lang.NullPointerException]

  STACK TRACE   : 
com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
javax.naming.InitialContext.lookup(Unknown Source)
org.america3.testclasses.OracleForumTestClass.main(OracleForumTestClass.java:59)

1 个答案:

答案 0 :(得分:1)

我开始知道glassfish 4.1有这个错误,本地客户端无法连接到部署在服务器上的MDB。我尝试了两个ejb项目,它运行得很好。