Accessing WEB-INF from Java code
Hi,
I have a .ear application running that uses a WSDL. The auto generated code for the WSDL looks for one of the .wsdl files in the same directory as the .class file.
For Example:
URL baseUrl = WSDL_Service.class.getResource(".");
wsdlLocationURL = new URL(baseUrl, "WSDL.wsdl");
Unfortunately, when compiling and deploying the .ear, putting the WSDL.wsdl in the same folder as the class file's WSDL_Service.java file does not end up with the WSDL.wsdl in the same folder as the WSDL_Service.class file when deployed on the webserver. So, the current hack is to manually put the WSDL.wsdl in the correct folder with all the .class files on the server. This is not the desired way of doing this :-)
If I put the WSDL.wsdl in the 'resources' folder, after deploying, it ends up in the WEB-INF folder. Unfortunately I, with my google skills, have not found a way to access the WEB-INF folder from the java code. I *could* figure out the relative path from the WSDL_Service.class folder to the WEB-INF folder and hack my way to the file, but I don't want to do this. I have found solutions talking about ServletContext.getResource but these seem to only be viable solutions when dealing with JSP or AJAX code. I have found no way to instantiate a ServletContext object in the WSDL_Service class.
What is the correct way for accessing resource files from java in a .ear web app?
Please let me know if I need to clarify my question or more information is needed.
Thank you for any and all help!
~Scott <><
|