[jdom-interest] Sealing violation

Steven Smith ssmith at neonsys.com
Thu Mar 8 10:10:36 PST 2001


What's the classpath look like for this servlet?

-----Original Message-----
From: JStalnecker at idssinfo.com [mailto:JStalnecker at idssinfo.com]
Sent: Thursday, March 08, 2001 10:39 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] Sealing violation


I have just come across the jdom product thru an article on www.onjava.com
at http://www.onjava.com/pub/a/onjava/2000/12/15/xslt_servlets.html.  I
have made some changes the servlet and class.  I am also using my own XSL.
When I run my servlet(code below) I get the following error:

java.lang.ClassNotFoundException: class JDomServlet2 :
java.lang.SecurityException: sealing violation
           at java.beans.Beans.instantiate(Beans.java:215)
           at java.beans.Beans.instantiate(Beans.java:55)
           at
com.caucho.server.http.Application.loadServlet(Application.java:1244)
           at
com.caucho.server.http.Invocation.getServlet(Invocation.java:292)
           at
com.caucho.server.http.AbstractRequest.service(AbstractRequest.java:409)
           at
com.caucho.server.http.AbstractRequest.service(AbstractRequest.java:393)
           at
com.caucho.server.http.PageCache$Entry.service(PageCache.java:252)
           at com.caucho.server.http.PageCache.service(PageCache.java:103)
           at
com.caucho.server.http.VirtualHost.service(VirtualHost.java:395)
           at com.caucho.server.http.Request.dispatch(Request.java:211)
           at
com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:201)
           at
com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java,
Compiled Code)
           at com.caucho.server.TcpConnection.run(TcpConnection.java,
Compiled Code)
           at java.lang.Thread.run(Thread.java:479)


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.xalan.xslt.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;

public class JDomServlet2 extends HttpServlet {
    // reuse the same processor over and over
    private XSLTProcessor processor = XSLTProcessorFactory.getProcessor(
            new org.apache.xalan.xpath.xdom.XercesLiaison());

          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 xsltURL = request.getParameter("xsltURL");
                    // read the XSLT stylesheet and cache it for future
reuse
            InputStream xsltStream = context.getResourceAsStream(xsltURL);
            StylesheetRoot parsedStylesheet = processor.processStylesheet(
                    new XSLTInputSource(xsltStream));
            processor.setStylesheet(parsedStylesheet);

            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);

            // transform the XML into HTML
            processor.process(new XSLTInputSource(domDoc),
                              null,  // use pre-compiled stylesheet
                              new XSLTResultTarget(response.getWriter()));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

import java.io.*;
import org.jdom.*;
import org.jdom.output.*;
import com.sun.java.util.collections.*;

/**
 * Example of an object that knows how to represent itself as
 * XML using JDOM.
 *
 * @author Eric M. Burke
 */
public class CustomerInfo implements Serializable {
    private String number;
    private String address1;
    private String address2;
    private String address3;
     private String city;
     private String state;
     private String zip;

    // transient fields are not serialized.  This prevents the potential
    // overhead of sending too much data between an EJB and the web tier
    private transient Document doc = null;
    private transient Element elem = null;

    /**
     * Construct a new data object.
     */
    public CustomerInfo(String number, String address1, String address2,
            String address3, String city, String state, String zip) {
        this.number = number;
        this.address1 = address1;
        this.address2 = address2;
        this.address3 = address3;
          this.city = city;
          this.state = state;
          this.zip = zip;
    }

    /**
     * @return the contents of this object as an XML document.
     */
   public Document getDocument() {
       if (this.doc == null) {
           this.doc = new Document(getElement());
        }
        return this.doc;
    }

    /**
     * This method makes it possible to easily embed the output from
     * this data object into some other larger XML document.
     *
     * @return the contents of this object as an Element, which is just
     * the root element without the XML declaration.
     */
    public Element getElement() {
        if (this.elem == null) {
            this.elem = new Element("Customer");
               this.elem = new Element("BillTo");
               this.elem.addContent(new Element
("BillTo").setText(this.number))
               .addContent(new Element("Number").setText(this.number))
                .addContent(new Element("Address1").setText(this.address1))
                .addContent(new Element("Address2").setText(this.address2))
                .addContent(new Element("Address3").setText(this.address3))
                    .addContent(new Element("City").setText(this.city))
                    .addContent(new Element("State").setText(this.state))
                    .addContent(new Element("Zip").setText(this.zip));
        }
        return this.elem;
    }

    /**
     * A simple test program.
     */
    public static void main(String[] args) throws IOException {
        // create an object
        CustomerInfo ci = new CustomerInfo("100014", "1234",
                "111-222-333", "05/2000", "ewrwer", "qwe", "2414");

        // convert to XML, then format with two space indent
        Document doc = ci.getDocument();
        new XMLOutputter("  ", true).output(doc, System.out);
    }
}

This is my first attempt at using XML,XSL,XSLT,JDOM, etc. any help would be
greatly appreciated.

Thanks,
Joy

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20010308/2773151a/attachment.htm


More information about the jdom-interest mailing list