You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by martymusk <ma...@email.it> on 2008/01/03 11:16:07 UTC

Help on error

Hy,  can somebody help me please?

What means the following error?

Cannot perform operations on this component until it has been initialised
via init()

I hope you can help me.
Thanks in advance

Martina
-- 
View this message in context: http://www.nabble.com/Help-on-error-tp14594612s12049p14594612.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Help on error

Posted by martymusk <ma...@email.it>.
I've tried to do this, I've modified my class in following way:


package org.apache.servicemix.wsn;

import javax.jbi.JBIException;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.xml.transform.TransformerException;
//import javax.jbi.messaging.InOut;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.MessageExchangeListener;
import org.apache.servicemix.components.util.ComponentSupport;
import org.apache.servicemix.wsn.spring.PublisherComponent;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.servicemix.wsn.client.AbstractWSAClient;
import org.apache.servicemix.wsn.client.NotificationBroker;


public class TraceComponent extends ComponentSupport implements
		MessageExchangeListener {

	private Log log = LogFactory.getLog(TraceComponent.class);

	private SourceTransformer sourceTransformer = new SourceTransformer();

	public Log getLog() {
		return log;
	}

	public void setLog(Log log) {
		this.log = log;
	}

	public SourceTransformer getSourceTransformer() {
		return sourceTransformer;
	}

	public void setSourceTransformer(SourceTransformer sourceTransformer) {
		this.sourceTransformer = sourceTransformer;
	}
	
	
	//AGGIUNGO CODICE
		
	PublisherComponent publisher = new PublisherComponent();
	  private String subscriptionEndpoint = "subscription";
	  private NotificationBroker wsnBroker;
	  private String receiveTopic;
	  private String msg;
	  private boolean demand;
	  
	  
	  //public String getTopic() {
	  //      return receiveTopic;
	  //  }

	    /**
	     * @param topic The topic to set.
	     */
	   // public void setTopic(String topic) {
	      //  this.topic = topic;
	   // }
	  
	 public void init() throws JBIException {
	        super.init();
	        getContext().activateEndpoint(getService(), subscriptionEndpoint);
		 log.info("METODO INIT");
		// publisher.init();
		 
		 publisher.setTopic(receiveTopic);
	    }
	    
	    /* (non-Javadoc)
	     * @see javax.jbi.management.LifeCycleMBean#start()
	     */
	    public void start() throws JBIException {
	    	
	    	log.info("METODO START");
	    	//publisher.start();
	        new Thread() {
	          public void run() {
	               try {
	                   wsnBroker = new NotificationBroker(getContext());
	                  
	                   String wsaAddress = getService().getNamespaceURI() + "/"
+ getService().getLocalPart() + "/" + subscriptionEndpoint;
	                  
wsnBroker.registerPublisher(AbstractWSAClient.createWSA(wsaAddress),
	                                               receiveTopic,
	                                                demand);
	                } catch (Exception e) {
	                    log.error("Could not create wsn client", e);
	                }
	            }
	        }.start();
	    }
	    
	    
	    public void shutDown() throws JBIException {
	    	log.info("METODO SHUTDOWN");
	    //	publisher.shutDown();
	       super.shutDown();
	    }
	    
	    //FINE CODICE AGGIUNTO

	public void onMessageExchange(MessageExchange exchange)
			throws MessagingException {
		// lets dump the incoming message
		NormalizedMessage message = exchange.getMessage("in");
		if (message == null) {
			log.warn("Received null message from exchange: " + exchange);
		} else {
			log.info("Exchange: " + exchange + " received IN message: "
					+ message);
			try {
				log.info("Body is: "
						+ sourceTransformer.toString(message.getContent()));
			} catch (TransformerException e) {
				log.error("Failed to turn message body into text: " + e, e);
			}
		}
		done(exchange);
		log.info("MESSAGGIO RICEVUTO");
		
		log.info("COPIO IL PACCHETTO");
		
		MessageExchange scambio = (MessageExchange)exchange;
		
		log.info("INVIO");
		
	  try{
		wsnBroker.notify(msg, receiveTopic); 
		log.info("FASE INVIO");
		publisher.onMessageExchange(scambio);
		log.debug("IL PACCHETTO INVIATO E': " + scambio);
	  }catch(JBIException e){
		  log.error("ECCEZIONE GENERATA!");
	  }
	
      log.info("INVIATO");
}
}


It's right?

When I run example, I've the following output:


......
DEBUG - SedaFlow                       - Called Flow send
INFO  - TraceComponent                 - Exchange: InOut[
  id: ID:192.168.0.172-1173fde41d2-2:0
  status: Active
  role: provider
  endpoint: endpoint
  in: <?xml version="1.0" encoding="UTF-8"?><ns2:Notify
xmlns:ns2="http://docs.oasis-open.org/wsn/b-2"
xmlns="http://www.w3.org/2005/08/addressing"
xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"
xmlns:ns4="http://docs.oasis-open.org/wsn/t-1"><ns2:NotificationMessage><ns2:Topic>sendTopic</ns2:Topic><ns2:Message><timer
xmlns="" xmlns:ns5="http://www.w3.org/2005/08/addressing"><name>My Example
Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example
Job</fullname><description/><fireTime>Thu Jan 03 14:37:42 CET
2008</fireTime></timer></ns2:Message></ns2:NotificationMessage></ns2:Notify>
] received IN message:
org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@1e13a2c{properties:
{}}
INFO  - TraceComponent                 - Body is: <?xml version="1.0"
encoding="UTF-8"?><ns2:Notify xmlns:ns2="http://docs.oasis-open.org/wsn/b-2"
xmlns="http://www.w3.org/2005/08/addressing"
xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"
xmlns:ns4="http://docs.oasis-open.org/wsn/t-1"><ns2:NotificationMessage><ns2:Topic>sendTopic</ns2:Topic><ns2:Message><timer
xmlns="" xmlns:ns5="http://www.w3.org/2005/08/addressing"><name>My Example
Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example
Job</fullname><description/><fireTime>Thu Jan 03 14:37:42 CET
2008</fireTime></timer></ns2:Message></ns2:NotificationMessage></ns2:Notify>
DEBUG - SedaFlow                       - Called Flow send
INFO  - TraceComponent                 - MESSAGGIO RICEVUTO
INFO  - TraceComponent                 - COPIO IL PACCHETTO
INFO  - TraceComponent                 - INVIO
DEBUG - JMSFlow                        - Called Flow send
DEBUG - ActiveMQSession                - Sending message:
ActiveMQObjectMessage {commandId = 0, responseRequired = false, messageId =
ID:martina-34240-1199367439941-3:0:1:1:2, originalDestination = null,
originalTransactionId = null, producerId =
ID:martina-34240-1199367439941-3:0:1:1, destination =
queue://org.apache.servicemix.jms.{http://servicemix.org/wsnotification}NotificationBroker:Broker,
transactionId = null, expiration = 0, timestamp = 1199367463015, arrival =
0, correlationId = null, replyTo = null, persistent = true, type = null,
priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
compressed = false, userID = null, content =
org.apache.activemq.util.ByteSequence@2f75e5, marshalledProperties = null,
dataStructure = null, redeliveryCounter = 0, size = 0, properties = null,
readOnlyProperties = true, readOnlyBody = true, droppable = false}
DEBUG - WSNSpringComponent             - Received exchange: status: Active,
role: provider
DEBUG - WSNSpringComponent             - Retrieved correlation id: null
DEBUG - WSNSpringComponent             - Received exchange: status: Active,
role: consumer
DEBUG - WSNSpringComponent             - Retrieved correlation id: null
ERROR - WSNSpringComponent             - Error processing exchange InOut[
  id: ID:192.168.0.172-1173fde41d2-3:1
  status: Active
  role: provider
  endpoint: Broker
  in: <?xml version="1.0" encoding="UTF-8"?><ns2:Notify
xmlns:ns2="http://docs.oasis-open.org/wsn/b-2"
xmlns="http://www.w3.org/2005/08/addressing"
xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"
xmlns:ns4="http://docs.oasis-open.org/wsn/t-1"
xmlns:ns5="http://docs.oasis-open.org/wsn/br-2"><ns2:NotificationMessage><ns2:Message/></ns2:NotificationMessage></ns2:Notify>
]
java.lang.NullPointerException
	at
org.apache.servicemix.wsn.jms.JmsTopicExpressionConverter.toActiveMQTopic(JmsTopicExpressionConverter.java:63)
	at org.apache.servicemix.wsn.jms.JmsPublisher.notify(JmsPublisher.java:82)
	at
org.apache.servicemix.wsn.AbstractNotificationBroker.handleNotify(AbstractNotificationBroker.java:111)
	at
org.apache.servicemix.wsn.AbstractNotificationBroker.notify(AbstractNotificationBroker.java:103)
	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
org.apache.servicemix.wsn.component.WSNEndpoint.process(WSNEndpoint.java:137)
	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.jms.JMSFlow.access$3(JMSFlow.java:1)
	at org.apache.servicemix.jbi.nmr.flow.jms.JMSFlow$5.run(JMSFlow.java:543)
	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)
DEBUG - JMSFlow                        - Called Flow send
DEBUG - ActiveMQSession                - Sending message:
ActiveMQObjectMessage {commandId = 0, responseRequired = false, messageId =
ID:martina-34240-1199367439941-3:0:1:1:3, originalDestination = null,
originalTransactionId = null, producerId =
ID:martina-34240-1199367439941-3:0:1:1, destination =
queue://org.apache.servicemix.jms.wsn2, transactionId = null, expiration =
0, timestamp = 1199367463037, arrival = 0, correlationId = null, replyTo =
null, persistent = true, type = null, priority = 4, groupID = null,
groupSequence = 0, targetConsumerId = null, compressed = false, userID =
null, content = org.apache.activemq.util.ByteSequence@f49e8f,
marshalledProperties = null, dataStructure = null, redeliveryCounter = 0,
size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true,
droppable = false}
INFO  - TraceComponent                 - FASE INVIO
INFO  - TraceComponent                 - INVIATO
.....

Perhaps, I don't understand...

Can you help me again?
Thank you very much.

Martina



gnodet wrote:
> 
> The PublisherComponent is a lightweight component and should be configured
> in a spring xml for the lightweight container.
> Else, use the WSN client api only.
>    wsnBroker = new NotificationBroker(getContext());
>    wsnBroker.notify(msg, topic);
> 
> It seems the client api does not support setting the publisher on the
> notification but you can add the needed method and provide a patch.
> 
> 
> On Jan 3, 2008 12:10 PM, martymusk <ma...@email.it> wrote:
> 
>>
>> Hy gnodet,
>> thank you for immediately answer.
>> Thus... I'm trying to modify wsn-example. After instance2 receive
>> exchange,
>> I'd like it publish copy of it.
>> I've created another TraceComponent class. This class, after receiving
>> exchange, try to send "scambio".
>> I've created this class as follow:
>>
>>
>> package org.apache.servicemix.wsn;
>>
>> import javax.jbi.JBIException;
>> import javax.jbi.messaging.MessageExchange;
>> import javax.jbi.messaging.MessagingException;
>> import javax.jbi.messaging.NormalizedMessage;
>> import javax.xml.transform.TransformerException;
>> //import javax.jbi.messaging.InOut;
>>
>> import org.apache.commons.logging.Log;
>> import org.apache.commons.logging.LogFactory;
>> import org.apache.servicemix.MessageExchangeListener;
>> import org.apache.servicemix.components.util.ComponentSupport;
>> import org.apache.servicemix.wsn.spring.PublisherComponent;
>> import org.apache.servicemix.jbi.jaxp.SourceTransformer;
>> import org.apache.servicemix.wsn.client.AbstractWSAClient;
>> import org.apache.servicemix.wsn.client.NotificationBroker;
>>
>>
>> public class TraceComponent extends ComponentSupport implements
>>                MessageExchangeListener {
>>
>>        private Log log = LogFactory.getLog(TraceComponent.class);
>>
>>        private SourceTransformer sourceTransformer = new
>> SourceTransformer();
>>
>>        public Log getLog() {
>>                return log;
>>        }
>>
>>        public void setLog(Log log) {
>>                this.log = log;
>>        }
>>
>>        public SourceTransformer getSourceTransformer() {
>>                return sourceTransformer;
>>        }
>>
>>        public void setSourceTransformer(SourceTransformer
>> sourceTransformer) {
>>                this.sourceTransformer = sourceTransformer;
>>        }
>>
>>
>>        //AGGIUNGO CODICE
>>
>>        PublisherComponent publisher = new PublisherComponent();
>>         //private String receiveTopic;
>>          private String subscriptionEndpoint = "subscription";
>>          private NotificationBroker wsnBroker;
>>          private String topic;
>>          private boolean demand;
>>
>>
>>          public String getTopic() {
>>                return topic;
>>            }
>>
>>            /**
>>             * @param topic The topic to set.
>>             */
>>            public void setTopic(String topic) {
>>                this.topic = topic;
>>            }
>>
>>         public void init() throws JBIException {
>>                super.init();
>>                getContext().activateEndpoint(getService(),
>> subscriptionEndpoint);
>>                 log.info("METODO INIT");
>>                 //publisher.init();
>>
>>                // publisher.setTopic(receiveTopic);
>>            }
>>
>>            /* (non-Javadoc)
>>             * @see javax.jbi.management.LifeCycleMBean#start()
>>             */
>>            public void start() throws JBIException {
>>
>>                log.info("METODO START");
>>                //publisher.start();
>>                new Thread() {
>>                  public void run() {
>>                       try {
>>                           wsnBroker = new
>> NotificationBroker(getContext());
>>                           String wsaAddress =
>> getService().getNamespaceURI() + "/"
>> + getService().getLocalPart() + "/" + subscriptionEndpoint;
>>
>> wsnBroker.registerPublisher(AbstractWSAClient.createWSA(wsaAddress),
>>                                                       topic,
>>                                                        demand);
>>                        } catch (Exception e) {
>>                            log.error("Could not create wsn client", e);
>>                        }
>>                    }
>>                }.start();
>>            }
>>
>>
>>            public void shutDown() throws JBIException {
>>                log.info("METODO SHUTDOWN");
>>            //  publisher.shutDown();
>>               super.shutDown();
>>            }
>>
>>            //FINE CODICE AGGIUNTO
>>
>>        public void onMessageExchange(MessageExchange exchange)
>>                        throws MessagingException {
>>                // lets dump the incoming message
>>                NormalizedMessage message = exchange.getMessage("in");
>>                if (message == null) {
>>                        log.warn("Received null message from exchange: " +
>> exchange);
>>                } else {
>>                        log.info("Exchange: " + exchange + " received IN
>> message: "
>>                                        + message);
>>                        try {
>>                                log.info("Body is: "
>>                                                +
>> sourceTransformer.toString(message.getContent()));
>>                        } catch (TransformerException e) {
>>                                log.error("Failed to turn message body
>> into
>> text: " + e, e);
>>                        }
>>                }
>>                done(exchange);
>>                log.info("MESSAGGIO RICEVUTO");
>>
>>                log.info("COPIO IL PACCHETTO");
>>
>>                MessageExchange scambio = (MessageExchange)exchange;
>>
>>                log.info("INVIO");
>>
>>                publisher.onMessageExchange(scambio);
>>
>>        }
>>
>>
>> }
>>
>>
>>
>> When I run example, in instance2 I've the following eror:
>>
>> .......
>> DEBUG - JMSFlow                        - Called Flow send
>> DEBUG - ActiveMQSession                - Sending message:
>> ActiveMQObjectMessage {commandId = 0, responseRequired = false, messageId
>> =
>> ID:martina-33417-1199357741650-4:0:1:1:2, originalDestination = null,
>> originalTransactionId = null, producerId =
>> ID:martina-33417-1199357741650-4:0:1:1, destination =
>> queue://org.apache.servicemix.jms.wsn3, transactionId = null, expiration
>> =
>> 0, timestamp = 1199357765789, arrival = 0, correlationId = null, replyTo
>> =
>> null, persistent = true, type = null, priority = 4, groupID = null,
>> groupSequence = 0, targetConsumerId = null, compressed = false, userID =
>> null, content = org.apache.activemq.util.ByteSequence@11126f6,
>> marshalledProperties = null, dataStructure = null, redeliveryCounter = 0,
>> size = 0, properties = null, readOnlyProperties = true, readOnlyBody =
>> true,
>> droppable = false}
>> DEBUG - SedaFlow                       - Called Flow send
>> INFO  - TraceComponent                 - Exchange: InOut[
>>  id: ID:192.168.0.172-1173f4a4a0b-2:1
>>  status: Active
>>  role: provider
>>  endpoint: endpoint
>>  in: <?xml version="1.0" encoding="UTF-8"?><ns2:Notify
>> xmlns:ns2="http://docs.oasis-open.org/wsn/b-2"
>> xmlns="http://www.w3.org/2005/08/addressing"
>> xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"
>> xmlns:ns4="http://docs.oasis-open.org/wsn/t-1
>> "><ns2:NotificationMessage><ns2:Topic>sendTopic</ns2:Topic><ns2:Message><timer
>> xmlns="" xmlns:ns5="http://www.w3.org/2005/08/addressing"><name>My
>> Example
>> Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example
>> Job</fullname><description/><fireTime>Thu Jan 03 11:56:05 CET
>>
>> 2008</fireTime></timer></ns2:Message></ns2:NotificationMessage></ns2:Notify>
>> ] received IN message:
>>
>> org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@1703484{properties
>> :
>> {}}
>> INFO  - TraceComponent                 - Body is: <?xml version="1.0"
>> encoding="UTF-8"?><ns2:Notify xmlns:ns2="
>> http://docs.oasis-open.org/wsn/b-2"
>> xmlns="http://www.w3.org/2005/08/addressing"
>> xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"
>> xmlns:ns4="http://docs.oasis-open.org/wsn/t-1
>> "><ns2:NotificationMessage><ns2:Topic>sendTopic</ns2:Topic><ns2:Message><timer
>> xmlns="" xmlns:ns5="http://www.w3.org/2005/08/addressing"><name>My
>> Example
>> Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example
>> Job</fullname><description/><fireTime>Thu Jan 03 11:56:05 CET
>>
>> 2008</fireTime></timer></ns2:Message></ns2:NotificationMessage></ns2:Notify>
>> DEBUG - SedaFlow                       - Called Flow send
>> INFO  - TraceComponent                 - MESSAGGIO RICEVUTO
>> INFO  - TraceComponent                 - COPIO IL PACCHETTO
>> INFO  - TraceComponent                 - INVIO
>> ERROR - SedaQueue                      -
>> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1@2209db got error
>> processing InOut[
>>  id: ID:192.168.0.172-1173f4a4a0b-2:1
>>  status: Error
>>  role: provider
>>  endpoint: endpoint
>>  in: <?xml version="1.0" encoding="UTF-8"?><ns2:Notify
>> xmlns:ns2="http://docs.oasis-open.org/wsn/b-2"
>> xmlns="http://www.w3.org/2005/08/addressing"
>> xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"
>> xmlns:ns4="http://docs.oasis-open.org/wsn/t-1
>> "><ns2:NotificationMessage><ns2:Topic>sendTopic</ns2:Topic><ns2:Message><timer
>> xmlns="" xmlns:ns5="http://www.w3.org/2005/08/addressing"><name>My
>> Example
>> Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example
>> Job</fullname><description/><fireTime>Thu Jan 03 11:56:05 CET
>>
>> 2008</fireTime></timer></ns2:Message></ns2:NotificationMessage></ns2:Notify>
>>  error: java.lang.NullPointerException
>> ]
>> org.apache.servicemix.jbi.NotInitialisedYetException: Cannot perform
>> operations on this component until it has been initialised via init()
>>        at
>> org.apache.servicemix.components.util.PojoSupport.getDeliveryChannel(
>> PojoSupport.java:168)
>>        at
>> org.apache.servicemix.components.util.PojoSupport.fail(PojoSupport.java
>> :249)
>>        at
>> org.apache.servicemix.wsn.spring.PublisherComponent.onMessageExchange(
>> PublisherComponent.java:197)
>>        at
>> org.apache.servicemix.wsn.TraceComponent.onMessageExchange(
>> TraceComponent.java:130)
>>        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)
>> ......
>>
>> It's clear what I mean?
>>
>> I hope you can help me!
>>
>> Thank you very much!
>>
>> Martina
>>
>>
>>
>>
>> gnodet wrote:
>> >
>> > This means that the component has not been properly initialized and
>> > started
>> > ;-)
>> > Do you have a stack trace ?
>> >
>> > On Jan 3, 2008 11:16 AM, martymusk <ma...@email.it> wrote:
>> >
>> >>
>> >> Hy,  can somebody help me please?
>> >>
>> >> What means the following error?
>> >>
>> >> Cannot perform operations on this component until it has been
>> initialised
>> >> via init()
>> >>
>> >> I hope you can help me.
>> >> Thanks in advance
>> >>
>> >> Martina
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Help-on-error-tp14594612s12049p14594612.html
>> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> > ------------------------
>> > Blog: http://gnodet.blogspot.com/
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Help-on-error-tp14594612s12049p14595288.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Help-on-error-tp14594612s12049p14597221.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Help on error

Posted by Guillaume Nodet <gn...@gmail.com>.
The PublisherComponent is a lightweight component and should be configured
in a spring xml for the lightweight container.
Else, use the WSN client api only.
   wsnBroker = new NotificationBroker(getContext());
   wsnBroker.notify(msg, topic);

It seems the client api does not support setting the publisher on the
notification but you can add the needed method and provide a patch.


On Jan 3, 2008 12:10 PM, martymusk <ma...@email.it> wrote:

>
> Hy gnodet,
> thank you for immediately answer.
> Thus... I'm trying to modify wsn-example. After instance2 receive
> exchange,
> I'd like it publish copy of it.
> I've created another TraceComponent class. This class, after receiving
> exchange, try to send "scambio".
> I've created this class as follow:
>
>
> package org.apache.servicemix.wsn;
>
> import javax.jbi.JBIException;
> import javax.jbi.messaging.MessageExchange;
> import javax.jbi.messaging.MessagingException;
> import javax.jbi.messaging.NormalizedMessage;
> import javax.xml.transform.TransformerException;
> //import javax.jbi.messaging.InOut;
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.servicemix.MessageExchangeListener;
> import org.apache.servicemix.components.util.ComponentSupport;
> import org.apache.servicemix.wsn.spring.PublisherComponent;
> import org.apache.servicemix.jbi.jaxp.SourceTransformer;
> import org.apache.servicemix.wsn.client.AbstractWSAClient;
> import org.apache.servicemix.wsn.client.NotificationBroker;
>
>
> public class TraceComponent extends ComponentSupport implements
>                MessageExchangeListener {
>
>        private Log log = LogFactory.getLog(TraceComponent.class);
>
>        private SourceTransformer sourceTransformer = new
> SourceTransformer();
>
>        public Log getLog() {
>                return log;
>        }
>
>        public void setLog(Log log) {
>                this.log = log;
>        }
>
>        public SourceTransformer getSourceTransformer() {
>                return sourceTransformer;
>        }
>
>        public void setSourceTransformer(SourceTransformer
> sourceTransformer) {
>                this.sourceTransformer = sourceTransformer;
>        }
>
>
>        //AGGIUNGO CODICE
>
>        PublisherComponent publisher = new PublisherComponent();
>         //private String receiveTopic;
>          private String subscriptionEndpoint = "subscription";
>          private NotificationBroker wsnBroker;
>          private String topic;
>          private boolean demand;
>
>
>          public String getTopic() {
>                return topic;
>            }
>
>            /**
>             * @param topic The topic to set.
>             */
>            public void setTopic(String topic) {
>                this.topic = topic;
>            }
>
>         public void init() throws JBIException {
>                super.init();
>                getContext().activateEndpoint(getService(),
> subscriptionEndpoint);
>                 log.info("METODO INIT");
>                 //publisher.init();
>
>                // publisher.setTopic(receiveTopic);
>            }
>
>            /* (non-Javadoc)
>             * @see javax.jbi.management.LifeCycleMBean#start()
>             */
>            public void start() throws JBIException {
>
>                log.info("METODO START");
>                //publisher.start();
>                new Thread() {
>                  public void run() {
>                       try {
>                           wsnBroker = new
> NotificationBroker(getContext());
>                           String wsaAddress =
> getService().getNamespaceURI() + "/"
> + getService().getLocalPart() + "/" + subscriptionEndpoint;
>
> wsnBroker.registerPublisher(AbstractWSAClient.createWSA(wsaAddress),
>                                                       topic,
>                                                        demand);
>                        } catch (Exception e) {
>                            log.error("Could not create wsn client", e);
>                        }
>                    }
>                }.start();
>            }
>
>
>            public void shutDown() throws JBIException {
>                log.info("METODO SHUTDOWN");
>            //  publisher.shutDown();
>               super.shutDown();
>            }
>
>            //FINE CODICE AGGIUNTO
>
>        public void onMessageExchange(MessageExchange exchange)
>                        throws MessagingException {
>                // lets dump the incoming message
>                NormalizedMessage message = exchange.getMessage("in");
>                if (message == null) {
>                        log.warn("Received null message from exchange: " +
> exchange);
>                } else {
>                        log.info("Exchange: " + exchange + " received IN
> message: "
>                                        + message);
>                        try {
>                                log.info("Body is: "
>                                                +
> sourceTransformer.toString(message.getContent()));
>                        } catch (TransformerException e) {
>                                log.error("Failed to turn message body into
> text: " + e, e);
>                        }
>                }
>                done(exchange);
>                log.info("MESSAGGIO RICEVUTO");
>
>                log.info("COPIO IL PACCHETTO");
>
>                MessageExchange scambio = (MessageExchange)exchange;
>
>                log.info("INVIO");
>
>                publisher.onMessageExchange(scambio);
>
>        }
>
>
> }
>
>
>
> When I run example, in instance2 I've the following eror:
>
> .......
> DEBUG - JMSFlow                        - Called Flow send
> DEBUG - ActiveMQSession                - Sending message:
> ActiveMQObjectMessage {commandId = 0, responseRequired = false, messageId
> =
> ID:martina-33417-1199357741650-4:0:1:1:2, originalDestination = null,
> originalTransactionId = null, producerId =
> ID:martina-33417-1199357741650-4:0:1:1, destination =
> queue://org.apache.servicemix.jms.wsn3, transactionId = null, expiration =
> 0, timestamp = 1199357765789, arrival = 0, correlationId = null, replyTo =
> null, persistent = true, type = null, priority = 4, groupID = null,
> groupSequence = 0, targetConsumerId = null, compressed = false, userID =
> null, content = org.apache.activemq.util.ByteSequence@11126f6,
> marshalledProperties = null, dataStructure = null, redeliveryCounter = 0,
> size = 0, properties = null, readOnlyProperties = true, readOnlyBody =
> true,
> droppable = false}
> DEBUG - SedaFlow                       - Called Flow send
> INFO  - TraceComponent                 - Exchange: InOut[
>  id: ID:192.168.0.172-1173f4a4a0b-2:1
>  status: Active
>  role: provider
>  endpoint: endpoint
>  in: <?xml version="1.0" encoding="UTF-8"?><ns2:Notify
> xmlns:ns2="http://docs.oasis-open.org/wsn/b-2"
> xmlns="http://www.w3.org/2005/08/addressing"
> xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"
> xmlns:ns4="http://docs.oasis-open.org/wsn/t-1
> "><ns2:NotificationMessage><ns2:Topic>sendTopic</ns2:Topic><ns2:Message><timer
> xmlns="" xmlns:ns5="http://www.w3.org/2005/08/addressing"><name>My Example
> Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example
> Job</fullname><description/><fireTime>Thu Jan 03 11:56:05 CET
>
> 2008</fireTime></timer></ns2:Message></ns2:NotificationMessage></ns2:Notify>
> ] received IN message:
>
> org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@1703484{properties
> :
> {}}
> INFO  - TraceComponent                 - Body is: <?xml version="1.0"
> encoding="UTF-8"?><ns2:Notify xmlns:ns2="
> http://docs.oasis-open.org/wsn/b-2"
> xmlns="http://www.w3.org/2005/08/addressing"
> xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"
> xmlns:ns4="http://docs.oasis-open.org/wsn/t-1
> "><ns2:NotificationMessage><ns2:Topic>sendTopic</ns2:Topic><ns2:Message><timer
> xmlns="" xmlns:ns5="http://www.w3.org/2005/08/addressing"><name>My Example
> Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example
> Job</fullname><description/><fireTime>Thu Jan 03 11:56:05 CET
>
> 2008</fireTime></timer></ns2:Message></ns2:NotificationMessage></ns2:Notify>
> DEBUG - SedaFlow                       - Called Flow send
> INFO  - TraceComponent                 - MESSAGGIO RICEVUTO
> INFO  - TraceComponent                 - COPIO IL PACCHETTO
> INFO  - TraceComponent                 - INVIO
> ERROR - SedaQueue                      -
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1@2209db got error
> processing InOut[
>  id: ID:192.168.0.172-1173f4a4a0b-2:1
>  status: Error
>  role: provider
>  endpoint: endpoint
>  in: <?xml version="1.0" encoding="UTF-8"?><ns2:Notify
> xmlns:ns2="http://docs.oasis-open.org/wsn/b-2"
> xmlns="http://www.w3.org/2005/08/addressing"
> xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"
> xmlns:ns4="http://docs.oasis-open.org/wsn/t-1
> "><ns2:NotificationMessage><ns2:Topic>sendTopic</ns2:Topic><ns2:Message><timer
> xmlns="" xmlns:ns5="http://www.w3.org/2005/08/addressing"><name>My Example
> Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example
> Job</fullname><description/><fireTime>Thu Jan 03 11:56:05 CET
>
> 2008</fireTime></timer></ns2:Message></ns2:NotificationMessage></ns2:Notify>
>  error: java.lang.NullPointerException
> ]
> org.apache.servicemix.jbi.NotInitialisedYetException: Cannot perform
> operations on this component until it has been initialised via init()
>        at
> org.apache.servicemix.components.util.PojoSupport.getDeliveryChannel(
> PojoSupport.java:168)
>        at
> org.apache.servicemix.components.util.PojoSupport.fail(PojoSupport.java
> :249)
>        at
> org.apache.servicemix.wsn.spring.PublisherComponent.onMessageExchange(
> PublisherComponent.java:197)
>        at
> org.apache.servicemix.wsn.TraceComponent.onMessageExchange(
> TraceComponent.java:130)
>        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)
> ......
>
> It's clear what I mean?
>
> I hope you can help me!
>
> Thank you very much!
>
> Martina
>
>
>
>
> gnodet wrote:
> >
> > This means that the component has not been properly initialized and
> > started
> > ;-)
> > Do you have a stack trace ?
> >
> > On Jan 3, 2008 11:16 AM, martymusk <ma...@email.it> wrote:
> >
> >>
> >> Hy,  can somebody help me please?
> >>
> >> What means the following error?
> >>
> >> Cannot perform operations on this component until it has been
> initialised
> >> via init()
> >>
> >> I hope you can help me.
> >> Thanks in advance
> >>
> >> Martina
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Help-on-error-tp14594612s12049p14594612.html
> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Help-on-error-tp14594612s12049p14595288.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

Re: Help on error

Posted by martymusk <ma...@email.it>.
Hy gnodet,
thank you for immediately answer.
Thus... I'm trying to modify wsn-example. After instance2 receive exchange,
I'd like it publish copy of it. 
I've created another TraceComponent class. This class, after receiving
exchange, try to send "scambio".
I've created this class as follow:


package org.apache.servicemix.wsn;

import javax.jbi.JBIException;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.xml.transform.TransformerException;
//import javax.jbi.messaging.InOut;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.MessageExchangeListener;
import org.apache.servicemix.components.util.ComponentSupport;
import org.apache.servicemix.wsn.spring.PublisherComponent;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.servicemix.wsn.client.AbstractWSAClient;
import org.apache.servicemix.wsn.client.NotificationBroker;


public class TraceComponent extends ComponentSupport implements
		MessageExchangeListener {

	private Log log = LogFactory.getLog(TraceComponent.class);

	private SourceTransformer sourceTransformer = new SourceTransformer();

	public Log getLog() {
		return log;
	}

	public void setLog(Log log) {
		this.log = log;
	}

	public SourceTransformer getSourceTransformer() {
		return sourceTransformer;
	}

	public void setSourceTransformer(SourceTransformer sourceTransformer) {
		this.sourceTransformer = sourceTransformer;
	}
	
	
	//AGGIUNGO CODICE
		
	PublisherComponent publisher = new PublisherComponent();
	 //private String receiveTopic;
	  private String subscriptionEndpoint = "subscription";
	  private NotificationBroker wsnBroker;
	  private String topic;
	  private boolean demand;
	  
	  
	  public String getTopic() {
	        return topic;
	    }

	    /**
	     * @param topic The topic to set.
	     */
	    public void setTopic(String topic) {
	        this.topic = topic;
	    }
	  
	 public void init() throws JBIException {
	        super.init();
	        getContext().activateEndpoint(getService(), subscriptionEndpoint);
		 log.info("METODO INIT");
		 //publisher.init();
		 
		// publisher.setTopic(receiveTopic);
	    }
	    
	    /* (non-Javadoc)
	     * @see javax.jbi.management.LifeCycleMBean#start()
	     */
	    public void start() throws JBIException {
	    	
	    	log.info("METODO START");
	    	//publisher.start();
	        new Thread() {
	          public void run() {
	               try {
	                   wsnBroker = new NotificationBroker(getContext());
	                   String wsaAddress = getService().getNamespaceURI() + "/"
+ getService().getLocalPart() + "/" + subscriptionEndpoint;
	                  
wsnBroker.registerPublisher(AbstractWSAClient.createWSA(wsaAddress),
	                                               topic,
	                                                demand);
	                } catch (Exception e) {
	                    log.error("Could not create wsn client", e);
	                }
	            }
	        }.start();
	    }
	    
	    
	    public void shutDown() throws JBIException {
	    	log.info("METODO SHUTDOWN");
	    //	publisher.shutDown();
	       super.shutDown();
	    }
	    
	    //FINE CODICE AGGIUNTO

	public void onMessageExchange(MessageExchange exchange)
			throws MessagingException {
		// lets dump the incoming message
		NormalizedMessage message = exchange.getMessage("in");
		if (message == null) {
			log.warn("Received null message from exchange: " + exchange);
		} else {
			log.info("Exchange: " + exchange + " received IN message: "
					+ message);
			try {
				log.info("Body is: "
						+ sourceTransformer.toString(message.getContent()));
			} catch (TransformerException e) {
				log.error("Failed to turn message body into text: " + e, e);
			}
		}
		done(exchange);
		log.info("MESSAGGIO RICEVUTO");
		
		log.info("COPIO IL PACCHETTO");
		
		MessageExchange scambio = (MessageExchange)exchange;
		
		log.info("INVIO");
		
		publisher.onMessageExchange(scambio);
		
	}


}



When I run example, in instance2 I've the following eror:

.......
DEBUG - JMSFlow                        - Called Flow send
DEBUG - ActiveMQSession                - Sending message:
ActiveMQObjectMessage {commandId = 0, responseRequired = false, messageId =
ID:martina-33417-1199357741650-4:0:1:1:2, originalDestination = null,
originalTransactionId = null, producerId =
ID:martina-33417-1199357741650-4:0:1:1, destination =
queue://org.apache.servicemix.jms.wsn3, transactionId = null, expiration =
0, timestamp = 1199357765789, arrival = 0, correlationId = null, replyTo =
null, persistent = true, type = null, priority = 4, groupID = null,
groupSequence = 0, targetConsumerId = null, compressed = false, userID =
null, content = org.apache.activemq.util.ByteSequence@11126f6,
marshalledProperties = null, dataStructure = null, redeliveryCounter = 0,
size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true,
droppable = false}
DEBUG - SedaFlow                       - Called Flow send
INFO  - TraceComponent                 - Exchange: InOut[
  id: ID:192.168.0.172-1173f4a4a0b-2:1
  status: Active
  role: provider
  endpoint: endpoint
  in: <?xml version="1.0" encoding="UTF-8"?><ns2:Notify
xmlns:ns2="http://docs.oasis-open.org/wsn/b-2"
xmlns="http://www.w3.org/2005/08/addressing"
xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"
xmlns:ns4="http://docs.oasis-open.org/wsn/t-1"><ns2:NotificationMessage><ns2:Topic>sendTopic</ns2:Topic><ns2:Message><timer
xmlns="" xmlns:ns5="http://www.w3.org/2005/08/addressing"><name>My Example
Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example
Job</fullname><description/><fireTime>Thu Jan 03 11:56:05 CET
2008</fireTime></timer></ns2:Message></ns2:NotificationMessage></ns2:Notify>
] received IN message:
org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@1703484{properties:
{}}
INFO  - TraceComponent                 - Body is: <?xml version="1.0"
encoding="UTF-8"?><ns2:Notify xmlns:ns2="http://docs.oasis-open.org/wsn/b-2"
xmlns="http://www.w3.org/2005/08/addressing"
xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"
xmlns:ns4="http://docs.oasis-open.org/wsn/t-1"><ns2:NotificationMessage><ns2:Topic>sendTopic</ns2:Topic><ns2:Message><timer
xmlns="" xmlns:ns5="http://www.w3.org/2005/08/addressing"><name>My Example
Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example
Job</fullname><description/><fireTime>Thu Jan 03 11:56:05 CET
2008</fireTime></timer></ns2:Message></ns2:NotificationMessage></ns2:Notify>
DEBUG - SedaFlow                       - Called Flow send
INFO  - TraceComponent                 - MESSAGGIO RICEVUTO
INFO  - TraceComponent                 - COPIO IL PACCHETTO
INFO  - TraceComponent                 - INVIO
ERROR - SedaQueue                      -
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1@2209db got error
processing InOut[
  id: ID:192.168.0.172-1173f4a4a0b-2:1
  status: Error
  role: provider
  endpoint: endpoint
  in: <?xml version="1.0" encoding="UTF-8"?><ns2:Notify
xmlns:ns2="http://docs.oasis-open.org/wsn/b-2"
xmlns="http://www.w3.org/2005/08/addressing"
xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"
xmlns:ns4="http://docs.oasis-open.org/wsn/t-1"><ns2:NotificationMessage><ns2:Topic>sendTopic</ns2:Topic><ns2:Message><timer
xmlns="" xmlns:ns5="http://www.w3.org/2005/08/addressing"><name>My Example
Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example
Job</fullname><description/><fireTime>Thu Jan 03 11:56:05 CET
2008</fireTime></timer></ns2:Message></ns2:NotificationMessage></ns2:Notify>
  error: java.lang.NullPointerException
]
org.apache.servicemix.jbi.NotInitialisedYetException: Cannot perform
operations on this component until it has been initialised via init()
	at
org.apache.servicemix.components.util.PojoSupport.getDeliveryChannel(PojoSupport.java:168)
	at
org.apache.servicemix.components.util.PojoSupport.fail(PojoSupport.java:249)
	at
org.apache.servicemix.wsn.spring.PublisherComponent.onMessageExchange(PublisherComponent.java:197)
	at
org.apache.servicemix.wsn.TraceComponent.onMessageExchange(TraceComponent.java:130)
	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)
......

It's clear what I mean?

I hope you can help me!

Thank you very much!

Martina




gnodet wrote:
> 
> This means that the component has not been properly initialized and
> started
> ;-)
> Do you have a stack trace ?
> 
> On Jan 3, 2008 11:16 AM, martymusk <ma...@email.it> wrote:
> 
>>
>> Hy,  can somebody help me please?
>>
>> What means the following error?
>>
>> Cannot perform operations on this component until it has been initialised
>> via init()
>>
>> I hope you can help me.
>> Thanks in advance
>>
>> Martina
>> --
>> View this message in context:
>> http://www.nabble.com/Help-on-error-tp14594612s12049p14594612.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Help-on-error-tp14594612s12049p14595288.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Help on error

Posted by Guillaume Nodet <gn...@gmail.com>.
This means that the component has not been properly initialized and started
;-)
Do you have a stack trace ?

On Jan 3, 2008 11:16 AM, martymusk <ma...@email.it> wrote:

>
> Hy,  can somebody help me please?
>
> What means the following error?
>
> Cannot perform operations on this component until it has been initialised
> via init()
>
> I hope you can help me.
> Thanks in advance
>
> Martina
> --
> View this message in context:
> http://www.nabble.com/Help-on-error-tp14594612s12049p14594612.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/