-
1. Re: Cannot resolve dtd
adrian.brock Feb 14, 2002 1:52 PM (in response to toffeem)JBoss has its own local resolver, but the entities
are "hard-coded".
The source is org.jboss.metadata.XmlFileLoader
if you want to modify it.
Maybe you could provide a patch that loads the
entities from a configuration file, or failing that
put it in the feature requests on sourceforge.
NOTE: This also has to work with the external verifier.
Look at jboss/external/metadata.jar
Regards,
Adrian -
2. Re: Cannot resolve dtd
toffeem Feb 15, 2002 1:36 PM (in response to toffeem)Adrian,
Since I need it quite urgently, can you give me some hints/clues if I want to modify the XmlFileLoader. How hard is it?
Fanny -
3. Re: Cannot resolve dtd
adrian.brock Feb 15, 2002 2:06 PM (in response to toffeem)It is a static list of entity/dtd strings in the code.
The real DTD has to be in the classpath of the server,
e.g. put it in a jar and drop it in lib/ext
Here's the code from org.jboss.metadata.XmlFileLoader in
3.0
[pre]
// Inner classes -------------------------------------------------
/**
* Local entity resolver to handle J2EE DTDs. With this a http connection
* to sun is not needed during deployment.
* Function boolean hadDTD() is here to avoid validation errors in
* descriptors that do not have a DOCTYPE declaration.
* @author Wolfgang Werner
* @author Darius Davidavicius
**/
private static class LocalResolver implements EntityResolver
{
private Hashtable dtds = new Hashtable();
private boolean hasDTD = false;
public LocalResolver() {
registerDTD("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN", "ejb-jar.dtd");
registerDTD("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN", "ejb-jar_2_0.dtd");
registerDTD("-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN", "application_1_2.dtd");
registerDTD("-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN", "application_1_3.dtd");
registerDTD("-//Sun Microsystems, Inc.//DTD Connector 1.0//EN", "connector_1_0.dtd");
registerDTD("-//JBoss//DTD JAWS//EN", "jaws.dtd");
registerDTD("-//JBoss//DTD JAWS 2.4//EN", "jaws_2_4.dtd");
registerDTD("-//JBoss//DTD JAWS 3.0//EN", "jaws_3_0.dtd");
registerDTD("-//JBoss//DTD JBOSS//EN","jboss.dtd");
registerDTD("-//JBoss//DTD JBOSS 2.4//EN","jboss_2_4.dtd");
registerDTD("-//JBoss//DTD JBOSS 3.0//EN","jboss_3_0.dtd");
registerDTD("-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN",
"jbosscmp-jdbc_3_0.dtd");
}
/**
Registers available DTDs
@param String publicId - Public ID of DTD
@param String dtdFileName - the file name of DTD
*/
public void registerDTD(String publicId, String dtdFileName) {
dtds.put(publicId, dtdFileName);
}
/**
Returns DTD inputSource. Is DTD was found in the hashtable and inputSource was created
flad hasDTD is ser to true.
@param String publicId - Public ID of DTD
@param String dtdFileName - the file name of DTD
@return InputSource of DTD
*/
public InputSource resolveEntity (String publicId, String systemId)
{
hasDTD = false;
String dtd = (String)dtds.get(publicId);
if (dtd != null)
{
hasDTD = true;
try
{
InputStream dtdStream = getClass().getResourceAsStream(dtd);
InputSource aInputSource = new InputSource(dtdStream);
return aInputSource;
} catch( Exception ex ) {
// ignore
}
}
return null;
}
/**
Returns the boolean value to inform id DTD was found in the XML file or not
@return boolean - true if DTD was found in XML
*/
public boolean hasDTD ()
{
return hasDTD;
}
}
[/pre]
Regards,
Adrian -
4. Re: Cannot resolve dtd
toffeem Feb 17, 2002 12:09 PM (in response to toffeem)Hi,
Thanks for your reply.
If I need to refer a dtd which is not included in the LocalResolver, do I need to modify the XmlFileLoader?
For example:
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://localhost/struts/dtds/struts-config_1_0.dtd">
Cheers,
Fanny -
5. Re: Cannot resolve dtd
joesclee Feb 18, 2002 10:55 AM (in response to toffeem)Hi Adrian,
I followed your advice and do a quick hack registering the struts dtd that I used. However when I tried it out I noticed that the resolveEntity method is only used to resolve those Sun's DTDs. Application dtds in application xmls are not resolved by this class. Any other ideas?
- Joe -
6. Re: Cannot resolve dtd
adrian.brock Feb 18, 2002 11:30 AM (in response to toffeem)I never said this would magically get used.
The class org.jboss.metadata.XmlFileLoader is
used during JBoss deployment. It has a local resolver for
redirecting entities to dtds in the classpath.
You can use this class in your own code, providing
you modify the list of registerDTD()s and add the dtd
to the classpath.
e.g.
registerDTD("-//Apache Software Foundation//DTD Struts Configuration 1.0//EN", "struts-config_1_0.dtd");
To put struts-config_1_0.dtd in the classpath,
create a jar containing the dtd and drop it in jboss/lib/ext.
Because of the confusion, I think this mechanism is
not very useful for struts???
I haven't used struts.
Perhaps you can explain how the dtd is used?
Regards,
Adrian