Hi Gert Vanthienen

Thanks for your reply. I had debug statements, just removed them before
submitting the code to forum. Please find the bean method with debug
statements and the console displaying/printing the statement values.

It is executing onMessageExchange successfully while the control
returning back from onMessageExchange method to router the router occurs
(I guess).

Please help me to solve this issue. I am struggling for the past four
days with the same issue.

Bean method
-----------

        public void onMessageExchange(MessageExchange exchange)
                        throws MessagingException {

                if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
                        NormalizedMessage normalizedMessage =null;
                        NormalizedMessage normalizedMessageOut=null;
                        normalizedMessage = exchange.getMessage("in");  
                        normalizedMessageOut= exchange.createMessage(); 
                        String outMessage =
processXml(normalizedMessage);
                        System.out.println("after processXml11111" +
outMessage);
                        normalizedMessageOut.setContent(new
StringSource(outMessage));
                        System.out.println("set
content"+normalizedMessageOut.getContent().toString());
                        exchange.setMessage(normalizedMessageOut,
"out");
                        exchange.setStatus(ExchangeStatus.ACTIVE);
                        System.out.println("before sending");
                        channel.send(exchange);
                        System.out.println("after sending");
                } 
        }
        private String processXml(NormalizedMessage normalizedMessage)
throws MessagingException {
   SourceTransformer sourceTransformer = new SourceTransformer(); 
   String inMessage = "";
   try {   
   inMessage = sourceTransformer.contentToString(normalizedMessage); 
   } catch (Exception e) {  
   throw new MessagingException(e); 
   }  
   System.out.println("input"+inMessage);
   System.out.println("coreMessage from Service1"+coreMessage);
   String outMessage ="<response1>" + coreMessage + "</response1>";  
   System.out.println("11111111");
   System.out.println("## Out Message: " + outMessage);
   return outMessage;
   }
}

Server console output
---------------------

input<?xml version="1.0" encoding="UTF-8"?><input2>Tesing Content Based
Rounter
2222</input2>
coreMessage from Service1<input2>Tesing Content Based Rounter
2222</input2>
11111111
## Out Message: <response1><input2>Tesing Content Based Rounter
2222</input2></r
esponse1>
after processXml11111<response1><input2>Tesing Content Based Rounter
2222</input
2></response1>
set contentStringSource[<response1><input2>Tesing Content Based Rounter
2222</in
put2></response1>]
before sending
after sending
[Fatal Error] :-1:-1: Premature end of file.
[Fatal Error] :-1:-1: Premature end of file.
ERROR - EIPComponent                   - Error processing exchange
InOnly[
  id: ID:10.102.11.29-11f46231bc3-11:2
  status: Active
  role: provider
  service: {http://test}MyStaticRoutingSlip1Service
  endpoint: myStaticRoutingSlip1Su
  operation: {http://test}onMessage
  in: Unable to display: org.xml.sax.SAXParseException: Premature end of
file.
]
org.xml.sax.SAXParseException: Premature end of file.

Please help me to solve this issue. I am struggling for the past four
days with the same issue.

Thanks
Vasumathi
 

-----Original Message-----
From: Gert Vanthienen [mailto:[email protected]] 
Sent: Thursday, February 05, 2009 7:46 AM
To: [email protected]
Subject: Re: Unable to display: org.xml.sax.SAXParseException: Premature
end of file

Vasumathi,

This is probably caused by something consuming a StreamSource or
StaxSource before your service touches it.  To make sure that this is
the cause, could you try enabling DEBUG logging because this should
'solve' the issue then?

Once we are sure that this is the cause of the problem, we should try to
modify the bean method so that it converts the source into a re-readable
source type before actually processing it.  Our MessageUtil class has a
method named enableContentRereadability() that was created exactly for
this purpose.

Regards,

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



2009/2/5 Vasumathi, Rajamarthandan
<[email protected]>:
> Hi All,
>
> I am new to service Mix and JBI. I am getting the below error while 
> executing a content enricher EIP. The service Mix version I am using 
> is 3.3.1.3. I am using In-Only exchange pattern.
>
>  Overall flow goes like this
>
> JMS BC -> Content Enricher EIP -> Service Unit(Temporarily using a 
> Single Service Unit)
>
> Error I am facing
>
> [Fatal Error] :-1:-1: Premature end of file.
> [Fatal Error] :-1:-1: Premature end of file.
> ERROR - EIPComponent                   - Error processing exchange
> InOnly[
>  id: ID:10.102.11.29-11f46231bc3-11:0
>  status: Active
>  role: provider
>  service: {http://test}MyStaticRoutingSlip1Service
>  endpoint: myStaticRoutingSlip1Su
>  operation: {http://test}onMessage
>  in: Unable to display: org.xml.sax.SAXParseException: Premature end 
> of file ]
> org.xml.sax.SAXParseException: Premature end of file.
>
> Please find the code
>
> JMS BC
> -------
>
> <beans xmlns:jms="http://servicemix.apache.org/jms/1.0";
> xmlns:test="http://test"; xmlns:amq="http://activemq.org/config/1.0";>
>  <jms:endpoint service="test:MyJmsQueueTest" endpoint="jmsQueue"
>  targetService="test:MyStaticRoutingSlip1Service"
> targetEndpoint="myStaticRoutingSlip1Su"
>  role="consumer" destinationStyle="queue"
> jmsProviderDestinationName="myJmsQueueTest"
>  defaultMep="http://www.w3.org/2004/08/wsdl/in-only";
> defaultOperation="test:onMessage"
>  connectionFactory="#connectionFactory">
>  </jms:endpoint>
>  <amq:connectionFactory id="connectionFactory"
>  brokerURL="tcp://localhost:61616" />
> </beans>
>
> Cotent Enricher EIP
> -------------------
> <beans xmlns:eip="http://servicemix.apache.org/eip/1.0";
> xmlns:test="http://test";>
> <eip:content-enricher service="test:MyStaticRoutingSlip1Service"
> endpoint="myStaticRoutingSlip1Su">
>  <eip:enricherTarget>
>    <eip:exchange-target service="test:MyS1PojoService"/>  
> </eip:enricherTarget>
>
> </eip:content-enricher>
> </beans>
>
> Service Unit  - Pojo code
> --------------------------
>
> public void onMessageExchange(MessageExchange exchange) {  if 
> (exchange.getStatus() == ExchangeStatus.ACTIVE) {
>
>   NormalizedMessage normalizedMessage =null;
>   NormalizedMessage normalizedMessageOut=null;
>   normalizedMessage = exchange.getMessage("in");
>   normalizedMessageOut= exchange.createMessage();
>   String outMessage = processXml(normalizedMessage);
>   normalizedMessageOut.setContent(new StringSource(outMessage));
>   exchange.setMessage(normalizedMessageOut, "out");
>   exchange.setStatus(ExchangeStatus.ACTIVE);
>   channel.send(exchange);
>
>  }
>  }
>
> I am struggling for the past four days with this issue. Please help me

> to solve the issue.
>
> Thanks
> Vasumathi
>
>
>
>
>
>
>
>

Reply via email to