GeeCON Prague 2014*
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven Project loading props file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven Project loading props file" Watch "Maven Project loading props file" New topic
Author

Maven Project loading props file

Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
If this isn't the proper place to post this I apologize however it seems to be maven related so lets give it a try. The issue is as follows. I have a project setup using maven as I have with pretty much all of my projects. Within this project I have standard code to load a props file from a resource stream. The properties file is located in the resources directory and is copied to the target directory as it should be on build. However when I run the project I get FileNotFoundException even though it is in the class path. Is there a trick to getting this to work with maven builds? I'm getting a bit tired of dealing with it. My environment consist of Netbeans 6.1 MavenIDE plugin (3.1.3)and the standard project archetype. Any ideas? I appreciate your time.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5835
    
    7

From your description, it should be working (provided you did everything correct ;-) ). Have you looked to see if the properties file is packaged in the JAR file? Have you verified that the relative path in the JAR file (or in target/classes) matches the properties file name used in the app? (For example, when I load a properties file located at some/package/my.properties, I use the name "some.pakage.my").

If that does not help you solve the problem, please provide the following:

1) The exact classpath being used for your app (to help in debugging this, it might be best to not run the app from within NetBeans - once you get it running stand-alone you can then work on getting it running in NetBeans)

2) The exact location of the properties file. If you package it in a JAR, then the relative path within the JAR, and an indication of which JAR it is in.

3) The code you are using to load the properties file.


JBoss In Action
 
GeeCON Prague 2014
 
subject: Maven Project loading props file