<!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>FW: [jdom-interest] Sealing violation</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Here's the response from Eric...I thought it went to the list, but it was send directly to me.</FONT>
</P>
<P><FONT SIZE=2>One additional question, is JDomServlet2 in a package? The code snippet doesn't reflect it, but on closer examination it looks like your problem might be with that file.</FONT></P>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Eric Burke [<A HREF="mailto:burke_e@yahoo.com">mailto:burke_e@yahoo.com</A>]</FONT>
<BR><FONT SIZE=2>Sent: Thursday, March 08, 2001 12:42 PM</FONT>
<BR><FONT SIZE=2>To: Steven Smith</FONT>
<BR><FONT SIZE=2>Subject: RE: [jdom-interest] Sealing violation</FONT>
</P>
<BR>
<P><FONT SIZE=2>The "sealing violation" is always a CLASSPATH</FONT>
<BR><FONT SIZE=2>issue. Under Tomcat 3.x, Tomcat includes its</FONT>
<BR><FONT SIZE=2>own XML JAR files in your web app's </FONT>
<BR><FONT SIZE=2>environment. We found that we had to hand-edit</FONT>
<BR><FONT SIZE=2>Tomcat's startup scripts to modify the</FONT>
<BR><FONT SIZE=2>CLASSPATH.</FONT>
</P>
<P><FONT SIZE=2>Look inside of Tomcat's startup.bat (I'm assuming </FONT>
<BR><FONT SIZE=2>this is Windows). Somewhere in there you will</FONT>
<BR><FONT SIZE=2>see a lot of code that configures the</FONT>
<BR><FONT SIZE=2>CLASSPATH. Just make sure that Tomcat's</FONT>
<BR><FONT SIZE=2>older jaxp.jar and parser.jar appear</FONT>
<BR><FONT SIZE=2>AFTER any newer XML parsers and XSLT processors</FONT>
<BR><FONT SIZE=2>that you intend to use.</FONT>
</P>
<P><FONT SIZE=2>Another option is to move up to Tomcat 4.0.</FONT>
<BR><FONT SIZE=2>They have really cleaned up the CLASSPATH</FONT>
<BR><FONT SIZE=2>problems, although you will still have to</FONT>
<BR><FONT SIZE=2>get in there and provide updated JAR files</FONT>
<BR><FONT SIZE=2>in Tomcat's "lib" directory --- Tomcat 4.0</FONT>
<BR><FONT SIZE=2>still ships with an older XML parser. I</FONT>
<BR><FONT SIZE=2>believe you can just replace their version</FONT>
<BR><FONT SIZE=2>with a newer one.</FONT>
</P>
<P><FONT SIZE=2>I'm at a client site so I can't look at</FONT>
<BR><FONT SIZE=2>my files right now, otherwise I could</FONT>
<BR><FONT SIZE=2>provide more details. I hope this helps.</FONT>
</P>
<P><FONT SIZE=2>- Eric</FONT>
</P>
<BR>
<P><FONT SIZE=2>--- Steven Smith <ssmith@neonsys.com> wrote:</FONT>
<BR><FONT SIZE=2>> What's the classpath look like for this servlet?</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> -----Original Message-----</FONT>
<BR><FONT SIZE=2>> From: JStalnecker@idssinfo.com</FONT>
<BR><FONT SIZE=2>> [<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>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> I have just come across the jdom product thru an</FONT>
<BR><FONT SIZE=2>> article on www.onjava.com</FONT>
<BR><FONT SIZE=2>> at</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2><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>.</FONT>
<BR><FONT SIZE=2>> I</FONT>
<BR><FONT SIZE=2>> have made some changes the servlet and class. I am</FONT>
<BR><FONT SIZE=2>> also using my own XSL.</FONT>
<BR><FONT SIZE=2>> When I run my servlet(code below) I get the</FONT>
<BR><FONT SIZE=2>> following error:</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> java.lang.ClassNotFoundException: class JDomServlet2</FONT>
<BR><FONT SIZE=2>> :</FONT>
<BR><FONT SIZE=2>> java.lang.SecurityException: sealing violation</FONT>
<BR><FONT SIZE=2>> at</FONT>
<BR><FONT SIZE=2>> java.beans.Beans.instantiate(Beans.java:215)</FONT>
<BR><FONT SIZE=2>> at</FONT>
<BR><FONT SIZE=2>> java.beans.Beans.instantiate(Beans.java:55)</FONT>
<BR><FONT SIZE=2>> at</FONT>
<BR><FONT SIZE=2>></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>></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>></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>></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>></FONT>
<BR><FONT SIZE=2>com.caucho.server.http.PageCache$Entry.service(PageCache.java:252)</FONT>
<BR><FONT SIZE=2>> at</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>com.caucho.server.http.PageCache.service(PageCache.java:103)</FONT>
<BR><FONT SIZE=2>> at</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>com.caucho.server.http.VirtualHost.service(VirtualHost.java:395)</FONT>
<BR><FONT SIZE=2>> at</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>com.caucho.server.http.Request.dispatch(Request.java:211)</FONT>
<BR><FONT SIZE=2>> at</FONT>
<BR><FONT SIZE=2>></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>></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</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>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>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><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>
<BR><FONT SIZE=2>> </FONT>
<BR><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 =</FONT>
<BR><FONT SIZE=2>> XSLTProcessorFactory.getProcessor(</FONT>
<BR><FONT SIZE=2>> new</FONT>
<BR><FONT SIZE=2>> org.apache.xalan.xpath.xdom.XercesLiaison());</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> ServletContext context = null;</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> // initialize the Servlet. This code is</FONT>
<BR><FONT SIZE=2>> executed once.</FONT>
<BR><FONT SIZE=2>> public void init(ServletConfig config) throws</FONT>
<BR><FONT SIZE=2>> ServletException {</FONT>
<BR><FONT SIZE=2>> super.init(config);</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> context = config.getServletContext();</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> }</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><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</FONT>
<BR><FONT SIZE=2>> IOException,</FONT>
<BR><FONT SIZE=2>> ServletException {</FONT>
<BR><FONT SIZE=2>> try {</FONT>
<BR><FONT SIZE=2>> HttpSession session =</FONT>
<BR><FONT SIZE=2>> request.getSession(true);</FONT>
<BR><FONT SIZE=2>> String xsltURL =</FONT>
<BR><FONT SIZE=2>> request.getParameter("xsltURL");</FONT>
<BR><FONT SIZE=2>> // read the XSLT stylesheet and</FONT>
<BR><FONT SIZE=2>> cache it for future</FONT>
<BR><FONT SIZE=2>> reuse</FONT>
<BR><FONT SIZE=2>> InputStream xsltStream =</FONT>
<BR><FONT SIZE=2>> context.getResourceAsStream(xsltURL);</FONT>
<BR><FONT SIZE=2>> StylesheetRoot parsedStylesheet =</FONT>
<BR><FONT SIZE=2>> processor.processStylesheet(</FONT>
<BR><FONT SIZE=2>> new</FONT>
<BR><FONT SIZE=2>> XSLTInputSource(xsltStream));</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> processor.setStylesheet(parsedStylesheet);</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> response.setContentType("text/html");</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> // in a real app, the CreditInfo object</FONT>
<BR><FONT SIZE=2>> would be retrieved</FONT>
<BR><FONT SIZE=2>> // from an EJB component</FONT>
<BR><FONT SIZE=2>> CustomerInfo ci = new</FONT>
<BR><FONT SIZE=2>> CustomerInfo("100014", "123 Main</FONT>
<BR><FONT SIZE=2>> Street", "Suite 12345",</FONT>
<BR><FONT SIZE=2>> "This is the third address</FONT>
<BR><FONT SIZE=2>> line", "Reading", "PA",</FONT>
<BR><FONT SIZE=2>> "19607");</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><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</FONT>
<BR><FONT SIZE=2>> DOMOutputter().output(jdomDoc);</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> // transform the XML into HTML</FONT>
<BR><FONT SIZE=2>> processor.process(new</FONT>
<BR><FONT SIZE=2>> XSLTInputSource(domDoc),</FONT>
<BR><FONT SIZE=2>> null, // use</FONT>
<BR><FONT SIZE=2>> pre-compiled stylesheet</FONT>
<BR><FONT SIZE=2>> new</FONT>
<BR><FONT SIZE=2>> 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>
<BR><FONT SIZE=2>> </FONT>
<BR><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>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> /**</FONT>
<BR><FONT SIZE=2>> * Example of an object that knows how to represent</FONT>
<BR><FONT SIZE=2>> 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>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> // transient fields are not serialized. This</FONT>
<BR><FONT SIZE=2>> prevents the potential</FONT>
<BR><FONT SIZE=2>> // overhead of sending too much data between an</FONT>
<BR><FONT SIZE=2>> 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>
<BR><FONT SIZE=2>> </FONT>
<BR><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</FONT>
<BR><FONT SIZE=2>> address1, String address2,</FONT>
<BR><FONT SIZE=2>> String address3, String city, String</FONT>
<BR><FONT SIZE=2>> 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>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> /**</FONT>
<BR><FONT SIZE=2>> * @return the contents of this object as an XML</FONT>
<BR><FONT SIZE=2>> 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>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> /**</FONT>
<BR><FONT SIZE=2>> * This method makes it possible to easily embed</FONT>
<BR><FONT SIZE=2>> the output from</FONT>
<BR><FONT SIZE=2>> * this data object into some other larger XML</FONT>
<BR><FONT SIZE=2>> document.</FONT>
<BR><FONT SIZE=2>> *</FONT>
<BR><FONT SIZE=2>> * @return the contents of this object as an</FONT>
<BR><FONT SIZE=2>> 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>> </FONT>
<BR><FONT SIZE=2>=== message truncated ===</FONT>
</P>
<BR>
<P><FONT SIZE=2>=====</FONT>
<BR><FONT SIZE=2>Eric M. Burke</FONT>
<BR><FONT SIZE=2>Principal Software Engineer, Object Computing, Inc.</FONT>
<BR><FONT SIZE=2>314-494-3185 (mobile)</FONT>
<BR><FONT SIZE=2>636-978-3268 (home)</FONT>
<BR><FONT SIZE=2>burke_e@ociweb.com</FONT>
</P>
<P><FONT SIZE=2>__________________________________________________</FONT>
<BR><FONT SIZE=2>Do You Yahoo!?</FONT>
<BR><FONT SIZE=2>Get email at your own domain with Yahoo! Mail. </FONT>
<BR><FONT SIZE=2><A HREF="http://personal.mail.yahoo.com/" TARGET="_blank">http://personal.mail.yahoo.com/</A></FONT>
</P>
</BODY>
</HTML>