-
1. Re: How Can I get a ConnectionFactory using JMS with JBoss?
sportsbaby1980 Feb 19, 2004 9:42 PM (in response to sportsbaby1980)My code is below:
try {
java.util.Hashtable JNDIParm = new java.util.Hashtable();
JNDIParm.put(Context.PROVIDER_URL, "localhost");
JNDIParm.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
jndiContext = new InitialContext(JNDIParm);
} catch (NamingException e) {
System.out.println("Could not create JNDI API " +
"context: " + e.toString());
System.exit(1);
}
try {
queueConnectionFactory = (QueueConnectionFactory)
jndiContext.lookup("JBossMQProvider");
queue = (Queue) jndiContext.lookup(queueName);
} catch (NamingException e) {
System.out.println("JNDI API lookup failed: " +
e.toString());
System.exit(1);
} -
2. Re: How Can I get a ConnectionFactory using JMS with JBoss?
sportsbaby1980 Feb 19, 2004 10:19 PM (in response to sportsbaby1980)JBossMQProvider
when my program run, it throws an exception,
JNDI API lookup failed: javax.naming.NameNotFoundException: JBossMQProvider not bound
who can Help?
thank you -
3. Re: How Can I get a ConnectionFactory using JMS with JBoss?
adrian.brock Feb 20, 2004 12:19 AM (in response to sportsbaby1980)lookup UIL2ConnectionFactory
Regards,
Adrian -
4. Re: How Can I get a ConnectionFactory using JMS with JBoss?
sportsbaby1980 Feb 20, 2004 3:37 AM (in response to sportsbaby1980)the result of look UIL2ConnectionFactory is
JNDI API lookup failed: javax.naming.NameNotFoundException: UIL2ConnectionFactory not bound.
Maybe I think the JNDI name is in a file?
but I can't fiind it. -
5. Re: How Can I get a ConnectionFactory using JMS with JBoss?
adrian.brock Feb 20, 2004 3:45 AM (in response to sportsbaby1980)Which version of JBoss are you using?
Have you tried the getting started docs?
Try lookup "ConnectionFactory", if that doesn't work, you aren't connecting to jboss's jndi
Regards,
Adrian -
6. Re: How Can I get a ConnectionFactory using JMS with JBoss?
sportsbaby1980 Feb 22, 2004 8:05 PM (in response to sportsbaby1980)to Adrian:
I run my program while JBoss is running.
but it still does not work.
Follow is JNDIContext:
java.util.Hashtable JNDIParm = new java.util.Hashtable();
JNDIParm.put(Context.PROVIDER_URL, "localhost");
JNDIParm.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
jndiContext = new InitialContext(JNDIParm);
when I use it to look up EntityBean,it runs well. -
7. Re: How Can I get a ConnectionFactory using JMS with JBoss?
sportsbaby1980 Feb 22, 2004 8:10 PM (in response to sportsbaby1980)package simple;
import javax.jms.*;
import javax.naming.*;
public class SimpleQueueReceiver {
public static void main(String[] args) {
String queueName = "A";
Context jndiContext = null;
QueueConnectionFactory queueConnectionFactory = null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueReceiver queueReceiver = null;
TextMessage message = null;
System.out.println("Queue name is " + queueName);
try {
// jndiContext = new InitialContext();
java.util.Hashtable JNDIParm = new java.util.Hashtable();
JNDIParm.put(Context.PROVIDER_URL, "localhost");
JNDIParm.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
jndiContext = new InitialContext(JNDIParm);
queueConnectionFactory = (QueueConnectionFactory)
jndiContext.lookup("ConnectionFactory ");
queue = (Queue) jndiContext.lookup(queueName);
queueConnection =
queueConnectionFactory.createQueueConnection();
queueSession =
queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
queueReceiver = queueSession.createReceiver(queue);
queueConnection.start();
while (true) {
Message m = queueReceiver.receive(1);
if (m != null) {
if (m instanceof TextMessage) {
message = (TextMessage) m;
System.out.println("Reading message: " +
message.getText());
} else {
break;
}
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (queueConnection != null) {
try {
queueConnection.close();
} catch (JMSException e) {}
}
}
}
} -
8. Re: How Can I get a ConnectionFactory using JMS with JBoss?
sportsbaby1980 Feb 22, 2004 8:13 PM (in response to sportsbaby1980)Up is my JMS reciever. I known there is a default Queue named "A".But How can I get ConnectionFactory?Is there a JNDI name I can use and what is it?
-
9. 3739954
sportsbaby1980 Feb 22, 2004 8:18 PM (in response to sportsbaby1980)Queue name is A
javax.naming.NameNotFoundException: ConnectionFactory not bound
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at simple.SimpleQueueReceiver.main(SimpleQueueReceiver.java:69)
This is the error message when it runs. -
10. Re: How Can I get a ConnectionFactory using JMS with JBoss?
sportsbaby1980 Feb 22, 2004 9:17 PM (in response to sportsbaby1980)Thank you,everyone.
The problem has resovled. -
11. Re: How Can I get a ConnectionFactory using JMS with JBoss?
jamlu Feb 23, 2004 10:11 PM (in response to sportsbaby1980)hi:
I am an Chinese boy!
Can you share your experiences with me? thanks a lot!
My MSN:javailoveyou@hotmail.com.