Hello,
I have the following piece of code (bean):
public class JmsWriterBean implements MessageExchangeListener {
@Resource
private DeliveryChannel channel;
public void onMessageExchange(MessageExchange exchange) throws
MessagingException {
System.out.println("Message to send to JMS queue: " + exchange);
// Convert MessageExchange into suitable data
String value = null;
NormalizedMessage theMessage = exchange.getMessage("in");
System.out.println("NormalizedMessage: " + theMessage);
Source theSource = theMessage.getContent();
System.out.println("Source: " + theSource);
DOMSource xmlSource = (DOMSource) theSource;
Object[] records = new Object[1];
records[0] = theSource;
try {
// Create a JNDI API Context object if none exists yet.
System.out.println("JNDI connection ...");
org.openadaptor.auxil.connector.jndi.JNDIConnection
jndiConnection = new
org.openadaptor.auxil.connector.jndi.JNDIConnection();
jndiConnection
.setProviderUrl("jnp://girardin8000.emea.hpqcorp.net:1099");
jndiConnection
.setInitialContextFactory("org.jnp.interfaces.NamingContextFactory");
javax.naming.directory.DirContext context = jndiConnection
.connect();
System.out.println("OK");
// Look up connection factory and destination. If either does
not exist,
// exit. If you look up a TopicConnectionFactory instead of a
// QueueConnectionFactory, program behavior is the same.
System.out.println("JMS connection ...");
org.openadaptor.auxil.connector.jms.JMSConnection jmsConnection
= new
JMSConnection();
jmsConnection.setJndiConnection(jndiConnection);
jmsConnection.setConnectionFactoryName("ConnectionFactory");
List exceptions = null;
jmsConnection.validate(exceptions);
System.out.println("OK");
// JMSWriter to create
System.out.println("JMSWriter creation ...");
org.openadaptor.auxil.connector.jms.JMSWriteConnector writer =
new
org.openadaptor.auxil.connector.jms.JMSWriteConnector();
writer.setDestinationName("queue/testQueue");
writer.setJmsConnection(jmsConnection);
writer.setTransacted(true);
writer.validate(exceptions);
System.out.println("OK");
System.out.println("JMSWriter connection ...");
writer.connect();
System.out.println("OK");
// Send the message on the JMS queue
writer.deliver(records);
System.out.println("JMSWriter sends message OK");
writer.disconnect();
} catch (javax.naming.NamingException e) {
System.out.println("javax.naming exception: " + e);
} catch (org.openadaptor.core.exception.ConnectionException e2)
{
System.out.println("openadaptor exception: " + e2);
}
// exchange.setStatus(ExchangeStatus.DONE);
// channel.send(exchange);
}
}
Running ServiceMix, i got the following error:
org.openadaptor.core.exception.ConnectionException: null : NamingException
during connect.
at
org.openadaptor.auxil.connector.jms.JMSConnection.createConnection(JMSConnection.java:212)
at
org.openadaptor.auxil.connector.jms.JMSConnection.createSessionFor(JMSConnection.java:166)
at
org.openadaptor.auxil.connector.jms.JMSWriteConnector.connect(JMSWriteConnector.java:156)
at
org.apache.servicemix.bean.beans.JmsWriterBean.onMessageExchange(JmsWriterBean.java:69)
at
org.apache.servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoint.java:225)
at
org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:201)
at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:489)
at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:441)
at
org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:595)
at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:174)
at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:176)
at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
at java.lang.Thread.run(Thread.java:595)
Caused by: javax.naming.CommunicationException [Root exception is
java.rmi.ServerException: RemoteException occurred in s
d exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested
exception is:
java.net.MalformedURLException: no protocol:
Applications/apache-servicemix-3.1.1-incubating/bin/../conf/]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:722)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at
org.openadaptor.auxil.connector.jms.JMSConnection.lookup(JMSConnection.java:260)
at
org.openadaptor.auxil.connector.jms.JMSConnection.doCreateConnection(JMSConnection.java:225)
at
org.openadaptor.auxil.connector.jms.JMSConnection.createConnection(JMSConnection.java:201)
... 15 more
Caused by: java.rmi.ServerException: RemoteException occurred in server
thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested
exception is:
java.net.MalformedURLException: no protocol:
Applications/apache-servicemix-3.1.1-incubating/bin/../conf/
at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:325)
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)
... 20 more
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments;
nested exception is:
java.net.MalformedURLException: no protocol:
Applications/apache-servicemix-3.1.1-incubating/bin/../conf/
at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:282)
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)
... 1 more
Caused by: java.net.MalformedURLException: no protocol:
Applications/apache-servicemix-3.1.1-incubating/bin/../conf/
at java.net.URL.<init>(URL.java:567)
at java.net.URL.<init>(URL.java:464)
at java.net.URL.<init>(URL.java:413)
at sun.rmi.server.LoaderHandler.pathToURLs(LoaderHandler.java:747)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:147)
at
java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
at
org.jboss.system.JBossRMIClassLoader.loadClass(JBossRMIClassLoader.java:91)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
at
sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
at
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
at
java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at javax.naming.CompoundName.readObject(CompoundName.java:554)
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
java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:946)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1809)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:290)
at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:279)
i run my servicemix on same machine as the JBoss (JMS queue).
It seems that ServiceMix jndi config (conf/jndi.xml) is used instead of what
i specified in my code ?
Any idea about the JNDI conf in order my ServiceMix can post data in my JMS
queue (JBoss)
Rgds,
Christophe.
--
View this message in context:
http://www.nabble.com/JNDI-Error-in-JMSWriter-bean-tf4376539s12049.html#a12474756
Sent from the ServiceMix - Dev mailing list archive at Nabble.com.