Wildfly in production does not recover properties and SQL script values

Asked

Viewed 96 times

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:

inserir a descrição da imagem aqui

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?

  • 1

    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?

  • 1

    You use Maven to build the application?

  • Yes, in a WAR. And I use Maven in the application for dependencies.

  • If you put the properties in the folder src/main/resources/MessageI18N instead of src/main/java/MessageI18N, and do something like the Sqls, which happens?

  • 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.

  • The detail is that the production server is in English, while the others in Portuguese.

  • The Sqls worked at least?

  • 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.

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.