Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
|
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 13th, 2009, 02:20 PM
Registered User
 
Join Date: Mar 2009
Posts: 4
Thanks: 3
Thanked 0 Times in 0 Posts
Default 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 <><





Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginning Java Web Services source code examples ch1cago2la Java Basics 1 May 3rd, 2009 01:52 PM
source code examples Beginning Java Web Services ch1cago2la All Other Wrox Books 1 November 18th, 2008 04:49 PM
multiple web-inf folder Nia Servlets 0 February 17th, 2005 12:28 PM
Accessing Web User Controls from code aquaboltar ASP.NET 2.0 Basics 0 October 26th, 2004 04:04 PM
Cannot find Professional Java Web Services code? lipeng_cn Wrox Book Feedback 3 February 16th, 2004 10:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.