Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Aquivo properties - resolvido

Tenho este properties. D:/ide/workspace_luna/erp/erp-modelo/src/main/resources/APP_MSG_AUTH.properties. Mas logico que quando eu colocar no servidor vai dar erro.

Como faze para pegar o caminho absoluto até chegar neste arquivo, indepedente de onde esteja incluído ?

Meu código está assim:

package br.eti.netsoft.erp.bundle;

    import java.io.FileInputStream;
    import java.io.IOException;
    import java.util.Properties;

    public class BundleErpMensagem extends BundleErp {

        private static final String CAMINHO_PROPERTIES_MSG = "D:/ide/workspace_luna/erp/erp-modelo/src/main/resources/APP_MSG_AUTH.properties";

        public BundleErpMensagem() {
            iniciaPropriedade();
        }

        private Properties getPropertiesMensagem() throws IOException {
            Properties props = new Properties();

            FileInputStream file = new FileInputStream(CAMINHO_PROPERTIES_MSG);
            props.load(file);
            return props;
        }

        private void iniciaPropriedade() {
            try {
                setProp(getPropertiesMensagem());
            } catch (IOException e) {
                logger.error(e.getMessage(), e);
            }
        }
    }

Só que quando coloco a aplicação no servidor, lógico, ele não acha este caminho.

1 resposta
solução!

Ficou assim e resolveu.

package br.eti.netsoft.erp.bundle;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class BundleErpMensagem extends BundleErp {

    public BundleErpMensagem() {
        iniciaPropriedade();
    }

    private Properties getPropertiesMensagem() throws IOException {
        Properties props = new Properties();
        InputStream file = getClass().getClassLoader().getResourceAsStream(
                "APP_MSG_AUTH.properties");
        props.load(file);
        return props;
    }

    private void iniciaPropriedade() {
        try {
            setProp(getPropertiesMensagem());
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        }
    }
}