To access resources from classpath use ClassLoader.getResource()never access resources as Files !
2009/10/16 Ivan Martinez <[email protected]> > Hello all, > I have a project with its own configuration file "oid.properties", > which I want to read from the server. The problem is if I place the > file in "src\main\resources" and compile the project, the file goes to > "target\project\WED-INF\classes" and "war\WEB-INF\classes", but if I > run in hosted mode and try to read the file with: > > ServletContext application = servletConfig.getServletContext(); > String pathBase = application.getRealPath(""); > if(!pathBase.endsWith(File.separator)) > pathBase = pathBase + File.separator; > new FileInputStream(pathBase + ficheroConfiguracionOID); > > The actual path where it's looking for the file is > "tomcat\webapps\ROOT\oid.properties" > > I know compilation is not related to hosted mode but I'm quite > confused with the behaviour in both cases. What is the right place for > the file and the right way to find it from the server, so it works > both in hosted mode and in the app server after compiling and > packaging the project?. > > Thank you, > Iván Martínez > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > >
