cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ellis Pritchard (JIRA)" <>
Subject [jira] Created: (COCOON-2077) XModuleSource getInputStream() throws NPE
Date Mon, 18 Jun 2007 15:57:25 GMT
XModuleSource getInputStream() throws NPE

                 Key: COCOON-2077
             Project: Cocoon
          Issue Type: Bug
          Components: * Cocoon Core
    Affects Versions: 2.1.10, 2.1.9, 2.1.11-dev (Current SVN), 2.2-dev (Current SVN)
            Reporter: Ellis Pritchard
            Priority: Minor

I'm getting:

	at org.apache.cocoon.serialization.AbstractTextSerializer.getTransformerHandler(
	at org.apache.cocoon.serialization.XMLSerializer.setOutputStream(
	at org.apache.cocoon.components.source.impl.XModuleSource.getInputStream(
	at com.researchresearch.cocoon.generation.RESTfulServiceGenerator.doPOSTBody(
	at com.researchresearch.cocoon.generation.RESTfulServiceGenerator.generate(
	at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.processXMLPipeline(
	at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(
	at org.apache.cocoon.components.source.impl.SitemapSource.toSAX(
	at org.apache.cocoon.components.source.SourceUtil.toSAX(
	at org.apache.cocoon.components.source.SourceUtil.parse(
	at org.apache.cocoon.sitemap.ContentAggregator.generate(

When trying to use an xmodule: as the source for a custom generator.

[Cocoon BRANCH_2_1_X.]

Now admittedly, I'm not using it in a pure sitemap way, which would end up using the XMLizable
interface method, but I'm calling the (equally valid) Source method getInputStream() instead.

The offending code in org.apache.cocoon.components.source.impl.XModuleSource seems to be:

     * Return an <code>InputStream</code> object to read from the source.
     * @throws IOException if I/O error occured.
    // Stolen from QDoxSource
    public InputStream getInputStream() throws IOException, SourceException {
        if ( this.logger.isDebugEnabled() ) {
            this.logger.debug( "Getting InputStream for " + getURI() );

        // Serialize the SAX events to the XMLSerializer:

        XMLSerializer serializer = new XMLSerializer(); <!--- HERE: creates XMLSerializer,
but doesn't configure() it !! -->
        ByteArrayInputStream inputStream = null;

        try {
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream( 2048 );
            serializer.setOutputStream( outputStream );
            toSAX( serializer );
            inputStream = new ByteArrayInputStream( outputStream.toByteArray() );
        } catch ( SAXException se ) {
            logger.error( "SAX exception!", se );
            throw new SourceException( "Serializing SAX to a ByteArray failed!", se );

        return inputStream;

The serializer is created, but not configure()d, and it is only the configuration that sets
the TransformerFactory in, hence the NPE.

The causal change seems to have been made to AbstractTextSerializer yonks ago:

	23784 	3/19/03 5:37PM sylvain  Allow the TransformerFactory class to be specified in the

Before that revision the TransformerFactory was set in the constructor of AbstractTextSerializer,
thus it worked with the xmodule getInputStream() method before that change.

No compensating change is in XModuleSource (433543), so this has been broken since 2003.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message