Le D?aut St?phane wrote:
> Hello,
>
> I deployed xxe on client side.
> The installation looks right and i can see it in the directory :
> C:\Documents and Settings\toto\Application
> Data\Sun\Java\Deployment\javaws\cache\http\Dtoto\P80\DMxxe\DMwebstart
>
> Client can launch xxe also and see my config.xxe, so xxe knows automatically
> extract files which are in the xxe_config.jar.
>
> My application needs also to read xml files which are embedded in the
> xxe_config.jar.
> They are configuration files of my application and they are also stored in
> xxe_config.jar as my config.xxe.
>
> how to retrieve xml files located in xxe_config.jar directly from my program
> ?
>
> In my program I use the method :
> docLoader.load(".\\config\\myConfig\\init\\parameters.xml")
>
> On server side it works well.
(I think it works on the server only because XXE current working
directory happens to be right.)
This is a Java WebStart question in fact. In your code, please do this:
---
URL parametersURL =
getClass().getResource("/config/myConfig/init/parameters.xml");
Document parametersDoc = docLoader.load(parametersURL);
---
Note that:
* /config/myConfig/init/parameters.xml is an URL, not a filename.
* /config/myConfig/init/parameters.xml must start with "/".
* This only works with Java WebStart because configurations are archived
in xxe_config.jar which is in the CLASSPATH.
A more general way to do this is:
---
import com.xmlmind.xmledit.xmlutil.XMLCatalogs;
URL parametersURL =
XMLCatalogs.resolveURI("xxe-config:myConfig/init/parameters.xml",
/*fallback baseURL: don't care*/ null);
Document parametersDoc = docLoader.load(parametersURL);
---
This should work because XXE default XML catalog, config/catalog.xml,
contains:
---
<rewriteURI uriStartString="xxe-config:" rewritePrefix="." />
---
I haven't tested all this but I'm almost sure this will work.