<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [jdom-interest] Sealing violation</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>What's the classpath look like for this servlet?</FONT>
</P>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: JStalnecker@idssinfo.com [<A HREF="mailto:JStalnecker@idssinfo.com">mailto:JStalnecker@idssinfo.com</A>]</FONT>
<BR><FONT SIZE=2>Sent: Thursday, March 08, 2001 10:39 AM</FONT>
<BR><FONT SIZE=2>To: jdom-interest@jdom.org</FONT>
<BR><FONT SIZE=2>Subject: [jdom-interest] Sealing violation</FONT>
</P>
<BR>
<P><FONT SIZE=2>I have just come across the jdom product thru an article on www.onjava.com</FONT>
<BR><FONT SIZE=2>at <A HREF="http://www.onjava.com/pub/a/onjava/2000/12/15/xslt_servlets.html" TARGET="_blank">http://www.onjava.com/pub/a/onjava/2000/12/15/xslt_servlets.html</A>. I</FONT>
<BR><FONT SIZE=2>have made some changes the servlet and class. I am also using my own XSL.</FONT>
<BR><FONT SIZE=2>When I run my servlet(code below) I get the following error:</FONT>
</P>
<P><FONT SIZE=2>java.lang.ClassNotFoundException: class JDomServlet2 :</FONT>
<BR><FONT SIZE=2>java.lang.SecurityException: sealing violation</FONT>
<BR><FONT SIZE=2> at java.beans.Beans.instantiate(Beans.java:215)</FONT>
<BR><FONT SIZE=2> at java.beans.Beans.instantiate(Beans.java:55)</FONT>
<BR><FONT SIZE=2> at</FONT>
<BR><FONT SIZE=2>com.caucho.server.http.Application.loadServlet(Application.java:1244)</FONT>
<BR><FONT SIZE=2> at</FONT>
<BR><FONT SIZE=2>com.caucho.server.http.Invocation.getServlet(Invocation.java:292)</FONT>
<BR><FONT SIZE=2> at</FONT>
<BR><FONT SIZE=2>com.caucho.server.http.AbstractRequest.service(AbstractRequest.java:409)</FONT>
<BR><FONT SIZE=2> at</FONT>
<BR><FONT SIZE=2>com.caucho.server.http.AbstractRequest.service(AbstractRequest.java:393)</FONT>
<BR><FONT SIZE=2> at</FONT>
<BR><FONT SIZE=2>com.caucho.server.http.PageCache$Entry.service(PageCache.java:252)</FONT>
<BR><FONT SIZE=2> at com.caucho.server.http.PageCache.service(PageCache.java:103)</FONT>
<BR><FONT SIZE=2> at</FONT>
<BR><FONT SIZE=2>com.caucho.server.http.VirtualHost.service(VirtualHost.java:395)</FONT>
<BR><FONT SIZE=2> at com.caucho.server.http.Request.dispatch(Request.java:211)</FONT>
<BR><FONT SIZE=2> at</FONT>
<BR><FONT SIZE=2>com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:201)</FONT>
<BR><FONT SIZE=2> at</FONT>
<BR><FONT SIZE=2>com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java,</FONT>
<BR><FONT SIZE=2>Compiled Code)</FONT>
<BR><FONT SIZE=2> at com.caucho.server.TcpConnection.run(TcpConnection.java,</FONT>
<BR><FONT SIZE=2>Compiled Code)</FONT>
<BR><FONT SIZE=2> at java.lang.Thread.run(Thread.java:479)</FONT>
</P>
<BR>
<P><FONT SIZE=2>import java.io.*;</FONT>
<BR><FONT SIZE=2>import javax.servlet.*;</FONT>
<BR><FONT SIZE=2>import javax.servlet.http.*;</FONT>
<BR><FONT SIZE=2>import org.apache.xalan.xslt.*;</FONT>
<BR><FONT SIZE=2>import org.jdom.*;</FONT>
<BR><FONT SIZE=2>import org.jdom.input.*;</FONT>
<BR><FONT SIZE=2>import org.jdom.output.*;</FONT>
</P>
<P><FONT SIZE=2>public class JDomServlet2 extends HttpServlet {</FONT>
<BR><FONT SIZE=2> // reuse the same processor over and over</FONT>
<BR><FONT SIZE=2> private XSLTProcessor processor = XSLTProcessorFactory.getProcessor(</FONT>
<BR><FONT SIZE=2> new org.apache.xalan.xpath.xdom.XercesLiaison());</FONT>
</P>
<P><FONT SIZE=2> ServletContext context = null;</FONT>
</P>
<P><FONT SIZE=2> // initialize the Servlet. This code is executed once.</FONT>
<BR><FONT SIZE=2> public void init(ServletConfig config) throws ServletException {</FONT>
<BR><FONT SIZE=2> super.init(config);</FONT>
</P>
<P><FONT SIZE=2> context = config.getServletContext();</FONT>
</P>
<BR>
<P><FONT SIZE=2> }</FONT>
</P>
<P><FONT SIZE=2> // handle a single request from the client</FONT>
<BR><FONT SIZE=2> public void doGet(HttpServletRequest request,</FONT>
<BR><FONT SIZE=2> HttpServletResponse response) throws IOException,</FONT>
<BR><FONT SIZE=2> ServletException {</FONT>
<BR><FONT SIZE=2> try {</FONT>
<BR><FONT SIZE=2> HttpSession session = request.getSession(true);</FONT>
<BR><FONT SIZE=2> String xsltURL = request.getParameter("xsltURL");</FONT>
<BR><FONT SIZE=2> // read the XSLT stylesheet and cache it for future</FONT>
<BR><FONT SIZE=2>reuse</FONT>
<BR><FONT SIZE=2> InputStream xsltStream = context.getResourceAsStream(xsltURL);</FONT>
<BR><FONT SIZE=2> StylesheetRoot parsedStylesheet = processor.processStylesheet(</FONT>
<BR><FONT SIZE=2> new XSLTInputSource(xsltStream));</FONT>
<BR><FONT SIZE=2> processor.setStylesheet(parsedStylesheet);</FONT>
</P>
<P><FONT SIZE=2> response.setContentType("text/html");</FONT>
</P>
<P><FONT SIZE=2> // in a real app, the CreditInfo object would be retrieved</FONT>
<BR><FONT SIZE=2> // from an EJB component</FONT>
<BR><FONT SIZE=2> CustomerInfo ci = new CustomerInfo("100014", "123 Main</FONT>
<BR><FONT SIZE=2>Street", "Suite 12345",</FONT>
<BR><FONT SIZE=2> "This is the third address line", "Reading", "PA",</FONT>
<BR><FONT SIZE=2>"19607");</FONT>
</P>
<BR>
<P><FONT SIZE=2> // convert the JDOM into DOM</FONT>
<BR><FONT SIZE=2> Document jdomDoc = ci.getDocument();</FONT>
<BR><FONT SIZE=2> org.w3c.dom.Document domDoc =</FONT>
<BR><FONT SIZE=2> new DOMOutputter().output(jdomDoc);</FONT>
</P>
<P><FONT SIZE=2> // transform the XML into HTML</FONT>
<BR><FONT SIZE=2> processor.process(new XSLTInputSource(domDoc),</FONT>
<BR><FONT SIZE=2> null, // use pre-compiled stylesheet</FONT>
<BR><FONT SIZE=2> new XSLTResultTarget(response.getWriter()));</FONT>
<BR><FONT SIZE=2> } catch (Exception ex) {</FONT>
<BR><FONT SIZE=2> ex.printStackTrace();</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2>}</FONT>
</P>
<P><FONT SIZE=2>import java.io.*;</FONT>
<BR><FONT SIZE=2>import org.jdom.*;</FONT>
<BR><FONT SIZE=2>import org.jdom.output.*;</FONT>
<BR><FONT SIZE=2>import com.sun.java.util.collections.*;</FONT>
</P>
<P><FONT SIZE=2>/**</FONT>
<BR><FONT SIZE=2> * Example of an object that knows how to represent itself as</FONT>
<BR><FONT SIZE=2> * XML using JDOM.</FONT>
<BR><FONT SIZE=2> *</FONT>
<BR><FONT SIZE=2> * @author Eric M. Burke</FONT>
<BR><FONT SIZE=2> */</FONT>
<BR><FONT SIZE=2>public class CustomerInfo implements Serializable {</FONT>
<BR><FONT SIZE=2> private String number;</FONT>
<BR><FONT SIZE=2> private String address1;</FONT>
<BR><FONT SIZE=2> private String address2;</FONT>
<BR><FONT SIZE=2> private String address3;</FONT>
<BR><FONT SIZE=2> private String city;</FONT>
<BR><FONT SIZE=2> private String state;</FONT>
<BR><FONT SIZE=2> private String zip;</FONT>
</P>
<P><FONT SIZE=2> // transient fields are not serialized. This prevents the potential</FONT>
<BR><FONT SIZE=2> // overhead of sending too much data between an EJB and the web tier</FONT>
<BR><FONT SIZE=2> private transient Document doc = null;</FONT>
<BR><FONT SIZE=2> private transient Element elem = null;</FONT>
</P>
<P><FONT SIZE=2> /**</FONT>
<BR><FONT SIZE=2> * Construct a new data object.</FONT>
<BR><FONT SIZE=2> */</FONT>
<BR><FONT SIZE=2> public CustomerInfo(String number, String address1, String address2,</FONT>
<BR><FONT SIZE=2> String address3, String city, String state, String zip) {</FONT>
<BR><FONT SIZE=2> this.number = number;</FONT>
<BR><FONT SIZE=2> this.address1 = address1;</FONT>
<BR><FONT SIZE=2> this.address2 = address2;</FONT>
<BR><FONT SIZE=2> this.address3 = address3;</FONT>
<BR><FONT SIZE=2> this.city = city;</FONT>
<BR><FONT SIZE=2> this.state = state;</FONT>
<BR><FONT SIZE=2> this.zip = zip;</FONT>
<BR><FONT SIZE=2> }</FONT>
</P>
<P><FONT SIZE=2> /**</FONT>
<BR><FONT SIZE=2> * @return the contents of this object as an XML document.</FONT>
<BR><FONT SIZE=2> */</FONT>
<BR><FONT SIZE=2> public Document getDocument() {</FONT>
<BR><FONT SIZE=2> if (this.doc == null) {</FONT>
<BR><FONT SIZE=2> this.doc = new Document(getElement());</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> return this.doc;</FONT>
<BR><FONT SIZE=2> }</FONT>
</P>
<P><FONT SIZE=2> /**</FONT>
<BR><FONT SIZE=2> * This method makes it possible to easily embed the output from</FONT>
<BR><FONT SIZE=2> * this data object into some other larger XML document.</FONT>
<BR><FONT SIZE=2> *</FONT>
<BR><FONT SIZE=2> * @return the contents of this object as an Element, which is just</FONT>
<BR><FONT SIZE=2> * the root element without the XML declaration.</FONT>
<BR><FONT SIZE=2> */</FONT>
<BR><FONT SIZE=2> public Element getElement() {</FONT>
<BR><FONT SIZE=2> if (this.elem == null) {</FONT>
<BR><FONT SIZE=2> this.elem = new Element("Customer");</FONT>
<BR><FONT SIZE=2> this.elem = new Element("BillTo");</FONT>
<BR><FONT SIZE=2> this.elem.addContent(new Element</FONT>
<BR><FONT SIZE=2>("BillTo").setText(this.number))</FONT>
<BR><FONT SIZE=2> .addContent(new Element("Number").setText(this.number))</FONT>
<BR><FONT SIZE=2> .addContent(new Element("Address1").setText(this.address1))</FONT>
<BR><FONT SIZE=2> .addContent(new Element("Address2").setText(this.address2))</FONT>
<BR><FONT SIZE=2> .addContent(new Element("Address3").setText(this.address3))</FONT>
<BR><FONT SIZE=2> .addContent(new Element("City").setText(this.city))</FONT>
<BR><FONT SIZE=2> .addContent(new Element("State").setText(this.state))</FONT>
<BR><FONT SIZE=2> .addContent(new Element("Zip").setText(this.zip));</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> return this.elem;</FONT>
<BR><FONT SIZE=2> }</FONT>
</P>
<P><FONT SIZE=2> /**</FONT>
<BR><FONT SIZE=2> * A simple test program.</FONT>
<BR><FONT SIZE=2> */</FONT>
<BR><FONT SIZE=2> public static void main(String[] args) throws IOException {</FONT>
<BR><FONT SIZE=2> // create an object</FONT>
<BR><FONT SIZE=2> CustomerInfo ci = new CustomerInfo("100014", "1234",</FONT>
<BR><FONT SIZE=2> "111-222-333", "05/2000", "ewrwer", "qwe", "2414");</FONT>
</P>
<P><FONT SIZE=2> // convert to XML, then format with two space indent</FONT>
<BR><FONT SIZE=2> Document doc = ci.getDocument();</FONT>
<BR><FONT SIZE=2> new XMLOutputter(" ", true).output(doc, System.out);</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2>}</FONT>
</P>
<P><FONT SIZE=2>This is my first attempt at using XML,XSL,XSLT,JDOM, etc. any help would be</FONT>
<BR><FONT SIZE=2>greatly appreciated.</FONT>
</P>
<P><FONT SIZE=2>Thanks,</FONT>
<BR><FONT SIZE=2>Joy</FONT>
</P>
<P><FONT SIZE=2>_______________________________________________</FONT>
<BR><FONT SIZE=2>To control your jdom-interest membership:</FONT>
<BR><FONT SIZE=2><A HREF="http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com" TARGET="_blank">http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com</A></FONT>
</P>
</BODY>
</HTML>