XStream + JDK 1.4 + IBM Websphere

1 resposta
L

Boa tarde pessoal,

Fiz uma página JSP para ler e gravar um arquivo XML, para desenvolver utilizei o Netbeans e o tomcat, criei o projeto para utilizar JDK 1.4 pois no cliente é utilizado o JDK 1.4, na minha máquina está funcionando normalmente, mas quando publiquei no servidor de produção que é um IBM Websphere eu tive o seguinte erro:

Error 500: com/thoughtworks/xstream/io/StreamException

Alguem já passou por algo parecido e pode me dar uma ajuda?
Pesquisei e encontrei este post: http://www.guj.com.br/posts/list/84829.java já fiz o que está descrito lá, mas não adiantou…
Será que pode ser permissão de escrita na pasta aonde salvo o XML ?

Se alguem tiver alguma idéia eu agradeço desde já, pois estou perdido

Obrigado

Att.
Leonardo Lima

Abaixo segue a classe que criei para gerar o XML

public class XmlUtil {

    private final XStream xstream;
    private final String filePath;
    private String fileName;
    private String fullPath;
    private File arquivoXML;

    public XmlUtil(String filePath, String fileName) throws IOException {
        this.xstream = new XStream();
        xstream.alias("contato", Contato.class);

        this.filePath = filePath;
        this.fileName = fileName;
        this.fullPath = filePath + File.separator + fileName;
        ajustaCaminhoArquivos();
    }

    public List carregarXML() throws IOException {
        try {
            FileReader reader = new FileReader(arquivoXML);
            //List contatosExistente = (List) xstream.fromXML(reader);
            List contatosExistente = (List) xstream.fromXML(new FileInputStream(arquivoXML));
            reader.close();
            return contatosExistente;

        } catch (StreamException ex) {
            return null;
        }
    }

    public void salvarXML(List contatosExistentes) {
        try {
            FileOutputStream fs = new FileOutputStream(arquivoXML);
            xstream.toXML(contatosExistentes, fs);
            fs.close();
        } catch (IOException ex) {
            Logger.getLogger(XmlUtil.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void ajustaCaminhoArquivos() throws IOException {
        File folder = new File(filePath);
        if (!folder.exists()) {
            boolean createSuccess = folder.mkdirs();
            if (!createSuccess) {
                throw new FileNotFoundException("Não foi possível criar um novo diretório!");
            }
        }

        arquivoXML = new File(fullPath);
        if (!arquivoXML.exists()) {
            arquivoXML.createNewFile();
        }
    }

    public void gerarArquivoBackup() throws IOException {
        String backupFilename = fileName + "_BKP_" + DateUtil.retornaStringDataAtualFormatada("dd_MM_yyyy_HH_mm_ss_SSS") + ".xml";
        String backupFileFullPath = filePath + File.separator + backupFilename;
        File backupFile = new File(backupFileFullPath);
        FileUtils.copyFile(arquivoXML, backupFile);
    }
}

1 Resposta

L

Olá pessoal,

Alguma dica ???

Obrigado

Att.
Leonardo Lima

Criado 8 de julho de 2010
Ultima resposta 12 de jul. de 2010
Respostas 1
Participantes 1