FW: [jdom-interest] Sealing violation

JStalnecker at idssinfo.com JStalnecker at idssinfo.com
Thu Mar 8 11:59:24 PST 2001


My JDomServlet2 is not part of a package, however I have written another
servlet trying to the same thing in a different way.  I have included the
source below, it uses the same CustomerInfo.class.

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.xalan.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.dom.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;


public class JDomServlet extends HttpServlet {

     ServletContext context = null;

    // initialize the Servlet.  This code is executed once.
    public void init(ServletConfig config) throws ServletException {
        super.init(config);

        context = config.getServletContext();
    }

    // handle a single request from the client
    public void doGet(HttpServletRequest request,
            HttpServletResponse response) throws IOException,
            ServletException {

               try
               {

               HttpSession session = request.getSession(true);
               String xslURL = request.getParameter("xslURL");
               System.out.println("inside servlet");
            response.setContentType("text/html");

            // in a real app, the CreditInfo object would be retrieved
            // from an EJB component
               CustomerInfo ci = new CustomerInfo("100014", "123 Main
Street", "Suite 12345",
                    "This is the third address line", "Reading", "PA",
"19607");

            // convert the JDOM into DOM
            Document jdomDoc = ci.getDocument();

            org.w3c.dom.Document domDoc =
                    new DOMOutputter().output(jdomDoc);

               TransformerFactory tFactory = TransformerFactory.newInstance
();

    if (tFactory.getFeature(DOMSource.FEATURE) &&
tFactory.getFeature(StreamResult.FEATURE))
    {


     // Use the TransformerFactory to instantiate a Transformer that will
work with
     // the stylesheet you specify. This method call also processes the
stylesheet
  // into a compiled Templates object.
     Transformer transformer = tFactory.newTransformer(new
StreamSource(xslURL));

     // Use the Transformer to apply the associated Templates object to an
XML document
     // (foo.xml) and write the output to a file (foo.out).
     transformer.transform(new DOMSource(domDoc), new
StreamResult(response.getWriter()));
     }
    } catch (Exception ex) {
                  ex.printStackTrace();
    }
    }
}

The funny thing is that this servlet also produces a sealing violation,
however it manifests itself differently.  I have highlighted the statement
that produces the error.  When JDomServlet is run, the before mentioned
error appears in the browser window.  When JDomServlet is run (I am running
both servlets on Resin1.1),  the below error is produced in the DOS prompt
associated with Resin.

 org.jdom.JDOMException: Exception outputting Document: sealing violation
     at org.jdom.output.DOMOutputter.output<DOMOutputter.java, compiled
code>
     at JDomServlet.doGet<JDomServlet.java:50>
     etc..
Root cause: java.lang.SecurityException: sealing violation
etc...


Thanks again for all your help,
Joy






More information about the jdom-interest mailing list