Skip to content

Commit

Permalink
MONDRIAN: In Weblogic, use Xerces, not the default JAXP parser. (Beca…
Browse files Browse the repository at this point in the history
…use Weblogic's JAXP parser doesn't run in non-validating mode.)

[git-p4: depot-paths = "//open/mondrian/": change = 136]
  • Loading branch information
julianhyde committed Sep 10, 2002
1 parent 4b1c51a commit fbe1f52
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 6 deletions.
4 changes: 3 additions & 1 deletion build.xml
Expand Up @@ -64,9 +64,11 @@ ${etc.dir}/mondrian/web/jsp/**/*.java"/>
<pathelement location="${lib.dir}/jmi.jar"/>
<pathelement location="${xalan.home}/bin/xalan.jar"/>
<pathelement location="${junit.home}/junit.jar"/>
<pathelement location="${weblogic.home}/lib/weblogic.jar"/>
<!-- CLASSPATH must contain xml-apis.jar, xercesImpl.jar, javacup.jar -->
<pathelement path="${myenv.CLASSPATH}"/>
<!-- Weblogic must be after xml-apis.jar and xercesImpl.jar, because it
contains an incompatible version of xerces. -->
<pathelement location="${weblogic.home}/lib/weblogic.jar"/>
</path>

<path id="project.boot.classpath">
Expand Down
37 changes: 37 additions & 0 deletions doc/install.html
Expand Up @@ -134,6 +134,7 @@ <h2><a name="3_Setup_build_environment">3. Setup build environment</a></h2>
<p>Optional:</p>
<ol>
<li>Install <a href="#Jikes">Jikes</a>.</li>
<li>Configure <a href="#Weblogic">Weblogic</a>.</li>
</ol>

<h2><a name="4_Download_the_source_code">4. Download the code</a></h2>
Expand Down Expand Up @@ -637,6 +638,21 @@ <h2><a name="Appendix_A_Product_installation_instructions">Appendix A. Product
I modified version v.0.10g to add an Ant task, and to output error
messages in a format which Emacs can parse.</td>
</tr>
<tr>
<td><a name="Weblogic">Weblogic</a></td>
<td>No</td>
<td>6.1</td>
<td>
<ol>
<li>Extract <code>xml-apis.jar</code> and <code>xercesImpl.jar</code> from
<code>mondrian.war</code> and place them in <code>${weblogic.home}/lib</code>.</li>
<li>Edit <code>startWeblogic.cmd</code>, or whichever script you use to
start Weblogic, and place <code>xml-apis.jar</code> and <code>
xercesImpl.jar</code> before <code>weblogic.jar</code> on the class-path.</li>
</ol>
<p>See <a href="#Appendix_C_A_note_on_Weblogic_and_Xerces">note on Weblogic
and Xerces</a>.</td>
</tr>
</table>

<h2><a name="Appendix_B_How_to_debug_Tomcat_using_IntelliJ">Appendix B. How to debug
Expand Down Expand Up @@ -666,6 +682,27 @@ <h2><a name="Appendix_B_How_to_debug_Tomcat_using_IntelliJ">Appendix B. How to d
<li>attach intellij's debugger to port 5000</li>
</ol>

<h2><a name="Appendix_C_A_note_on_Weblogic_and_Xerces">Appendix C. A note on
Weblogic and Xerces</a></h2>
<p>Weblogic 6.1 ships with an older, incompatible, version of Xerces. The
symptom is the error</p>
<blockquote>
<pre>java.lang.VerifyError: (class: mondrian/xom/wrappers/XercesDOMParser, method: parse signature: (Lorg/xml/sax/InputSource;)Lorg/w3c/dom/Document;) Incompatible object argument for function call
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at mondrian.xom.XOMUtil.createDefaultParser(XOMUtil.java:165)
at mondrian.resource.Util.load(Util.java:49)
...</pre>
</blockquote>
<p>The solution is to place <code>xml-apis.jar</code> and <code>xercesImpl.jar</code>
before <code>weblogic.jar</code> on your class-path.</p>
<p>Generally, Mondrian uses whichever JAXP-compliant XML parser is provided by
the system. Unfortunately Weblogic's parser cannot be set to non-validating
mode, and Mondrian needs this. Therefore, in a Weblogic environment, Mondrian
explicitly uses Xerces.&nbsp; Fyi,
<a href="http://xml.apache.org/soap/faq/faq-for-WL6.1beta.html">this note</a>
describes how to change Weblogic's default XML parser.</p>

<p>&nbsp;</p>

<b>
Expand Down
29 changes: 26 additions & 3 deletions src/main/mondrian/xom/XOMUtil.java
Expand Up @@ -156,13 +156,32 @@ public static void addChild(ElementDef parent, NodeDef child)
addChildren(parent, new NodeDef[] {child});
}

private static boolean inWeblogic() {
try {
Class.forName("weblogic.xml.sax.XMLInputSource");
} catch (ClassNotFoundException e) {
return false;
}
return true;
}

/**
* Creates a {@link Parser} of the default parser type.
**/
public static Parser createDefaultParser() throws XOMException
{
// String className = "mondrian.xom.wrappers.XercesDOMParser";
String className = "mondrian.xom.wrappers.JaxpDOMParser";
String className;
if (inWeblogic()) {
// We need a non-validating parser, and Weblogic's jaxp parser
// can't switched to non-validating, so explicitly use Xerces.
//
// You must also ensure that xml-apis.jar and xercesImpl.jar are
/// before weblogic.jar on the CLASSPATH, otherwise you'll get a
// java.lang.VerifyError.
className = "mondrian.xom.wrappers.XercesDOMParser";
} else {
className = "mondrian.xom.wrappers.JaxpDOMParser";
}
try {
Class clazz = Class.forName(className);
return (Parser) clazz.newInstance();
Expand All @@ -173,7 +192,11 @@ public static Parser createDefaultParser() throws XOMException
} catch (InstantiationException e) {
throw new XOMException(e, "while creating xml parser" + className);
} catch (VerifyError e) {
throw new XOMException(e, "while creating xml parser" + className);
throw new XOMException(
e, "while creating xml parser" + className +
" (if you are running Weblogic 6.1, try putting " +
"xml-apis.jar and xercesImpl.jar BEFORE weblogic.jar " +
"on CLASSPATH)");
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/main/mondrian/xom/wrappers/JaxpDOMParser.java
Expand Up @@ -44,8 +44,13 @@ public JaxpDOMParser(boolean validating) throws XOMException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(validating);
factory.setAttribute(VALIDATION_FEATURE, new Boolean(validating));
factory.setAttribute(LOAD_EXTERNAL_DTD_FEATURE, new Boolean(validating));
try {
factory.setAttribute(VALIDATION_FEATURE, new Boolean(validating));
factory.setAttribute(LOAD_EXTERNAL_DTD_FEATURE, new Boolean(validating));
} catch (IllegalArgumentException e) {
// Weblogic 6.1's parser complains 'No arguments are
// implemented'
}
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new XOMException(e, "Error creating parser");
Expand Down

0 comments on commit fbe1f52

Please sign in to comment.