Thanks to @AndréSchild comment (thank you) I realized the WAR file wasn't including Bundle.properties
. After doing some Google search I have found how to include resources to Maven project by editing pom.xml
file in this article. It presents two different ways to solve my problem:
Place .properties file inside resources folder
By default, Maven will look for your project's resources under
src/main/resources
.Project |-- pom.xml `-- src `-- main `-- resources
This basically states that I could simply place Bundle.properties
file inside resources
folder and it will be included in WAR file.
This file will be located at the root of classpath so I have to do this change in MyVaadinUI.java
class:
private final ResourceBundle bundle = ResourceBundle.getBundle("Bundle");
Add the folder as resource editing pom.xml file
If we want to add some resource which is not placed in src/main/resources
folder we can edit pom.xml
file adding a resource folder as follows:
<project>
...
<build>
...
<resources>
<resource>
<directory>[our folder here]</directory>
</resource>
</resources>
...
</build>
...
</project>
So in my case I could do something like this:
<project>
...
<build>
...
<resources>
<directory>src/main/java/com/mycompany/i18ntest</directory>
<includes>
<include>*.properties</include>
</includes>
</resources>
...
</build>
...
</project>
When WAR file is generated it will include the content of the specified resource folder (in addition to /src/main/resources
fodler content) at the root of classpath. Once again I have to do this change:
private final ResourceBundle bundle = ResourceBundle.getBundle("Bundle");
Note: despite NetBeans shows all files in the resource folder, only .properties
files will be included in WAR file because of this filter:
<includes>
<include>*.properties</include>
</includes>