Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix / tomcat 5.5 : Default folder for DTD files

Status
Not open for further replies.

swazik

Programmer
Aug 9, 2006
4
CA
Hi,

Where can I set up the default storage folder for DTD files in Tomcat ?

Here is my problem: I'm working with a XML webservice and I need to validate the XML using a DTD (I can't changed the XML input with the file URL that is just like: "ops.dtd"). On my window dev station, tomcat is searching that ops.dtd in its /bin directory. Ok, no problem with that. Now that I'm deploying on a UNIX station, it's looking for this file in the home directory /home/.../mydtd.dtd. I could put my file in there but I'm not happy with it, as it's a FTP directory, and someone could delete it thinking it's garbage.. I would really prefer to put it in my tomcat/webapps/myApp/.../etc so its part of the deployment process and backups.

Thanks for your help,

Swazik
 
You should certainly never put any application specific data in tomcat's bin dir - very bad practice.

You should put application specific files within the application/webapp.

Not sure what you really mean by "default storage for DTDs" - there is no such thing for webapp specific files.
Perhaps you should post how the XML defines where it's DTD lives - it should ALWAYS be EITHER a relative directory to the application processing it, or much better still a full URL.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Thank for your time and good advice but the purpose of my question was to know how to put these file in my webapp directory.

Here is more details on what is going on:

- I request a webservice through HTTP. It sends me back a response (I don't have ANY control on that response) that has
<!DOCTYPE OPS_envelope SYSTEM "ops.dtd"> in the header.

- When I parse this XML, I get a java.io.FileNotFoundException: /usr/home/app/ops.dtd when I call javax.xml.parsers.DocumentBuilder.parse

As I said, I can't change that DTD URI (it would be so simple if I could). I guess I'm in the wrong forum and it's not a Tomcat related issue. I though it was as it was looking for that dtd in the bin directory on my DEV station.

Anyway if you have any idea on how putting my dtd in my webapp folder I'll be very thankful.

Swasik.
 
The XML that you are recieving is badly written - the DTD should be given as being a full URL (so that you could just paste it into a browser, and see it).

The reason the parser is looking for the DTD in (on Win32 in tomcat's bin directory, on *nix in /usr/home/app) is because those are the directories where the java process that tomcat is running under is started in those directories.
Because the DTD has no full path or URL, the parser is looking for it in the current working directory of the process (as stated above).

You can either :
- Tell the developer of the web service to fix their application to generate a decent URL to the DTD, or
- Hack the XML when you recieve it, to replace the DTD location with either a URL, or a full path to somewhere on your server, or
- (Horribly) download the DTD itself and save it in the current working directory of the process.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 

Replacing the URI of the DTD before parsing sounds much cleaner than keeping that file in the start directory.

I can't change the xml but I'll let them know that they should use a full URL pointing to their server so I would not have to bother about storing that file. I don't think they'll change it as I'm not the only one using that webservice.

Thank you very much for these explanations !

Swazik
 
If they get enough complaints, they might fix it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top