Skip to main content

Problem with opening files in JAX-WS with tomcat

No replies
Joined: 2010-02-11

Hi all ...

I have a JAX-WS webservice deployed on tomcat
At the webservice startup I need to load a configuration file based on it's relative path (the file is inside the WEB-INF/config)
my code is like that:

public class MyWebservice {

public MyWebservice() {
File file = new File("./config/myConfiguration.xml")

public void webserviceMethod() {


but that doesn't work ..... the result of the printf is:

I need something to the get the path to my tomcat WEB-INF
please, what can I do ?

I know I could do this:

@Resource private WebServiceContext wsc;

MessageContext ctxt = wsc.getMessageContext();
ServletContext req = (ServletContext) ctxt.get(ctxt.SERVLET_CONTEXT);
String contextPath = req.getRealPath("WEB-INF");

but this way I need to wait for a request to load the file ... I want to load it at the webservice startup