[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.technology.m2e] Re: Specifying resources for runtime usage?

"mlt" <ddd@xxxxxxx> wrote in message news:h1fh8m$m8v$1@xxxxxxxxxxxxxxxxxxxx
I have some xml files in a maven module in:

src/main/resources

which is loaded in my application with:

   URL url = this.getClass().getClassLoader().getResource("somexml.xml");

When running my application from eclipse the files are found and used correctly.

When I build my application using "mvn install" and then run it those resources are not found/used. I have opened the .jar files (created during the packaging) and the resources are included. I have also tried to add:

  <build>
  <resources>
    <resource>
      <directory> src\main\resources</directory>
    </resource>
  </resources>
  </build>

to the pom.xml file but that does not help.

Any ideas on how to use resources from the packaged jar files when running an application?



The resources is loaded:
...
URL url = this.getClass().getClassLoader().getResource("somexmlfile.xml");
try {
file = new File(url.getPath());
} catch (Exception e) {


   }

I have also tried:
file = new File(url.toURI());

but this throws:

URI is not hierarchical exception.

It seems that this problem is not that the resource is not found but rather how to use it. I will find another forum, but if anyone in here has an idea you are welcome to make a comment.