Teminei o curso e o projeto e não sei porque ao executar o lista.xhtml passou a apresentar a seguinte mensagem de erro(lembrando que a aplicacao esta funcionando perfeitamente tanto no index.xhtml quanto no livro-detalhe ):
16:42:46,933 ERROR [io.undertow.request] (default task-44) UT005023: Exception handling request to /casadocodigo/file/: java.lang.RuntimeException: java.io.FileNotFoundException: \casadocodigo (Acesso negado)
at br.com.casadocodigo.loja.infra.FileSaver.transfer(FileSaver.java:46)
at br.com.casadocodigo.loja.servlets.FileServlet.service(FileServlet.java:33)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: \casadocodigo (Acesso negado)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at br.com.casadocodigo.loja.infra.FileSaver.transfer(FileSaver.java:33)
... 29 more
public class FileSaver {
public static final String SERVER_PATH = "/casadocodigo";
public String write(Part arquivo, String path){
String relativePath = path +"/"+ arquivo.getSubmittedFileName();
try {
arquivo.write(SERVER_PATH +"/"+ relativePath);
return relativePath;
}catch (IOException e){
throw new RuntimeException(e);
}
}
public static void transfer(Path source, OutputStream outputStream) {
try {
FileInputStream input = new FileInputStream(source.toFile());
try(ReadableByteChannel inputChannel = Channels.newChannel(input);
WritableByteChannel outputChannel = Channels.newChannel(outputStream)){
ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10);
while(inputChannel.read(buffer) != -1){
buffer.flip();
outputChannel.write(buffer);
buffer.clear();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
} catch (File