Troubleshooting
Problem
A JAR file, log4j.jar, in []
] folder contains the DTD file, log4j.dtd. The log4j.dtd file is referenced in an XML file, log4j.xml, created to define the logger configuration as doctype:
[]
[
]
However, the XML validator could not find the log4j.dtd contained in the log4j.jar file.
This technote describes several possible ways to reference a DTD file that is contained in a JAR file so that the validator can find the DTD file.
Resolving The Problem
There are several possible ways you could reference a DTD in a JAR so that the XML validator finds the DTD, but the method you choose might depend on your specific situation.
<!DOCTYPE log4j:configuration SYSTEM "jar:file:
<absolute-path>/log4j.jar!/org/apache/log4j/xml/log4j.dtd">
The problem with this way is that you have to specify an absolute path to the JAR file, and this might be a problem if you plan to push your project EAR to different servers.
In order to use the catalog follow these steps:
- Open Window > Preferences > Web and XML > XML Catalog.
- On the XML Catalog preference page select New. . .
- Enter a key of log4j.dtd. The Key type should be Public ID. The URI should be the absolute location of the DTD using the JAR notation that was used in the XML configuration file. For example, it looks like the following:
- Select OK in the dialog and again on the preference page.
- Change the declaration in the configuration file from the JAR reference to
<!DOCTYPE log4j:configuration PUBLIC "log4j.dtd" "log4j.dtd">
The XML configuration file should now validate successfully without extracting the DTD or making an absolute reference in the file.
[{"Product":{"code":"SSRTLW","label":"Rational Application Developer for WebSphere Software"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Web Development","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"6.0;6.0.0.1;6.0.1.0;6.0.1.1","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSYK2S","label":"Rational Software Architect Designer"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Web Development","Platform":[{"code":"PF033","label":"Windows"}],"Version":"6.0;6.0.0.1","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSJM4G","label":"Rational Web Developer for WebSphere Software"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Web Development","Platform":[{"code":"PF033","label":"Windows"}],"Version":"6.0;6.0.0.1","Edition":"","Line of Business":{"code":"","label":""}}]
Was this topic helpful?
Document Information
Modified date:
10 September 2020
UID
swg21233092