Tomcat classloader

Discussion in 'Java' started by Moiristo, Jun 21, 2006.

  1. Moiristo

    Moiristo Guest

    I have a web application that performs an XML transformation with an
    XSLT style sheet. It uses standard transformation classes from
    jax.xml.transform, Transformer and TransformerFactory. The result is
    saved in a StreamResult object.

    Strange thing is, the first time when I perform a transformation, the
    XSL (not the XML) Document is written to the StreamResult. On retry, it
    works fine. I think it has something to do with the Tomcat classloader.
    Does anyone have other ideas on this (and possibly, a solution)?
    Moiristo, Jun 21, 2006
    #1
    1. Advertising

  2. Moiristo wrote:

    > I have a web application that performs an XML transformation with an
    > XSLT style sheet. It uses standard transformation classes from
    > jax.xml.transform, Transformer and TransformerFactory. The result is
    > saved in a StreamResult object.
    >
    > Strange thing is, the first time when I perform a transformation, the
    > XSL (not the XML) Document is written to the StreamResult. On retry, it
    > works fine. I think it has something to do with the Tomcat classloader.

    Why do you think this? Is it a wild guess? Or did you run your
    web-application in *another* Java-web-server too, and you did *not* get the
    described strange behaviour there?

    > Does anyone have other ideas on this (and possibly, a solution)?

    Another reason might be a bug somewhere in your web-application (especially
    in using static variables).

    --
    "Thomas:Fritsch$ops.de".replace(':', '.').replace('$', '@')
    Thomas Fritsch, Jun 21, 2006
    #2
    1. Advertising

  3. Moiristo

    Moiristo Guest

    Thomas Fritsch wrote:
    > Another reason might be a bug somewhere in your web-application (especially
    > in using static variables).


    I create a pipeline that first collects the data in a class called
    DataManager. The XML and XSL documents are stored in a bean. After that,
    I call the transform function in another class (static method, see
    below). It seems to me that it's just a standard transformation. No
    exception is thrown. If I assume that the Transformer does its job, what
    else could it be then my wild guess?



    public static void transform(ReportOutput r) throws
    XSLTTransformException {

    Document XMLDoc = r.getXMLDoc();
    Document XSLDoc = r.getXSLTDoc();

    if(XSLDoc == null ) {
    r.setOutput(xmlToString(XMLDoc));
    return;
    }

    try {
    // Create a TransformerFactory
    TransformerFactory tFactory =
    TransformerFactory.newInstance();

    // Use the DOM XML Document to define a DOMSource object.
    DOMSource xmlDomSource = new DOMSource(XMLDoc);

    // Use the DOM XSL Document to define a DOMSource object.
    DOMSource xslDomSource = new DOMSource(XSLDoc);

    //Create a StringWriter to collect the output
    StringWriter sw = new StringWriter();

    // Create a StreamResult from the StringWriter
    StreamResult SResult = new StreamResult(sw);

    // Process the stylesheet DOMSource and generate a

    //Transformer.
    Transformer transformer =
    tFactory.newTransformer(xslDomSource);

    // Perform the transformation, placing the output in the
    //StreamResult.
    transformer.transform(xmlDomSource, SResult);

    r.setOutput(sw.getBuffer().toString());

    } catch (TransformerException e) {
    ModelUtils.log(e);
    throw new XSLTTransformException();
    }
    }
    Moiristo, Jun 21, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. Miguel

    classloader in tomcat

    Mr. Miguel, Jul 11, 2003, in forum: Java
    Replies:
    2
    Views:
    595
    Miguel De Anda
    Jul 14, 2003
  2. Replies:
    5
    Views:
    691
    Nigel Wade
    Jul 15, 2003
  3. Mikito Harakiri

    Tomcat ClassLoader/Compile nightmare

    Mikito Harakiri, Nov 6, 2003, in forum: Java
    Replies:
    0
    Views:
    332
    Mikito Harakiri
    Nov 6, 2003
  4. Mark F

    Tomcat classloader problem

    Mark F, Mar 5, 2004, in forum: Java
    Replies:
    0
    Views:
    476
    Mark F
    Mar 5, 2004
  5. Moiristo

    Tomcat classloader

    Moiristo, Jun 21, 2006, in forum: Java
    Replies:
    0
    Views:
    327
    Moiristo
    Jun 21, 2006
Loading...

Share This Page