Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

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

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

    Default JIRA Castor Created

    After to send some emails to the Castor committers

    A friendly person just created a Castor Jira account for me

    A JIRA account has been created for you at:

    https://jira.codehaus.org

    This is either because an administrator has created an account for you,
    or because you have been assigned to an issue.
    The JIRA created about Castor (done by myself) is
    https://jira.codehaus.org/browse/CASTOR-3145

    I hope this be reason of my situation about DOMResult, this was a weird day

    Best Regards Oleg
    - 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. #12
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,806

    Thumbs down Updated but no work DOMResult yet

    Hello Oleg

    A day of surprises. Really was not a bug. In JIRA Castor 1.3.1 is not available on MvnRepository
    Said

    Basically, the 'castor' artefact turns out to be the root POM of the complete project. If you are interested in e.g. XML data binding, please have a look at the castor-xml artefact, where you'll find all past releases.
    Wondered why a simple message was not included somewhere, anyway

    In Castor's mailing list I have the follow
    Castor 1.3.1 is not available on MvnRepository
    (seems Castor has a bug or its new 1.3.2 API has a new behaviour against 1.2, why?, see below my results)

    Therefore I changed from

    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>
    To only to

    Code:
    <dependency>
        <groupId>org.codehaus.castor</groupId>
        <artifactId>castor-xml</artifactId>
        <version>1.3.2</version>
    </dependency>
    I got the same exception working with castor-xml and DOMResult!

    Code:
    2011-07-12 12:41:40,296 INFO [org.springframework.integration.handler.LoggingHandler] - 
    <[Payload=javax.xml.transform.dom.DOMResult@14a7a12]
    [Headers={timestamp=1310492500296, id=fa7359ae-6384-4413-bc4b-1489603560be}]>
    
    2011-07-12 12:41:40,296 INFO [org.springframework.integration.handler.LoggingHandler] - 
    <[Payload=javax.xml.transform.dom.DOMResult@14a7a12]
    [Headers={timestamp=1310492500296, id=76f33ec9-05a3-4e9e-bbcf-66c000b4c2c8}]>
    
    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:866)
    
    Caused by: org.xml.sax.SAXParseException: 
    Content is not allowed in prolog.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    Now if I use this *Echo*

    Code:
    @Component
    public class EchoTransformer {
    
    	private static final Logger logger = LoggerFactory.getLogger(EchoTransformer.class);
    	
    	public Node showAsDOMNode(DOMResult domResult) {
    		Node node = domResult.getNode();
    		logger.info("*** asDOMNode");
    		System.out.println(node);
    		logger.info(node.toString());
    		logger.info("***");
    		return node;
    	}
    	public String showAsString(Object object) {
    		String string = object.toString();
    		System.out.println("** Log: Inside Transformer");
    		System.out.println(string);
    		logger.info("***");
    		return string;
    	}
    	
    }
    Therefore I must work now in this way (I just created an altern file to add these changes about the new Transformer and re order the input/ouput channels for each transformer)

    Code:
    <int-xml:marshalling-transformer 
                marshaller="castorMarshaller"
    	    result-type="DOMResult"
    	    input-channel="input"
    	    output-channel="xml"								 	
    	/>
    	 
    <int:transformer input-channel="xml"
    		       output-channel="dom"
    		       ref="echoTransformer"
    		       method="showAsDOMNode"
    	/>
    	 
    <int-xml:unmarshalling-transformer 
                unmarshaller="castorMarshaller"
    	    input-channel="xml-string"
    	    output-channel="output"
    />
    	
    <int:object-to-string-transformer 
                    input-channel="dom"
    		output-channel="xml-string" />
    I have the same exception shown above but showing now

    Code:
    2011-07-12 12:58:58,484 INFO [org.springframework.integration.handler.LoggingHandler] - 
    <[Payload=javax.xml.transform.dom.DOMResult@118fa47]
    [Headers={timestamp=1310493538484, id=8d81c1a1-65dc-424c-b49f-1fcf37fb6cf7}]>
    
    2011-07-12 12:58:58,500 INFO [com.manuel.jordan.main.transformers.echo.EchoTransformer] - 
    <*** asDOMNode>
    [#document: null]
    2011-07-12 12:58:58,500 INFO [com.manuel.jordan.main.transformers.echo.EchoTransformer] - 
    <[#document: null]>
    2011-07-12 12:58:58,500 INFO [com.manuel.jordan.main.transformers.echo.EchoTransformer] - 
    <***>
    2011-07-12 12:58:58,500 INFO 
    
    [org.springframework.integration.handler.LoggingHandler] - 
    <[Payload=[#document: null]]
    [Headers={timestamp=1310493538500, id=8c224986-af14-4a00-98dd-4360254cd34d}]>
    ... Rest of the same exception shown above in red
    Compare the second blue part shown above, with the second blue part shown below
    I mean

    Code:
    2011-07-12 12:41:40,296 INFO [org.springframework.integration.handler.LoggingHandler] - 
    <[Payload=javax.xml.transform.dom.DOMResult@14a7a12]
    [Headers={timestamp=1310492500296, id=76f33ec9-05a3-4e9e-bbcf-66c000b4c2c8}]>
    vs

    Code:
    [org.springframework.integration.handler.LoggingHandler] - 
    <[Payload=[#document: null]]
    [Headers={timestamp=1310493538500, id=8c224986-af14-4a00-98dd-4360254cd34d}]>
    Is null the DOMResult, why?

    Now with this update about the new dependency, StringResult no work anymore, please read the next post
    Last edited by dr_pompeii; Jul 12th, 2011 at 06:46 PM.
    - 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

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

    Thumbs down No work anymore StringResult

    In the Beginning of this Thread

    I shared

    Code:
    <int-xml:marshalling-transformer 
                marshaller="castorMarshaller"
    	    result-type="StringResult"
    	    input-channel="input"
    	    output-channel="xml"									 								 	
    	/>
    ...
    <int:channel id="xml">
    	<int:interceptors>
    		<int:wire-tap channel="logger01"/>
    	</int:interceptors>
    </int:channel>
    ...
    
    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 got ( 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, working really well with

    Code:
    <dependency>
      	<groupId>org.codehaus.castor</groupId>
        	<artifactId>castor</artifactId>
        	<version>1.2</version>
    </dependency>				
    <dependency>
        	<groupId>xerces</groupId>
        	<artifactId>xercesImpl</artifactId>
        	<version>2.9.1</version>
    </dependency>

    But now the same code shown above, but now only changing the maven dependency to work with the last version available (the shown below, replace both shown above)

    Code:
    <dependency>
       	<groupId>org.codehaus.castor</groupId>
        	<artifactId>castor-xml</artifactId>
        	<version>1.3.2</version>
    </dependency>
    I got now ( I am changing the presentation to let show the output friendly)
    (Recall I am working with StringResult)

    Code:
    2011-07-12 13:39:21,437 INFO [org.springframework.integration.handler.LoggingHandler] - 
    <[Payload=<?xml version="1.0" encoding="UTF-8"?>
    <cliente>
    <apellidos>Jordan</apellidos>
    <fecha-nacimiento>2011-07-12T13:39:21.265-05:00</fecha-nacimiento><nombres>Manuel</nombres>
    <peso>70.01</peso>
    <edad>30</edad>
    <credito>150.85</credito>
    </cliente>]
    [Headers={timestamp=1310495961437, id=73efd912-3db3-4018-b628-b515908d7778}]>
    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: 
    The class for the root element 'cliente' could not be found.{File: [not available]; line: 2; column: 10}
    at org.springframework.oxm.castor.CastorMarshaller.convertCastorException(CastorMarshaller.java:487)
    ....
    Caused by: org.exolab.castor.xml.MarshalException: 
    The class for the root element 'cliente' could not be found.{File: [not available]; line: 2; column: 10}
    	at org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:866)
    ...
    Caused by: org.xml.sax.SAXException: 
    The class for the root element 'cliente' could not be found.
    	at org.exolab.castor.xml.UnmarshalHandler.processFirstElement(UnmarshalHandler.java:890)
    I assume, is it a bug, right? or some extra configuration now is madatory here

    Code:
    @Bean
    public CastorMarshaller castorMarshaller(){
    	return new CastorMarshaller();
    }
    I am out of ideas

    Thanks in advanced for your support
    Last edited by dr_pompeii; Jul 12th, 2011 at 06:44 PM.
    - 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. #14
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,853

    Default

    Spring 3.0.5 is not intended to work with Castor 1.3.2. If you look in the POM, you will see version 1.2: http://repo1.maven.org/maven2/org/sp....5.RELEASE.pom

    If you want to use Castor 1.3.2, you will need to use Spring 3.1 (currently at Milestone 2). Spring Integration will not *officially* support Spring 3.1 until Spring Integration's own 2.1 version. We will have an initial milestone of 2.1 very soon (likely in August).

    -Mark

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

    Exclamation DOMResult is not working for both versions

    Hello Mark

    Thank you for your concrete and valuable information, really I appreciate

    Spring 3.0.5 is not intended to work with Castor 1.3.2. If you look in the POM, you will see version 1.2: http://repo1.maven.org/maven2/org/sp....5.RELEASE.pom
    Interesting, I arrived here through the Maven Central searching with the term spring-oxm. More detailed information and other style presentation is used

    Furthermore spring-oxm is a transitive dependency from spring-core. I did realize it belong before to Spring Web Services 1.5.x API

    If you want to use Castor 1.3.2, you will need to use Spring 3.1 (currently at Milestone 2). Spring Integration will not *officially* support Spring 3.1 until Spring Integration's own 2.1 version. We will have an initial milestone of 2.1 very soon (likely in August).
    Mmm, I see, I must wait

    OK, then I must use again

    Code:
    <dependency>
        	<groupId>org.codehaus.castor</groupId>
        	<artifactId>castor</artifactId>
        	<version>1.2</version>
    </dependency>				
    <dependency>
     	<groupId>xerces</groupId>
        	<artifactId>xercesImpl</artifactId>
        	<version>2.9.1</version>
    </dependency>
    Therefore working with StringResult my code work again, but with DOMResult I have the problem yet

    Code:
    2011-07-12 12:58:58,484 INFO [org.springframework.integration.handler.LoggingHandler] - 
    <[Payload=javax.xml.transform.dom.DOMResult@118fa47]
    [Headers={timestamp=1310493538484, id=8d81c1a1-65dc-424c-b49f-1fcf37fb6cf7}]>
    
    2011-07-12 12:58:58,500 INFO [com.manuel.jordan.main.transformers.echo.EchoTransformer] - 
    <*** asDOMNode>
    [#document: null]
    2011-07-12 12:58:58,500 INFO [com.manuel.jordan.main.transformers.echo.EchoTransformer] - 
    <[#document: null]>
    2011-07-12 12:58:58,500 INFO [com.manuel.jordan.main.transformers.echo.EchoTransformer] - 
    <***>
    2011-07-12 12:58:58,500 INFO 
    
    [org.springframework.integration.handler.LoggingHandler] - 
    <[Payload=[#document: null]]
    [Headers={timestamp=1310493538500, id=8c224986-af14-4a00-98dd-4360254cd34d}]>
    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 would I do?

    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

Posting Permissions

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