Hi all,

        I have tried to generate a small piece of code that allow me to compile the 
XSP pages outside Cocoon runtime.
        I intend to compile all the xsp files during each build so that we can 
guarantee that everything is fine.

        In order to do that I am using:
                - org.apache.cocoon.generation.ServerPagesGenerator  class
                - I am invoking setup on the above class to indicate which file is to 
be compile among other emulated parameters, such as:
                        - objectModel: I create mock Context, Request, Session and 
Response using CommandLine-based implementations provided by Cocoon
                        - SourceResolver: I have implemented by own SourceResolver
                        - empty org.apache.avalon.framework.parameters.Parameters 
instance.
                - and finally (I haven't got here yet) invoke generate() to obtain the 
xml associated with it.

        This is a snippet of code I have been working on:

        ServerPagesGenerator spg = new ServerPagesGenerator();
        SourceResolver sr = new MySourceResolver();
        Map omb = createMockObjectModel();
        String xspFile = "myxsp.xsp";

        try {
            spg.setup(sr, omb.getObjectModel(contextPath), xspFile, new Parameters());
        }catch(Exception e) {
            e.printStackTrace();
        }


        However, I am getting a NullPointerException within ServerPagesGenerator 
class. My question is whether the mock environment I have tried to reproduce is 
faithful or not. Obviously it is not, but I wonder what is wrong with it.

        Any hint or advice is very welcome

        Thx

        Marcial



Reply via email to