2
I am using a development environment and another production environment, in the development environment using the concept of i18n (Internationalization) is recovered correctly for example the value of label.carro
that is Carro
, but I put on the production server (which has no client), and it is returned in caption in HTML the value label.carro
and not Carro
how it should be returned, ie this is not reading the extension file .properties
included in the project’s Java Build Path.
The same happens when recovering a file .sql
, returns the error NullPointerException
when browsing a list of SQL files.
Follow the image of the files in Project Explorer:
Code that recovers files with extension . properties:
import java.util.Locale;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.context.support.ResourceBundleMessageSource;
public class MessageI18n {
private Locale locale;
public MessageI18n(Locale locale) {
this.locale = locale;
}
public MessageI18n() {
locale = LocaleContextHolder.getLocale();
}
public String getMessage(String code) {
ResourceBundleMessageSource m = new ResourceBundleMessageSource();
m.setBasenames("MessageI18N/ValidationMessages","MessageI18N/messages");
return m.getMessage(code, null, this.locale);
}
}
Code that recovers SQL files, but Nullpointerexception error occurs while entering the repeat loop:
List<String> lst = new ArrayList<String>();
ClassLoader classLoader = getClass().getClassLoader();
File folder = new File(classLoader.getResource("dataBaseVersion").getFile());
for (final File fileEntry : folder.listFiles()) {
// Resto dos códigos
}
What intrigues me is why you can read the files in development mode, but not in production mode and the settings are the same?
Would you know if the files are running inside a JAR/WAR/EAR on the server? Or if the contents of this JAR/WAR/EAR are exploded? And in the development environment?
– Victor Stafusa
You use Maven to build the application?
– Victor Stafusa
Yes, in a WAR. And I use Maven in the application for dependencies.
– Giancarlo Abel Giulian
If you put the properties in the folder
src/main/resources/MessageI18N
instead ofsrc/main/java/MessageI18N
, and do something like the Sqls, which happens?– Victor Stafusa
I did what you said, we tested on two other machines, the one with external IP (which is the production) and the one with internal IP, worked smoothly on the internal machines, but not on the external one that uses Windows Server 2008. Now it remains to know why and should work at all because of JVM and Wildfly with the same settings.
– Giancarlo Abel Giulian
The detail is that the production server is in English, while the others in Portuguese.
– Giancarlo Abel Giulian
The Sqls worked at least?
– Victor Stafusa
I fixed the error, as the server was in English and there were no properties in
en
this problem occurred, I thought I took from the client and passed to the server the language of the client, not to take the language of the server and yes of the client I believe it is a question for another question. As for sql, I haven’t been able to solve it yet, but instead of getting the path from where Deployment is taking a file that doesn’t exist in the user’s document folder.– Giancarlo Abel Giulian