(no such file or directory) getClass().getResource(
12/01/2018
0
Olá,
Tenho um projeto Web em Maven.
Quando starto o Tomcat no Eclipse e acesso no navegador, o sistema funciona normalmente. Quando eu gero o .war e faço o deploy no servidor, ele não consegue carregar esse arquivo, erro "no such file or directory".
Já até conferi no servidor se o arquivo estava no caminho correto depois do deploy, e estava sim.
Alguém pode me auxiliar?
(no such file or directory)
getClass().getResource("/redes/file.zip").getFile();
Tenho um projeto Web em Maven.
Quando starto o Tomcat no Eclipse e acesso no navegador, o sistema funciona normalmente. Quando eu gero o .war e faço o deploy no servidor, ele não consegue carregar esse arquivo, erro "no such file or directory".
Já até conferi no servidor se o arquivo estava no caminho correto depois do deploy, e estava sim.
Alguém pode me auxiliar?
(no such file or directory)
getClass().getResource("/redes/file.zip").getFile();
Wellington Oliveira
Curtir tópico
+ 0
Responder
Posts
12/01/2018
Wellington Oliveira
I made a change on my code and now it works fine:
i changed this:
to this:
i changed this:
File file = new File(getClass().getResource(caminhoRede).getFile());
to this:
InputStream in = getClass().getResourceAsStream(caminhoRede); File file = File.createTempFile("stream2file", ".tmp"); file.deleteOnExit(); try (FileOutputStream out = new FileOutputStream(file)) { IOUtils.copy(in, out); }
Responder
Clique aqui para fazer login e interagir na Comunidade :)