5 Replies Latest reply on Feb 5, 2008 11:53 AM by ccustine

    InvalidPayloadException Camel running in ServiceMix

    jcrean

      Hi Folks,

       

      I am testing a simple camel component in fuse 3306 and am getting an InvalidPayloadException as follows:

      [Fatal Error] test.txt:1:1: Content is not allowed in prolog.
      INFO: found exchange JbiMessage: org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@68f812{properties: {org.apache.servicemix.file.name=test.txt, org.apache.servicemix.file.path=/Users/jcrean/Development/camel-smx-test-case/temp/test.txt}}
      INFO: HELLO HELLO !!!!!!!!!!!
      WARN  - ResolverUtil                   - Could not examine class 'org/apache/activemq/camel/component/ActiveMQComponent.class' due to a java.lang.NoClassDefFoundError with message: org/apache/camel/component/jms/JmsComponent
      WARN  - ResolverUtil                   - Could not examine class 'org/apache/activemq/camel/component/ActiveMQConfiguration.class' due to a java.lang.NoClassDefFoundError with message: org/apache/camel/component/jms/JmsConfiguration
      WARN  - ResolverUtil                   - Could not examine class 'org/apache/activemq/camel/component/JournalComponent.class' due to a java.lang.NoClassDefFoundError with message: org/apache/camel/impl/DefaultComponent
      WARN  - ResolverUtil                   - Could not examine class 'org/apache/activemq/camel/component/JournalEndpoint$1.class' due to a java.lang.NoClassDefFoundError with message: org/apache/camel/impl/DefaultConsumer
      WARN  - ResolverUtil                   - Could not examine class 'org/apache/activemq/camel/component/JournalEndpoint$3.class' due to a java.lang.NoClassDefFoundError with message: org/apache/camel/impl/DefaultProducer
      WARN  - ResolverUtil                   - Could not examine class 'org/apache/activemq/camel/component/JournalEndpoint.class' due to a java.lang.NoClassDefFoundError with message: org/apache/camel/impl/DefaultEndpoint
      ERROR - DeadLetterChannel              - On delivery attempt: 0 caught: org.apache.camel.InvalidPayloadException: No in body available of type: java.io.InputStream but has value: javax.xml.transform.stream.StreamSource@738f23 of type: javax.xml.transform.stream.StreamSource on the exchange: Exchange[FileMessage: /Users/jcrean/Development/camel-smx-test-case/message_output]
      org.apache.camel.InvalidPayloadException: No in body available of type: java.io.InputStream but has value: javax.xml.transform.stream.StreamSource@738f23 of type: javax.xml.transform.stream.StreamSource on the exchange: Exchange[FileMessage: /Users/jcrean/Development/camel-smx-test-case/message_output]
           at org.apache.camel.util.ExchangeHelper.getMandatoryInBody(ExchangeHelper.java:100)
      

       

      The very first line of this is interesting - i searched thru the code base to see where this was coming from but couldnt find it. I dont quite know what is wrong here - the file is a simple text file with contents like

      this is my test file!!
      

       

      my route is pretty simple : I am routing from a file poller to a targetService called RouterFeederService which is defined in the from part of the camel route.

       

       
               from("jbi:service:http://com.iona.ps/RouterFeederService").process(new Processor()
               {
                    public void process(Exchange e) {
                         System.out.println("INFO: found exchange "+e.getIn());
                         System.out.println("INFO: HELLO HELLO !!!!!!!!!!!");
                         
                    }
               }
               ).to("file:///Users/jcrean/Development/camel-smx-test-case/message_output");
      
      

       

      Any ideas?

       

      thanks

      Joe

        • 1. Re: InvalidPayloadException Camel running in ServiceMix
          ccustine

          The line "[Fatal Error] test.txt:1:1: Content is not allowed in prolog." usually means that the input is either not a valid xml file or is just a text file.  So if you wrap your text in some xml tags you should be fine.

           

          Chris

          • 2. Re: InvalidPayloadException Camel running in ServiceMix
            jcrean

            Hi, this certainly got rid of the fatal error but unfortunately I am still getting the InvalidPayloadException - I am a little unsure here because it looks like it actually doesnt like the xml, see below. Do I need to configure a marshaler in the xbean??

            thanks

            Joe

             

            INFO: found exchange JbiMessage: org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@36257c{properties: {org.apache.servicemix.file.name=test.txt, org.apache.servicemix.file.path=/Users/jcrean/Development/camel-smx-test-case/temp/test.txt}}
            INFO: HELLO HELLO !!!!!!!!!!!
            WARN  - ResolverUtil                   - Could not examine class 'org/apache/activemq/camel/component/ActiveMQComponent.class' due to a java.lang.NoClassDefFoundError with message: org/apache/camel/component/jms/JmsComponent
            WARN  - ResolverUtil                   - Could not examine class 'org/apache/activemq/camel/component/ActiveMQConfiguration.class' due to a java.lang.NoClassDefFoundError with message: org/apache/camel/component/jms/JmsConfiguration
            WARN  - ResolverUtil                   - Could not examine class 'org/apache/activemq/camel/component/JournalComponent.class' due to a java.lang.NoClassDefFoundError with message: org/apache/camel/impl/DefaultComponent
            WARN  - ResolverUtil                   - Could not examine class 'org/apache/activemq/camel/component/JournalEndpoint$1.class' due to a java.lang.NoClassDefFoundError with message: org/apache/camel/impl/DefaultConsumer
            WARN  - ResolverUtil                   - Could not examine class 'org/apache/activemq/camel/component/JournalEndpoint$3.class' due to a java.lang.NoClassDefFoundError with message: org/apache/camel/impl/DefaultProducer
            WARN  - ResolverUtil                   - Could not examine class 'org/apache/activemq/camel/component/JournalEndpoint.class' due to a java.lang.NoClassDefFoundError with message: org/apache/camel/impl/DefaultEndpoint
            ERROR - DeadLetterChannel              - On delivery attempt: 0 caught: org.apache.camel.InvalidPayloadException: No in body available of type: java.io.InputStream but has value: javax.xml.transform.dom.DOMSource@56ad3e of type: javax.xml.transform.dom.DOMSource on the exchange: Exchange[FileMessage: /Users/jcrean/Development/camel-smx-test-case/message_output]
            org.apache.camel.InvalidPayloadException: No in body available of type: java.io.InputStream but has value: javax.xml.transform.dom.DOMSource@56ad3e of type: javax.xml.transform.dom.DOMSource on the exchange: Exchange[FileMessage: /Users/jcrean/Development/camel-smx-test-case/message_output]
                 at org.apache.camel.util.ExchangeHelper.getMandatoryInBody(ExchangeHelper.java:100)
                 at org.apache.camel.component.file.FileProducer.process(FileProducer.java:62)
                 at org.apache.camel.component.file.FileProducer.process(FileProducer.java:58)
                 at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:59)
                 at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:157)
                 at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
                 at org.apache.servicemix.camel.CamelJbiEndpoint.processInOnly(CamelJbiEndpoint.java:64)
            

             

            • 3. Re: InvalidPayloadException Camel running in ServiceMix
              jstrachan

              I think you've just hit this issue namely that we don't currently have a Source -> InputStream translator yet.

               

              A workaround will be to convert to a String first.

               

              from("jbi:endpoint:whatever").convertBodyTo(String.class).to("file://something");
              

               

              • 4. Re: InvalidPayloadException Camel running in ServiceMix
                jcrean

                Hi Folks,

                unfortunately that didnt work out - did you maybe mean convertBodyTo(InputStream) .. I tried that too but to no avail - the exception remains exactly the same in both cases. If I understand the issue correctly then the problem lies with the fact that I am trying to write to a file. I dont really have to write to a file at all. I really just want to show a dynamic recipient list in action. However I keep losing time on the basic case without any routing - I already tried to write to a JMS queue but that gives me lots of problems with classloading in the JBI environment.

                thanks

                Joe

                • 5. Re: InvalidPayloadException Camel running in ServiceMix
                  ccustine

                  Hi Joe,

                  I'm not sure about the Camel issue writing to a file, but if you start trying to use JMS make sure that you add camel-jms to your camel SU pom.xml dependencies.  Each Camel component has its own jar file to keep things lightweight, so make sure you have the ones you need in your pom.xml.

                   

                  Chris