You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by lekkie <le...@gmail.com> on 2009/07/31 18:19:21 UTC

NameNotFoundException for Queue (ServiceMIX/JMS)

I was trying to access a JMS consumer service exposed on Servicemix and its
throwing the follwoing exception:

javax.naming.NameNotFoundException: queue/A/Soap
	at
org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:215)
	at javax.naming.InitialContext.lookup(InitialContext.java:351)
	at
testDriver.WebServiceTestDriver.sendBinaryFileJMS(WebServiceTestDriver.java:89)
	at testDriver.WebServiceTestDriver.main(WebServiceTestDriver.java:71)


Here is my client code (running from eclipse): 

String fileName = "C:\\binaryfile.html";
byte[] payload = getBytesFromFile(fileName);
String dest = "queue/A/Soap";
Properties env = new Properties();
        if (System.getProperty("java.naming.provider.url") == null) {
            env.put("java.naming.provider.url", "tcp://localhost:61616");
        }
        if (System.getProperty("java.naming.factory.initial") == null) {        	
            env.put("java.naming.factory.initial",
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
        }
InitialContext ic = new InitialContext(env);	
ConnectionFactory confac = (ConnectionFactory)
ic.lookup("ConnectionFactory");
Connection connection = confac.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer((Destination)
ic.lookup(dest));
BytesMessage bm = session.createBytesMessage();
bm.writeBytes(payload);
producer.send(bm);
connection.close();


and here is my xbean.xml on servicemix which imho look good:

<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
          xmlns:is="http://services.is"
          xmlns:amqpool="http://jencks.org/amqpool/2.0">
        
    <bean id="connectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
    	     
    	     <property name="connectionFactory">
         	    <bean class="org.apache.activemq.ActiveMQConnectionFactory">
         	   	 <property name="brokerURL" value="tcp://localhost:61616" />
         	    </bean>
             </property>
         	
             <!--Configure maximum connections used by the pool -->
             <property name="maxConnections" value="10" />
             
             <!--Configure maximum sessions per connection -->
             <property name="maximumActive" value="10" />
   </bean> 

    <jms:endpoint service="is:isJMSFileConsumer"
                          endpoint="isJMSFileConsumer"
                          targetService="is:isFTPWriter"
                          targetEndpoint="isFTPWriter"                          
                          role="consumer" 
                          destinationStyle="queue"
                          jmsProviderDestinationName="queue/A/Soap"
                          connectionFactory="#connectionFactory"
                          soap="true"
                      	 
defaultMep="http://www.w3.org/2004/08/wsdl/robust-in-only"/>       
</beans>

-- 
View this message in context: http://www.nabble.com/NameNotFoundException-for-Queue-%28ServiceMIX-JMS%29-tp24759155p24759155.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: NameNotFoundException for Queue (ServiceMIX/JMS)

Posted by Gert Vanthienen <ge...@gmail.com>.
L.S.,

If the goal is just to send a message from a client, you can also just
use the plain JMS API starting from the ActiveMQConnectionFactory.
There's no real benefit in using JNDI here, I guess...

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/7/31 lekkie <le...@gmail.com>:
>
> I was trying to access a JMS consumer service exposed on Servicemix and its
> throwing the follwoing exception:
>
> javax.naming.NameNotFoundException: queue/A/Soap
>        at
> org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:215)
>        at javax.naming.InitialContext.lookup(InitialContext.java:351)
>        at
> testDriver.WebServiceTestDriver.sendBinaryFileJMS(WebServiceTestDriver.java:89)
>        at testDriver.WebServiceTestDriver.main(WebServiceTestDriver.java:71)
>
>
> Here is my client code (running from eclipse):
>
> String fileName = "C:\\binaryfile.html";
> byte[] payload = getBytesFromFile(fileName);
> String dest = "queue/A/Soap";
> Properties env = new Properties();
>        if (System.getProperty("java.naming.provider.url") == null) {
>            env.put("java.naming.provider.url", "tcp://localhost:61616");
>        }
>        if (System.getProperty("java.naming.factory.initial") == null) {
>            env.put("java.naming.factory.initial",
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
>        }
> InitialContext ic = new InitialContext(env);
> ConnectionFactory confac = (ConnectionFactory)
> ic.lookup("ConnectionFactory");
> Connection connection = confac.createConnection();
> Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> MessageProducer producer = session.createProducer((Destination)
> ic.lookup(dest));
> BytesMessage bm = session.createBytesMessage();
> bm.writeBytes(payload);
> producer.send(bm);
> connection.close();
>
>
> and here is my xbean.xml on servicemix which imho look good:
>
> <beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
>          xmlns:is="http://services.is"
>          xmlns:amqpool="http://jencks.org/amqpool/2.0">
>
>    <bean id="connectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory">
>
>             <property name="connectionFactory">
>                    <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>                         <property name="brokerURL" value="tcp://localhost:61616" />
>                    </bean>
>             </property>
>
>             <!--Configure maximum connections used by the pool -->
>             <property name="maxConnections" value="10" />
>
>             <!--Configure maximum sessions per connection -->
>             <property name="maximumActive" value="10" />
>   </bean>
>
>    <jms:endpoint service="is:isJMSFileConsumer"
>                          endpoint="isJMSFileConsumer"
>                          targetService="is:isFTPWriter"
>                          targetEndpoint="isFTPWriter"
>                          role="consumer"
>                          destinationStyle="queue"
>                          jmsProviderDestinationName="queue/A/Soap"
>                          connectionFactory="#connectionFactory"
>                          soap="true"
>
> defaultMep="http://www.w3.org/2004/08/wsdl/robust-in-only"/>
> </beans>
>
> --
> View this message in context: http://www.nabble.com/NameNotFoundException-for-Queue-%28ServiceMIX-JMS%29-tp24759155p24759155.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>

Re: NameNotFoundException for Queue (ServiceMIX/JMS)

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

It's the JNDI lookup that fails. The servicemix-jms component calls 
session.createQueue(). To register the queue in the  ActiveMQ JNDI tree, 
we need to create an instance of ActiveMQQueue and registering it. I 
don't remember if it's the case in the servicemix-jms component. Let me 
check.

Did you try using the new jms endpoints (using <jms:soap-consumer/>) ?

Regards
JB

lekkie wrote:
> I was trying to access a JMS consumer service exposed on Servicemix and its
> throwing the follwoing exception:
> 
> javax.naming.NameNotFoundException: queue/A/Soap
> 	at
> org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:215)
> 	at javax.naming.InitialContext.lookup(InitialContext.java:351)
> 	at
> testDriver.WebServiceTestDriver.sendBinaryFileJMS(WebServiceTestDriver.java:89)
> 	at testDriver.WebServiceTestDriver.main(WebServiceTestDriver.java:71)
> 
> 
> Here is my client code (running from eclipse): 
> 
> String fileName = "C:\\binaryfile.html";
> byte[] payload = getBytesFromFile(fileName);
> String dest = "queue/A/Soap";
> Properties env = new Properties();
>         if (System.getProperty("java.naming.provider.url") == null) {
>             env.put("java.naming.provider.url", "tcp://localhost:61616");
>         }
>         if (System.getProperty("java.naming.factory.initial") == null) {        	
>             env.put("java.naming.factory.initial",
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
>         }
> InitialContext ic = new InitialContext(env);	
> ConnectionFactory confac = (ConnectionFactory)
> ic.lookup("ConnectionFactory");
> Connection connection = confac.createConnection();
> Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> MessageProducer producer = session.createProducer((Destination)
> ic.lookup(dest));
> BytesMessage bm = session.createBytesMessage();
> bm.writeBytes(payload);
> producer.send(bm);
> connection.close();
> 
> 
> and here is my xbean.xml on servicemix which imho look good:
> 
> <beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
>           xmlns:is="http://services.is"
>           xmlns:amqpool="http://jencks.org/amqpool/2.0">
>         
>     <bean id="connectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory">
>     	     
>     	     <property name="connectionFactory">
>          	    <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>          	   	 <property name="brokerURL" value="tcp://localhost:61616" />
>          	    </bean>
>              </property>
>          	
>              <!--Configure maximum connections used by the pool -->
>              <property name="maxConnections" value="10" />
>              
>              <!--Configure maximum sessions per connection -->
>              <property name="maximumActive" value="10" />
>    </bean> 
> 
>     <jms:endpoint service="is:isJMSFileConsumer"
>                           endpoint="isJMSFileConsumer"
>                           targetService="is:isFTPWriter"
>                           targetEndpoint="isFTPWriter"                          
>                           role="consumer" 
>                           destinationStyle="queue"
>                           jmsProviderDestinationName="queue/A/Soap"
>                           connectionFactory="#connectionFactory"
>                           soap="true"
>                       	 
> defaultMep="http://www.w3.org/2004/08/wsdl/robust-in-only"/>       
> </beans>
> 

-- 
Jean-Baptiste Onofré
---------------------------------
  HomePage
http://www.nanthrax.net
---------------------------------
  Contacts
jbonofre@apache.org
jb@nanthrax.net
---------------------------------
  OpenSource
BuildProcess/AutoDeploy
http://buildprocess.sourceforge.net
Apache ServiceMix
http://servicemix.apache.org
-----------------------------------
PGP : 17D4F086

Re: NameNotFoundException for Queue (ServiceMIX/JMS)

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Lekkie,

I checked in the code, you need to define the jndiDestinationName. The 
jmsProviderDestinationName is used only is destination and 
jndiDestinationName are null.

If you want to register the queue into the JNDI tree you need to use the 
jndiDestinationName property.

It should work.

Regards
JB

lekkie wrote:
> I was trying to access a JMS consumer service exposed on Servicemix and its
> throwing the follwoing exception:
> 
> javax.naming.NameNotFoundException: queue/A/Soap
> 	at
> org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:215)
> 	at javax.naming.InitialContext.lookup(InitialContext.java:351)
> 	at
> testDriver.WebServiceTestDriver.sendBinaryFileJMS(WebServiceTestDriver.java:89)
> 	at testDriver.WebServiceTestDriver.main(WebServiceTestDriver.java:71)
> 
> 
> Here is my client code (running from eclipse): 
> 
> String fileName = "C:\\binaryfile.html";
> byte[] payload = getBytesFromFile(fileName);
> String dest = "queue/A/Soap";
> Properties env = new Properties();
>         if (System.getProperty("java.naming.provider.url") == null) {
>             env.put("java.naming.provider.url", "tcp://localhost:61616");
>         }
>         if (System.getProperty("java.naming.factory.initial") == null) {        	
>             env.put("java.naming.factory.initial",
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
>         }
> InitialContext ic = new InitialContext(env);	
> ConnectionFactory confac = (ConnectionFactory)
> ic.lookup("ConnectionFactory");
> Connection connection = confac.createConnection();
> Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> MessageProducer producer = session.createProducer((Destination)
> ic.lookup(dest));
> BytesMessage bm = session.createBytesMessage();
> bm.writeBytes(payload);
> producer.send(bm);
> connection.close();
> 
> 
> and here is my xbean.xml on servicemix which imho look good:
> 
> <beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
>           xmlns:is="http://services.is"
>           xmlns:amqpool="http://jencks.org/amqpool/2.0">
>         
>     <bean id="connectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory">
>     	     
>     	     <property name="connectionFactory">
>          	    <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>          	   	 <property name="brokerURL" value="tcp://localhost:61616" />
>          	    </bean>
>              </property>
>          	
>              <!--Configure maximum connections used by the pool -->
>              <property name="maxConnections" value="10" />
>              
>              <!--Configure maximum sessions per connection -->
>              <property name="maximumActive" value="10" />
>    </bean> 
> 
>     <jms:endpoint service="is:isJMSFileConsumer"
>                           endpoint="isJMSFileConsumer"
>                           targetService="is:isFTPWriter"
>                           targetEndpoint="isFTPWriter"                          
>                           role="consumer" 
>                           destinationStyle="queue"
>                           jmsProviderDestinationName="queue/A/Soap"
>                           connectionFactory="#connectionFactory"
>                           soap="true"
>                       	 
> defaultMep="http://www.w3.org/2004/08/wsdl/robust-in-only"/>       
> </beans>
> 

-- 
Jean-Baptiste Onofré
---------------------------------
  HomePage
http://www.nanthrax.net
---------------------------------
  Contacts
jbonofre@apache.org
jb@nanthrax.net
---------------------------------
  OpenSource
BuildProcess/AutoDeploy
http://buildprocess.sourceforge.net
Apache ServiceMix
http://servicemix.apache.org
-----------------------------------
PGP : 17D4F086