Hello,

I have a Maven project with resource files in src/main/resources. Currently
the jar file generated includes the resources in the jar but I'd like them
outside of the jar file ideally in the same directory as the jar file so I
added the <resources> section to my pom.xml as follows:

  <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-jar-plugin</artifactId>
              <version>2.4</version>
              <configuration>
                  <archive>
                      <manifest>
                          <addClasspath>true</addClasspath>
                          <mainClass>it.myapp</mainClass>
                      </manifest>
                      <manifestEntries>
                          <Class-Path>.</Class-Path>
                      </manifestEntries>
                  </archive>
              </configuration>
          </plugin>
      </plugins>
      <resources>
          <resource>
              <directory>src/main/resources</directory>
              <targetPath>..</targetPath>
          </resource>
      </resources>
  </build>
The problem is when I attempt to clean and build, my JUnit tests fail due
to an exception:

Caused by: java.util.MissingResourceException: Can't find bundle for base
name MessageResourceBundle, locale en_US
 at
java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499)
 at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322)
 at java.util.ResourceBundle.getBundle(ResourceBundle.java:724)
If I remove the <resources> section, the clean and build is successful but
my resources files are inside the jar. I want them on the outside.
I verified the above in a separate test project without a message resource
bundle so the problem is with the bundle but why? How do I fix this?

Reply via email to