activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From webber <tokomakoma...@gmail.com>
Subject using jndi caused error
Date Sun, 14 Apr 2013 20:56:10 GMT
Hello,

I am testing activemq producer code using jndi.

Running my code caused the following exception.

javax.jms.JMSException: Could not create Transport. Reason:
java.io.IOException: Transport scheme NOT recognized: [jnp]
	at
org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)
	at
org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:252)
	at
org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:265)
	at
org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:238)
	at
org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:184)
	at Producer.<init>(Producer.java:15)
	at Producer.main(Producer.java:31)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:283)
	at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.IOException: Transport scheme NOT recognized: [jnp]
	at
org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)
	at
org.apache.activemq.transport.TransportFactory.findTransportFactory(TransportFactory.java:178)
	at
org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java:63)
	at
org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:250)
	... 11 more
Caused by: java.io.IOException: Could not find factory class for resource:
META-INF/services/org/apache/activemq/transport/jnp
	at
org.apache.activemq.util.FactoryFinder$StandaloneObjectFactory.loadProperties(FactoryFinder.java:96)
	at
org.apache.activemq.util.FactoryFinder$StandaloneObjectFactory.create(FactoryFinder.java:58)
	at
org.apache.activemq.util.FactoryFinder.newInstance(FactoryFinder.java:146)
	at
org.apache.activemq.transport.TransportFactory.findTransportFactory(TransportFactory.java:175)

My code is as follows:

import javax.jms.*;
import javax.naming.InitialContext;
import javax.naming.NamingException;


public class Producer {

    public Producer() throws JMSException, NamingException {
	Connection connection=null;
	try {
	    InitialContext jndi = new InitialContext();

	    ConnectionFactory conFactory = (ConnectionFactory)
jndi.lookup("ConnectionFactory");
	    Destination destination = (Destination) jndi.lookup("MyQueue");
	    connection = conFactory.createConnection();
	    connection.start();
	    Session session =
connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
	    MessageProducer producer = session.createProducer(destination);
	    TextMessage message = session.createTextMessage("Hello World!");
	    producer.send(message);
	    System.out.println("Sent message '" + message.getText() + "'");
	} catch(Exception e) {
	    e.printStackTrace();
	} finally {
	    connection.close();
	}
    }

    public static void main(String[] args) throws JMSException {
	try {
	    new Producer();
	} catch (NamingException e) {
	    e.printStackTrace();
	}

    }
}

jndi.properties as follows:

java.naming.factory.initial =
org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url = tcp://localhost:61616 
connectionFactoryNames = ConnectionFactory, queueConnectionFactory,
topicConnectionFactry
queue.MyQueue = queue.queue_out

What is a problem in my code ?

Regards,







--
View this message in context: http://activemq.2283324.n4.nabble.com/using-jndi-caused-error-tp4665919.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message