Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Tomcat classloader

Thread view: 
Moiristo - 21 Jun 2006 15:27 GMT
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)?
Thomas Fritsch - 21 Jun 2006 16:45 GMT
> I have a web application that performs an XML transformation with an
> XSLT style sheet. It uses standard transformation classes from
[quoted text clipped - 4 lines]
> 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).

Signature

"Thomas:Fritsch$ops.de".replace(':', '.').replace('$', '@')

Moiristo - 21 Jun 2006 19:14 GMT
> 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();
        }
    }


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.