Hi there,

thanks for your quick responses.
Here's a little bit code:

Attached you can find the CocoonFopSerializer which i got from a user in the 
fop-user mailing list. By the way, this class needs additional classes libs 
explicitly added to the build path. 
Then i registered/deregistered the Serializers in the Root-Sitemap like this:

<!--
<map:serializer name="fo2pdf" logger="sitemap.serializer.fo2pdf" 
mime-type="application/pdf" src="org.apache.cocoon.serialization.FOPSerializer">
        <user-config>cocoon://fop-config.xml</user-config>
</map:serializer>
-->

<map:serializer name="fo2pdf" mime-type="application/pdf" 
src="CocoonFOPSerializer">
        <set-content-length>false</set-content-length>
        <user-config>cocoon://fop-config.xml</user-config>
</map:serializer>

Kai, you mentioned i should  "deregister the old FOPSerializer from the fop 
block". how do i do that?

at last but not least i attached my local.blocks.properties files

greetings Matthias


----- Ursprüngliche Mail ----
Von: Kai Mutz <[EMAIL PROTECTED]>
An: [email protected]
Gesendet: Montag, den 16. Juli 2007, 18:38:37 Uhr
Betreff: RE: Replacing FOP Jars

I don't know which new special FopSerializer Matthias uses. I use the
FOPNGSerializer from cocoon 2.2dev (trunk).


[EMAIL PROTECTED] <> wrote:
> Kai
>
> Looks good but where does the new special FopSerializer come from?
>
>
>
> Robin Rigby
> [EMAIL PROTECTED]
> http://www.gondolier.org.uk
> 07785 765017
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: 16 July 2007 16:18
> To: [email protected]
> Subject: RE: Replacing FOP Jars
>
> [EMAIL PROTECTED] <> wrote:
>> Hi,
>> I try to get FOP 0.9x working with Cocoon 2.1.9. Therefore i
>> added a special FopSerializer class to my build path. That works.
>>
>> But when i put the 0.93 fop libs to the
>> lib directory and replace the new fop.jar with the old one, i receive
>> an initialization error: java.lang.ClassNotFoundException:
>> org.apache.cocoon.faces.samples.components.taglib.AreaTag
>
> I don't understand your replacements. You have to replace the old fop
> jar with the new (0.9.3) fop jar and add the
> xmlgraphics-commons-*.jar. Then you
> have to register the new special FopSerializer, which uses the
> new fop API,
> in your sitemap (and deregister the old FOPSerializer from the fop
> block).
>
> Furthermore it seems that the above exception has nothing to do with
> fop. How do you invoke the serializer? Can you post the snippet from
> sitemap?
>
>>
>> for me
>> it seams like an totally different thing. anyway, when i undo the
>> last step (replacing the fop jars) i still have the error. so, i
>> need to rebuild the whole cocoon project and then i works again, but
>> i'm still at the beginning of my problem :-\
>>
>> maybe i should try to use the latest
>> stable cocoon version. i use cocoon 2.1.9. do you have any
>> suggestions for the build settings? which blocks should be excluded
>> to avoid problems?
>>
>
> You should exclude all blocks first and include only those blocks
> you really
> need. I don't know version 2.1.9 but I don't think that there are
> blocks, which make problems per se.
>
> I have fop 0.9.3 installed in cocoon 2.1.8 and it works fine.
>
> Kai
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






      __________________________________  Alles was der Gesundheit und 
Entspannung dient. BE A BETTER MEDIZINMANN! www.yahoo.de/clever
/*
 * Created on 03.07.2006
 * 
 */

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;

import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.serialization.AbstractSerializer;
import org.apache.excalibur.source.SourceValidity;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;


/**
 * Cocoon FOP serializer implementpation.
 *
 * @author Arne Hildebrand 
 * @version 1.0
 */

public class CocoonFOPSerializer extends AbstractSerializer implements Configurable, CacheableProcessingComponent, Serviceable {

    protected Logger logger = null;

    protected String mimetype = null;

    protected boolean setContentLength = true;

    protected FOUserAgent userAgent = null;

    protected Fop fop = null;

    protected ServiceManager manager = null;

    protected javax.xml.transform.stream.StreamResult res = null;

    private FopFactory fopFactory = null;

    public void service(ServiceManager manager) throws ServiceException {
        this.manager = manager;
    }

    public void configure(Configuration conf) throws ConfigurationException {
        this.logger = getLogger().getChildLogger("fop");

        this.setContentLength = conf.getChild("set-content-length").getValueAsBoolean(true);
        this.mimetype = conf.getAttribute("mime-type");

        // TODO get and use user configuration
        // TODO get and use user's renderer definition, ...

    }

    public String getMimeType() {
        return this.mimetype;
    }

    public void setOutputStream(OutputStream o) {
        DefaultHandler dh = null;

        try {
            // get user agent & configure it
            userAgent = getFopFactory().newFOUserAgent();
            userAgent.setTargetResolution(150);
            userAgent.setCreator("http://www.link-lab.net";);

            // create new fop for transformation
            fop = fopFactory.newFop(this.getMimeType(), userAgent, o);
            dh = fop.getDefaultHandler();
            setContentHandler(dh);
        }
        catch (Exception ex) {
            ex.printStackTrace();

        }
    }

    private FopFactory getFopFactory() throws ConfigurationException, SAXException, IOException {
        if (fopFactory == null) {
            fopFactory = FopFactory.newInstance();
            // use custom config file if exists
            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
            File cfgFile = new File("conf/fop-config.xml");
            if (cfgFile.exists()) {
                Configuration cfg = cfgBuilder.buildFromFile(cfgFile);
                fopFactory.configure(cfg);
            }

        }
        return fopFactory;
    }

    public Serializable getKey() {
        return "0";
    }

    public SourceValidity getValidity() {
        return null; // NOPValidity.SHARED_INSTANCE;
    }

    public void recycle() {
        super.recycle();
        this.userAgent = null;
        this.fop = null;
    }

    public boolean shouldSetContentLength() {
        return this.setContentLength;
    }

}

Attachment: local.blocks.properties
Description: Binary data

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to