Hi,
I'm new to JBoss and am trying to setup sample code to use the JBoss messaging
service.
I'm trying to use the included TopicSendRecvClient.java test class to access
the following default JNDI objects to send/receive JMS Text messages.
TopicConnectionFactory
topic/testTopic
Problem:
In Setup 1 (Local Workstation Environment listed below), I can retrieve and use
the objects normally.
In Setup 2, I have installed the same version server on a remote linux server.
My problem is that when I try to retrieve the same objects through JNDI, I have
an exception saying that the objects are not bound. This doesn't seem to be
the case though since I can see the objects through the JMXConsole
JNDIView.list() method on the same remote Linux server.
JMXConsole JNDIView.list(): On Remote Linux Server
Global JNDI Namespace
+- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
+- UIL2ConnectionFactory[link -> ConnectionFactory] (class:
javax.naming.LinkRef)
+- UserTransactionSessionFactory (proxy: $Proxy12 implements interface
org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
+- console (class: org.jnp.interfaces.NamingContext)
| +- PluginManager (proxy: $Proxy43 implements interface
org.jboss.console.manager.PluginManagerMBean)
+- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class:
javax.naming.LinkRef)
+- UUIDKeyGeneratorFactory (class:
org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
+- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
+- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
+- jmx (class: org.jnp.interfaces.NamingContext)
| +- invoker (class: org.jnp.interfaces.NamingContext)
| | +- RMIAdaptor (proxy: $Proxy42 implements interface
org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface
org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
| +- rmi (class: org.jnp.interfaces.NamingContext)
| | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class:
javax.naming.LinkRef)
+- UILXAConnectionFactory[link -> XAConnectionFactory] (class:
javax.naming.LinkRef)
+- UILConnectionFactory[link -> ConnectionFactory] (class:
javax.naming.LinkRef)
Client Exception:
javax.naming.NameNotFoundException: ConnectionFactory not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at
org.jboss.naming.LinkRefPairObjectFactory.getObjectInstance(LinkRefPairObjectFactory.java:85)
at
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at
org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
at
org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at TopicSendRecvClient.setupPubSub(TopicSendRecvClient.java:49)
at TopicSendRecvClient.sendRecvAsync(TopicSendRecvClient.java:71)
at TopicSendRecvClient.main(TopicSendRecvClient.java:94)
Exception in thread "main" javax.naming.NameNotFoundException:
ConnectionFactory not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at
org.jboss.naming.LinkRefPairObjectFactory.getObjectInstance(LinkRefPairObjectFactory.java:85)
at
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at
org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
at
org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at TopicSendRecvClient.setupPubSub(TopicSendRecvClient.java:49)
at TopicSendRecvClient.sendRecvAsync(TopicSendRecvClient.java:71)
at TopicSendRecvClient.main(TopicSendRecvClient.java:94)
Client Code:
import java.io.IOException;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.Topic;
import javax.jms.TopicConnection;
import javax.jms.TopicConnectionFactory;
import javax.jms.TopicPublisher;
import javax.jms.TopicSubscriber;
import javax.jms.TopicSession;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import EDU.oswego.cs.dl.util.concurrent.CountDown;
/**
* A complete JMS client example program that sends a TextMessage to a Topic and
* asynchronously receives the message from the same Topic.
*
* @author [EMAIL PROTECTED]
* @version $Revision: 1.10 $
*/
public class TopicSendRecvClient {
static CountDown done = new CountDown(1);
TopicConnection conn = null;
TopicSession session = null;
Topic topic = null;
public static class ExListener implements MessageListener {
public void onMessage(Message msg) {
done.release();
TextMessage tm = (TextMessage) msg;
try {
System.out.println("onMessage, recv text=" +
tm.getText());
} catch (Throwable t) {
t.printStackTrace();
}
}
}
public void setupPubSub() throws JMSException, NamingException,
IOException {
try{
InitialContext iniCtx = new InitialContext();
Object tmp = iniCtx.lookup("TopicConnectionFactory");
TopicConnectionFactory tcf = (TopicConnectionFactory)
tmp;
conn = tcf.createTopicConnection();
topic = (Topic) iniCtx.lookup("topic/testTopic");
session = conn.createTopicSession(false,
TopicSession.AUTO_ACKNOWLEDGE);
conn.start();
}
catch(NamingException e){
e.printStackTrace();
throw e;
}
catch(JMSException e){
e.printStackTrace();
throw e;
}
}
public void sendRecvAsync(String text) throws JMSException,
NamingException, IOException {
System.out.println("Begin sendRecvAsync");
// Setup the PubSub connection, session
setupPubSub();
// Set the async listener
TopicSubscriber recv = session.createSubscriber(topic);
recv.setMessageListener(new ExListener());
// Send a text msg
TopicPublisher send = session.createPublisher(topic);
TextMessage tm = session.createTextMessage(text);
send.publish(tm);
System.out.println("sendRecvAsync, sent text=" + tm.getText());
send.close();
System.out.println("End sendRecvAsync");
}
public void stop() throws JMSException {
conn.stop();
session.close();
conn.close();
}
public static void main(String args[]) throws Exception {
System.out.println("Begin TopicSendRecvClient, now="
+ System.currentTimeMillis());
TopicSendRecvClient client = new TopicSendRecvClient();
client.sendRecvAsync("A text msg, now=" +
System.currentTimeMillis());
client.done.acquire();
client.stop();
System.out.println("End TopicSendRecvClient");
System.exit(0);
}
}
Setup 1:
Environment: Windows XP Pro (Local Workstation)
JBoss: 4.0.5 Installed via jems-installer-1.2.0.GA.jar
The server here started correctly.
Setup 2:
Envrionment: Linux Server (Remote)
JBoss: 4.0.5 Installed via jboss-4.0.5.GA.zip.
The server here experienced startup errors from a fresh install. I don't know
if this is a red herring relating to my problem but I'll list them anyways.
Startup Errors:
18:52:15,974 WARN [ServiceController] Problem starting service
jboss:service=Hypersonic,database=localDB
java.sql.SQLException: The database is already in use by another process:
[EMAIL PROTECTED]
=/home/coms/jboss1/jboss-4.0.5.GA/server/default/data/hypersonic/localDB.lck,
exists=true, locked=false, valid=false, fl =null]:
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.(Unknown Source)
at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
at org.hsqldb.jdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at
org.jboss.jdbc.HypersonicDatabase.getConnection(HypersonicDatabase.java:761)
at
org.jboss.jdbc.HypersonicDatabase.startStandaloneDatabase(HypersonicDatabase.java:611)
at
org.jboss.jdbc.HypersonicDatabase.startService(HypersonicDatabase.java:557)
at
org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at
org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
...
Any help would be greatly appreciated to help me figure out why I can't connect
to my TopicConnectionFactory object via JNDI on the remote linux server.
thanks!
Don
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029546#4029546
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029546
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user