wood burning stoves 2.0*
The moose likes Struts and the fly likes read xml from JAR file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "read xml from JAR file" Watch "read xml from JAR file" New topic
Author

read xml from JAR file

Ralf Heinecke
Greenhorn

Joined: Dec 27, 2010
Posts: 2
Hi there,

I want to build a webproject that includes a "core"-application. This core is in a JAR file. It uses it's own struts configuration.

I tried to reference from the web.xml in the main-project to the struts-config.xml located inside the core-jar file
like this:



As this idea did not work I've put the core config file under web-inf in the main project.
Now the config file is found by the application and properties-files defined inside it (like ApplicationResources.properties [messages]) are also found, but the xml files referenced in the struts-config (like validator-config.xml or tiles-config.xml) cannot be found.

Example:

This works:


This didn't work:



Why can properties be found inside a jar file but no xml files ? Is there a way to do this ?

DO1EH
Jesus Mireles
Ranch Hand

Joined: Mar 10, 2010
Posts: 122

I usually have no issues when I use XXXX.class.getClassLoader().getResourceAsStream(filename) ... I usually read some XML for configuration that may not be in a properties file.
Ralf Heinecke
Greenhorn

Joined: Dec 27, 2010
Posts: 2
[quote=Lucas Mireles]I usually have no issues when I use XXXX.class.getClassLoader().getResourceAsStream(filename) ... I usually read some XML for configuration that may not be in a properties file.[/quote]

Yes it's no problem to read other xml files (like the hbm.xmls from hibernate) only the struts-config has a problem and i ask myself why.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: read xml from JAR file