Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Problem with DOMResult - Content is not allowed in prolog

  1. #1
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default Problem with DOMResult - Content is not allowed in prolog

    Hello Guys

    I have the follow code (match the colors yourself for a better understanding)

    Code:
    @Component
    public class Cliente  {	
    	
    	private static final long serialVersionUID = 1L;
    	
    	private String nombres;
    	private String apellidos;
    	private Integer edad;
    	private Double peso;
    	private BigDecimal credito;
    	private Date fechaNacimiento;
    	
    	public Cliente(){
    		
    	}
            ... setters/getters and toString()
    }
    
    @Bean
    public CastorMarshaller castorMarshaller(){
    	return new CastorMarshaller();
    }
    
    <int-xml:marshalling-transformer 
                marshaller="castorMarshaller"
    	    result-type="StringResult"
    	    input-channel="input"
    	    output-channel="xml"									 								 	
    	/>
    	
    <int-xml:unmarshalling-transformer 
                unmarshaller="castorMarshaller"
    	    input-channel="xml-string"
    	    output-channel="output"
    	/>
    	
    <int:object-to-string-transformer 
          input-channel="xml"
          output-channel="xml-string" />
    
    ...
    
    <int:channel id="xml">
    	<int:interceptors>
    		<int:wire-tap channel="logger01"/>
    	</int:interceptors>
    </int:channel>
    The code work , in my Main class I have

    Code:
    MessageChannel input = context.getBean("input", MessageChannel.class );
    PollableChannel output = context.getBean("output", PollableChannel.class );
    	
    Cliente cliente = new Cliente();		
    cliente.setNombres("Manuel");
    cliente.setApellidos("Jordan");		
    cliente.setEdad(30);		
    cliente.setPeso(70.01);
    cliente.setCredito(new BigDecimal("150.85"));
    cliente.setFechaNacimiento( new Date());
    
    Message<?> messageAltern01 = MessageBuilder.withPayload(cliente).build();
    input.send(messageAltern01);
    		
    Message<?> replyAltern01 = output.receive();		
    logger.info("Mensaje Recibido replyAltern01.toString(){}", replyAltern01.toString());
    I can confirm through the logging-channel-adapter and wire-tap the follow ( I am changing the presentation to let show the output friendly)

    Code:
    2011-07-11 12:19:30,329 INFO [org.springframework.integration.handler.LoggingHandler] - 
    <[Payload=<?xml version="1.0" encoding="UTF-8"?>
    <cliente>
    <apellidos>Jordan</apellidos>
    <fecha-nacimiento>2011-07-11T12:19:29.923-05:00</fecha-nacimiento><nombres>Manuel</nombres>
    <peso>70.01</peso>
    <edad>30</edad>
    <credito>150.85</credito>
    </cliente>]
    [Headers={timestamp=1310404770329, 
    id=4c20555b-0e1b-4292-bdd9-4baa3d99e449}]>
    Therefore the transformation is well done

    The problem is if I change only one line

    Code:
    <int-xml:marshalling-transformer 
                marshaller="castorMarshaller"
    	    result-type="DOMResult"
    	    input-channel="input"
    	    output-channel="xml"								 	
    	/>
    DOMResult is the default used by Spring Integration

    I get this output error ( I am changing the presentation to let show the output friendly)

    Code:
    ...
    2011-07-11 12:28:34,563 INFO [org.springframework.integration.handler.LoggingHandler] - 
    <[Payload=javax.xml.transform.dom.DOMResult@179953c]
    [Headers={timestamp=1310405314563, id=87444587-14d3-41a8-b15b-439d6e44f1c8}]>
    
    2011-07-11 12:28:34,563 INFO [org.springframework.integration.handler.LoggingHandler] - 
    <[Payload=javax.xml.transform.dom.DOMResult@179953c]
    [Headers={timestamp=1310405314563, id=d5fae7c1-42a8-4022-8d59-c658e8f87cf3}]>
    
    Exception in thread "main" org.springframework.integration.transformer.MessageTransformationException: 
    failed to transform message
    	at org.springframework.integration.transformer.AbstractTransformer.transform(AbstractTransformer.java:44)
    ...
    
    Caused by: org.springframework.oxm.UnmarshallingFailureException: 
    Castor unmarshalling exception; nested exception is 
    org.exolab.castor.xml.MarshalException: 
    Content is not allowed in prolog.{File: [not available]; line: 1; column: 1}
    	at org.springframework.oxm.castor.CastorMarshaller.convertCastorException(CastorMarshaller.java:487)
    ...
    
    Caused by: org.exolab.castor.xml.MarshalException: 
    Content is not allowed in prolog.{File: [not available]; line: 1; column: 1}
    	at org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:761)
    ...
    
    Caused by: org.xml.sax.SAXParseException: 
    Content is not allowed in prolog.
    	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    What is wrong or missing on my Configuration?, it could be this be a bug?

    Bear in mind I just changed StringResult to DOMResult

    Thanks in advanced
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    it seems like Castor has problem with your XML

    org.exolab.castor.xml.MarshalException:
    Content is not allowed in prolog.{File: [not available]; line: 1; column: 1}

    Could you try to create DOMResult and send it to Castor outside of SI, just to verify?

  3. #3
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello Oleg

    Thanks again for the reply


    it seems like Castor has problem with your XML
    Seems yes or perhaps is org.springframework.oxm.castor.CastorMarshaller

    I am working with

    Code:
    <!-- Castor -->
    <dependency>
    	<groupId>org.codehaus.castor</groupId>
     	<artifactId>castor</artifactId>
        	<version>1.2</version>
    </dependency>
    <!-- Castor - Xerces -->		
    <dependency>
        	<groupId>xerces</groupId>
        	<artifactId>xercesImpl</artifactId>
        	<version>2.9.1</version>
    </dependency>
    The last availables for each one

    Could you try to create DOMResult and send it to Castor outside of SI, just to verify?
    Something similar to this?

    Code:
    public class EchoTransformer {
    
    	public Node asDOMNode(DOMResult o) {
    		Node node = o.getNode();
    		System.out.println("** Log: Inside Transformer");
    		System.out.println(node);
    		System.out.println("**");
    		return node;
    	}
    	public String asString(Object o) {
    		String str = o.toString();
    		System.out.println("** Log: Inside Transformer");
    		System.out.println(str);
    		System.out.println("**");
    		return str;
    	}
    }
    I am taking referencing from this thread, If I am wrong pls let me know
    Thread: marshalling-transformer returns null for DOMResult and xml for StringResult

    Thank you
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  4. #4
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Well, i still think its your XML as it all comes down to this:

    Caused by: org.xml.sax.SAXParseException:
    Content is not allowed in prolog.
    at org.apache.xerces.util.ErrorHandlerWrapper.createS AXParseException(Unknown Source)

    Why do you need to specify xerses dependency in the first place? Its part of JDK since 1.5 right?

  5. #5
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello Oleg

    Well, i still think its your XML as it all comes down to this:
    Agree

    Why do you need to specify xerses dependency in the first place? Its part of JDK since 1.5 right?
    I am working with STS 2.6.1 and using jdk1.6.0_21

    I though like you about only adding the Castor dependency but I receive this exception when I try to run my application

    Code:
    Caused by: java.lang.RuntimeException: 
    Could not instantiate serializer org.apache.xml.serialize.XMLSerializer: 
    java.lang.ClassNotFoundException: org.apache.xml.serialize.XMLSerializer
      at org.exolab.castor.xml.XercesSerializer.<init>(XercesSerializer.java:50)
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  6. #6
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Can you try to upgrade to castor 1.3.2 ?

  7. #7
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello Oleg

    Can you try to upgrade to castor 1.3.2 ?
    I tried but we have a problem, STS use MvnRepository

    And from there doing a simple search with org.codehaus.castor pattern
    and selecting from the result list

    Castor
    org.codehaus.castor » castor
    I go to

    home » org.codehaus.castor » castor

    Where is shown

    Code:
    Available versions
    
    Version      Type               Download
    1.3.2        release 	        Binary (0 bytes)
    1.3.1        release 	        Binary (0 bytes)
    1.3.0.1      release 	        Binary (0 bytes)
    1.3          release 	        Binary (0 bytes)
    1.3rc1       release candidate 	Binary (0 bytes)
    1.2          release 	        Binary (845 KB) 
    Therefore if I select 1.3.2 my STS output console show

    Code:
    11/07/11 01:16:32 PM COT: Missing artifact org.codehaus.castor:castor:jar:1.3.2:compile
    11/07/11 11:28:53 AM COT: Downloaded http://repository.codehaus.org/com/springsource/bundlor/com.springsource.bundlor.maven/1.0.0.RELEASE/com.springsource.bundlor.maven-1.0.0.RELEASE.pom
    11/07/11 11:28:53 AM COT: [WARN] The POM for com.springsource.bundlor:com.springsource.bundlor.maven:jar:1.0.0.RELEASE is missing, no dependency information available
    11/07/11 12:19:28 PM COT: [WARN] The POM for com.springsource.bundlor:com.springsource.bundlor.maven:jar:1.0.0.RELEASE is missing, no dependency information available
    11/07/11 12:28:32 PM COT: [WARN] The POM for com.springsource.bundlor:com.springsource.bundlor.maven:jar:1.0.0.RELEASE is missing, no dependency information available
    11/07/11 12:32:20 PM COT: [WARN] The POM for com.springsource.bundlor:com.springsource.bundlor.maven:jar:1.0.0.RELEASE is missing, no dependency information available
    11/07/11 12:33:02 PM COT: [WARN] The POM for com.springsource.bundlor:com.springsource.bundlor.maven:jar:1.0.0.RELEASE is missing, no dependency information available
    11/07/11 01:16:30 PM COT: Refreshing [/integrationtransformationsenrichment/pom.xml]
    11/07/11 01:16:32 PM COT: Downloaded http://repo1.maven.org/maven2/org/codehaus/castor/castor/1.3.2/castor-1.3.2.jar
    Thats why I use 1.2

    How I should handle this?
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  8. #8
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Strange, i got the same error
    Could you place a question on Castor mailing list http://www.castor.org/news.html and see what they say?

  9. #9
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Strange, i got the same error
    Could you place a question on Castor mailing list http://www.castor.org/news.html and see what they say?
    OK, it will be done, I will share the reply here

    Best Regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  10. #10
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Angry Problems

    I have problems

    I already did my subscription to http://xircles.codehaus.org/ which is required to send emails to

    • user@castor.codehaus.org - User mailing list
    • dev@castor.codehaus.org - Development mailing list


    But I always got


    Hi. This is the qmail-send program at mail.codehaus.org.
    I'm afraid I wasn't able to deliver your message to the following addresses.
    This is a permanent error; I've given up. Sorry it didn't work out.

    <dev@castor.codehaus.org>:
    Sorry, only subscribers may post. If you are a subscriber, please forward this message to dev-owner@castor.codehaus.org to get your new address included. (#5.7.2)
    and

    Hi. This is the qmail-send program at mail.codehaus.org.
    I'm afraid I wasn't able to deliver your message to the following addresses.
    This is a permanent error; I've given up. Sorry it didn't work out.

    <user@castor.codehaus.org>:
    Sorry, only subscribers may post. If you are a subscriber, please forward this message to user-owner@castor.codehaus.org to get your new address included. (#5.7.2)
    I already sent to the two emails suggested but none reply yet

    Even I sent an email to two committers and nothing

    This is out of my hands
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •