Solved

Java XML code can run in VAJ, but cannot run under JRUN!

Posted on 2001-08-01
3
173 Views
Last Modified: 2010-03-31
Hi, all, I have a small question, but it already drive me crazy today. If anyone here familar with both java and XML, i'm very appreciated.

I use Xalan 2.1 and Xerces 1.4.1, I want to render a XML document to HTML, the XML document is generated from another object.

If I save the XML to a standalone xml file, I can use the command line xslt tool to do the render work and ensure the XSL file is correct.

and I use Visual Age for Java (already delete the origional IBM XML parser and use Xalan instead ), it works, i can get the HTML file in console.

the code is below:

=============== code begin ==============
Document xmlMenu = hsm.getUser().getXmlMenu();

TransformerFactory tFactory = TransformerFactory.newInstance();
     Transformer transformer     =
          tFactory.newTransformer(new StreamSource("d:\\Menu.xsl"));
     transformer.transform(new DOMSource(xmlMenu),
          new StreamResult( System.out ));
=============== code end ==============

the XSL is like below:
================ xsl begin ==============
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
     <xsl:template match="/">
     
<HTML>
<HEAD>


...
...
=============== xsl end ==================


But if I run it in JRun, it report a exception:

Exception thrown on line '17' from page 'E:\\JRun\\servers\\default\\SCMS\\banner.jsp'.
javax.xml.transform.TransformerConfigurationException: Namespace not supported by SAXParser
     at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:704)
     at jrun__banner2ejspb._jspService(jrun__banner2ejspb.java:89)
     at allaire.jrun.jsp.HttpJSPServlet.service(../jsp/HttpJSPServlet.java:39)
     at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:228)


How could it be?
To confirm jrun is using Xalan, i put the class files in WEB-INF/classes instead of WEB-INF/lib, and i can see it's a Xalan exception.

If anyone can help, thank you very much!
0
Comment
Question by:Xiaogang
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
ozymandias earned 250 total points
ID: 6340819
The factory object is returning an instance of a transformer based on some internal set of rules.

Either a) the class path in VAJ is different to that of JRun and JRun is finding a different Transformer object from VAJ, or

b) when the code runs in VAJ it somehow affects the decision of the factory method about which type of transformer to return.
0
 

Author Comment

by:Xiaogang
ID: 6343182
Yes, ozymandias, i know that exactly.
Thank god I already get the answer from XML board.
you can goto qid=20161357 to get the thread.

anyway, you are the only one who answer my question here, thank you very much, and i want to express my appreciate by accept u as answer.

Thanks!
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 6343552
That's very gracious of you.
Thanks.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 38
split string containing \r\n in Java 46 44
diffSum example 4 37
Is there a simpler dropbox system? 10 22
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question