2

I should design a localized App,But finally this error returns :

Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name messages, locale fa

Piece of code:

 ResourceBundle bundle =
            ResourceBundle.getBundle("messages",new Locale("fa"));

and image from my project structure(I tested it jsp page with similar error now I'm testing in a class with main method (TestCalender.java)) :

enter image description here


EDIT:

I saw similar questions and test their answers but no changes detected in my error!

Mammadreza
  • 84
  • 8
  • According to an answer on a similar question, it's looking for the bundle at the root of the classpath and that isn't where the bundle is located. – BSMP Jul 08 '15 at 19:31
  • possible duplicate of [Can't find bundle for base name /Bundle, locale en\_US](http://stackoverflow.com/questions/12986234/cant-find-bundle-for-base-name-bundle-locale-en-us) – BSMP Jul 08 '15 at 19:31
  • Unlike.Nope!I put the bundles in several places also root of calsspatp but No Change!!! – Mammadreza Jul 08 '15 at 19:44
  • I solve that by copy bundles to target dir!!!! I don't know why they doesn't copied here automatic !! @BSMP Do yo know ? – Mammadreza Jul 08 '15 at 20:06
  • I don't know why that isn't automatic but you can add that as the answer to the question so others can see that there's a solution. – BSMP Jul 08 '15 at 20:28
  • Sure,I add answer after finding best solution ;) – Mammadreza Jul 09 '15 at 03:58

1 Answers1

2

I found that :

Because of I'm using Maven and Some configs should add to pom.xml file for adding resources to target dir.

Here's what I did:

     <plugins>
        <!--Some plugins omitted >
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include> **/*.properties</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include> **/*.xml</include>
            </includes>
        </resource>
    </resources>
Mammadreza
  • 84
  • 8