java - How to resolve exception in thread “main” javax.naming.NameNotFoundException: not bound? -



java - How to resolve exception in thread “main” javax.naming.NameNotFoundException: not bound? -

i'm trying create jms publisher/subscriber chat application in eclipse.

import java.util.properties; import javax.jms.jmsexception; import javax.jms.message; import javax.jms.messagelistener; import javax.jms.textmessage; import javax.jms.topic; import javax.jms.topicconnection; import javax.jms.topicconnectionfactory; import javax.jms.topicsession; import javax.naming.context; import javax.naming.initialcontext; import javax.naming.namingexception; public class topicconsumer implements messagelistener { public static void main(string[] args) throws jmsexception, namingexception { system.out.println(".....entering jms illustration topicconsumer...."); context context = topicconsumer.getinitialcontext(); topicconnectionfactory topicconnectionfactory = (topicconnectionfactory) context.lookup("connectionfactory"); topic topic = (topic) context.lookup("topic/zaneacademy_jms_tutorial_01"); topicconnection topicconnection = topicconnectionfactory.createtopicconnection(); topicsession topicsession = topicconnection.createtopicsession(false, topicsession.auto_acknowledge); topicsession.createsubscriber(topic).setmessagelistener(new topicconsumer()); topicconnection.start(); system.out.println("......exiting jms illustration topicconsumer....."); } public void onmessage(message message) { seek { system.out.println("incoming messages: " + ((textmessage)message).gettext()); } grab (jmsexception e) { e.printstacktrace(); } } public static context getinitialcontext() throws jmsexception, namingexception { properties props = new properties(); props.setproperty("java.naming.factory.initial", "org.jnp.interfaces.namingcontextfactory"); props.setproperty("java.naming.factory.url.pkgs", "org.jboss.naming"); props.setproperty("java.naming.provider.url", "localhost:1099"); context context = new initialcontext(props); homecoming context; } }

trying run programme i'm getting next errors in console

.....entering jms illustration topicconsumer.... exception in thread "main" javax.naming.namenotfoundexception: zaneacademy_jms_tutorial_01 not bound @ org.jnp.server.namingserver.getbinding(namingserver.java:564) @ org.jnp.server.namingserver.getbinding(namingserver.java:572) @ org.jnp.server.namingserver.getobject(namingserver.java:578) @ org.jnp.server.namingserver.lookup(namingserver.java:317) @ org.jnp.server.namingserver.lookup(namingserver.java:291) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ sun.rmi.server.unicastserverref.dispatch(unknown source) @ sun.rmi.transport.transport$1.run(unknown source) @ sun.rmi.transport.transport$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ sun.rmi.transport.transport.servicecall(unknown source) @ sun.rmi.transport.tcp.tcptransport.handlemessages(unknown source) @ sun.rmi.transport.tcp.tcptransport$connectionhandler.run0(unknown source) @ sun.rmi.transport.tcp.tcptransport$connectionhandler.run(unknown source) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) @ sun.rmi.transport.streamremotecall.exceptionreceivedfromserver(unknown source) @ sun.rmi.transport.streamremotecall.executecall(unknown source) @ sun.rmi.server.unicastref.invoke(unknown source) @ java.rmi.server.remoteobjectinvocationhandler.invokeremotemethod(unknown source) @ java.rmi.server.remoteobjectinvocationhandler.invoke(unknown source) @ com.sun.proxy.$proxy0.lookup(unknown source) @ org.jnp.interfaces.namingcontext.lookup(namingcontext.java:669) @ org.jnp.interfaces.namingcontext.lookup(namingcontext.java:629) @ javax.naming.initialcontext.lookup(unknown source) @ topicconsumer.main(topicconsumer.java:19)

as says in exception zaneacademy_jms_tutorial_01 not defined. need configure , assigne topic/zaneacademy_jms_tutorial_01.

i say, problem getinitialcontext() configure mannaully, instead of returing configured context new initialcontext();

java jboss5.x jms-topic

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -