Hi,
I believe this forces me to change the location of the web apps data files.
Right now they are located under WEB-INF/data/somedata.xml. So if I use a
ContextClassLoader then I have to change the location of the files when the
webapp is deployed in production right?
Thanks,
- Ole
On 10/11/2011 03:25 AM, Olivier Lamy wrote:
Hello,
Why not simply put your resources in src/main/resources and load it
with Thread.currentThread().getContextClassLoader().getResourceAsStream(
path in classloader ) ?
2011/10/11 Ole Ersoy<ole.er...@gmail.com>:
Maybe if i explain what I'm trying to do, it will make more sense. I have a
maven webapp project. I'm running it with:
mvn tomcat:run
When I run the webapp I would like to load resources from
"WEB-INF/resources/...". When running a webapp in a standalone container
"WEB-INF" is located in the "root" folder. However because I'm using maven
to run the webapp, the "WEB-INF" folder is located under "src/main/webapp".
Therefore if I want to test resource loading I need to add
"src/main/webapp" to the path of the resource when running with:
mvn tomcat:run.
So for example running with "mvn tomcat:run" I have to load myresource.xml
like this:
application.load("src/main/webapp/WEB-INF/resources/myresource.xml");
However when deploying in a standalone container the same resource would be
loaded like this:
application.load("WEB-INF/resources/theresource.xml");
I'm trying to avoid having to change my application configuration for
testing in a standalone container and testing with:
mvn tomcat:run
Does that make sense?
Thanks,
- Ole
On 10/10/2011 04:26 PM, Olivier Lamy wrote:
2011/10/10 Ole Ersoy<ole.er...@gmail.com>:
I'm running the tomcat plugin configured as follows:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
</configuration>
</plugin>
If I run the following line from a servlet the application is running:
logger.trace("The current root directory is: {} ", new
File("").getAbsolutePath());
I would expect to see "The current root directory is:
${basedir}/src/main/webapp". However the result is:
"The current root directory is: ${basedir}". In other words it seems the
<warSourceDirectory> configuration has not taken effect.
you should read current root webapp directory in the servlet container.
this means if you go with your browser to http://localhost:${port}/
you will see files from this directory.
Thoughts? TIA,
- Ole
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org