编程语言
首页 > 编程语言> > Java-JMS-查找问题

Java-JMS-查找问题

作者:互联网

我正在使用Glassfish v3开发Java中的JMS程序.现在的事情是,我添加了一个类型为QueueConnectionFactory的ConnectionFactory,它的名称为:“ jms / KwetterFactory”.还有一个Queue类型的Destination Resource,它的名称为“ jms / KwetterQueue”.

现在,当我运行以下代码时:

public Sender() throws JMSException, NamingException
    {
        // get the initial context
       InitialContext ctx = new InitialContext();

       // lookup the queue connection factory
       QueueConnectionFactory connFactory = (QueueConnectionFactory) ctx.lookup("jms/KwetterFactory");

       // lookup the queue object
       Queue queue = (Queue) ctx.lookup("jms/KwetterQueue");

       // create a queue connection
       QueueConnection queueConn = connFactory.createQueueConnection();

       // create a queue session
       QueueSession queueSession = queueConn.createQueueSession(false,
           Session.DUPS_OK_ACKNOWLEDGE);

       // create a queue sender
       QueueSender queueSender = queueSession.createSender(queue);
       queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

       // create a simple message to say "Hello"
       TextMessage message = queueSession.createTextMessage("Hello");

       // send the message
       queueSender.send(message);

       // print what we did
       System.out.println("sent: " + message.getText());

       // close the queue connection
       queueConn.close();
    }

我收到此错误:

java.lang.RuntimeException: Orb initialization erorr
        at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:148)
        at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:365)
        at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:372)
        at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:402)
        at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:347)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at Sender.Sender.(Sender.java:32)
        at GUI.GUI.jButton1ActionPerformed(GUI.java:73)
        at GUI.GUI.access$000(GUI.java:24)
        at GUI.GUI$1.actionPerformed(GUI.java:47)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
        at java.awt.Component.processMouseEvent(Component.java:6263)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:6028)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4630)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
        at java.awt.Container.dispatchEventImpl(Container.java:2085)
        at java.awt.Window.dispatchEventImpl(Window.java:2478)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) Caused by: java.lang.NullPointerException
        at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:120)
        ... 36 more May 23, 2011 2:09:10 PM GUI.GUI jButton1ActionPerformed SEVERE: null javax.naming.NamingException: Lookup failed for 'jms/KwetterFactory' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is java.lang.RuntimeException: Orb initialization erorr]]
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at Sender.Sender.(Sender.java:32)
        at GUI.GUI.jButton1ActionPerformed(GUI.java:73)
        at GUI.GUI.access$000(GUI.java:24)
        at GUI.GUI$1.actionPerformed(GUI.java:47)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
        at java.awt.Component.processMouseEvent(Component.java:6263)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:6028)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4630)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
        at java.awt.Container.dispatchEventImpl(Container.java:2085)
        at java.awt.Window.dispatchEventImpl(Window.java:2478)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is java.lang.RuntimeException: Orb initialization erorr]
        at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:352)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
        ... 31 more Caused by: java.lang.RuntimeException: Orb initialization erorr
        at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:148)
        at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:365)
        at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:372)
        at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:402)
        at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:347)
        ... 32 more Caused by: java.lang.NullPointerException
        at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:120)
        ... 36 more BUILD SUCCESSFUL (total time: 9 seconds)

谁知道导致此问题的原因?

解决方法:

尝试看看
http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB
“如何从独立的Java客户端访问远程EJB组件?”

您需要在其中查看多个项目.祝好运.

标签:lookup,jms,glassfish,java
来源: https://codeday.me/bug/20191208/2091020.html