Boa Tarde pessoal, estamos fazendo uma aplicação e nela colocamos um formulario para anexar aquivos, testamos estava funcionando normal anexando salvando o caminho no banco, publicamos, porem houve uma mudanca de servidor, agora é servidor linux ja troquei o nome do caminho mais nao vai nem por nada vou posta o metodo,form e o erro que esta ocorrendo, se alguem puder me ajude ae…
public void processFileUpload(FileUploadEvent event) throws IOException {
this.arquivoSetadoParaUpload = true;
try {
UploadedFile arq = event.getFile();
InputStream in = new BufferedInputStream(arq.getInputstream());
//File file = new File("C://SICDE Documentos//" + alteraCaracter(arq.getFileName()));
File file = new File("/home/semges/Documentos/SICDE/" + alteraCaracter(arq.getFileName()));
String tipoArquivo = arq.getFileName().substring(arq.getFileName().lastIndexOf('.') + 1);
String nomeArquivo = alteraCaracter(arq.getFileName().replace("." + tipoArquivo, ""));
String pathArquivo = alteraCaracter(file.getAbsolutePath());
FileOutputStream fout = new FileOutputStream(file);
while (in.available() != 0) {
fout.write(in.read());
fout.flush();
}
Arquivo a = new Arquivo();
a.setNome(nomeArquivo);
a.setTipo(tipoArquivo);
a.setCaminho(pathArquivo);
this.arquivosParaUpload.add(a);
fout.close();
in.close();
System.out.println("Arquivo '" + file.getName() + "' anexado com sucesso!");
FacesUtils.messageInfo("Arquivo '" + file.getName() + "' anexado com sucesso!");
} catch (Exception ex) {
FacesUtils.messageError("Erro ao anexar arquivo: " + ex.getMessage());
}
}
o formulario
<h:form prependId="false">
<p:dialog header="Anexe arquivos aqui!" draggable="true"
widgetVar="anexosDialog" resizable="false" modal="true" width="700"
showEffect="fold" hideEffect="fold" onCloseUpdate="formNovaDemanda">
<h:panelGrid columns="3" style="margin-bottom: 15px;">
<h:graphicImage library="images" name="icon_info.gif" />
<h:outputText
value="Clique no link abaixo para inserir arquivos (Tipos permitidos: .doc, .docx, .pdf, .xls, .xlsx)."
styleClass="label-info" />
<h:graphicImage library="images" name="upload32.png" width="24"
height="24" />
</h:panelGrid>
<p:fieldset>
<h:panelGrid columns="1" cellpadding="2" cellspacing="5"
style="margin-bottom: 10px;" id="addArquivo">
<p:fileUpload vmode="advanced" auto="true"
fileUploadListener="#{demandaController.processFileUpload}"
multiple="true" label="Anexar arquivo..."
allowTypes="*.doc;*.pdf;*.xls;*.docx;*.xlsx" description="Images" height="32"
width="32" customUI="true" widgetVar="uploader"
image="/resources/images/upload32.png"
update="gridViewArquivos, addArquivo" />
<p:fileUpload vmode="advanced" auto="true"
fileUploadListener="#{demandaController.processFileUpload}"
multiple="true" label="Anexar arquivo..."
allowTypes="*.doc;*.pdf;*.xls;*.docx;*.xlsx" description="Images"
customUI="true" widgetVar="uploader"
value="Clique Aqui!"
update="gridViewArquivos, addArquivo" />
</h:panelGrid>
<h:panelGrid columns="1" id="gridViewArquivos"
cellpadding="2" cellspacing="5" style="margin-top:5px;">
<p:dataTable var="arq" emptyMessage="Nenhum arquivo anexado!"
value="#{demandaController.arquivosParaUpload}">
<p:column headerText="Nome">
<h:outputText value="#{arq.nome}" />
</p:column>
<p:column headerText="Tipo">
<h:outputText value="#{arq.tipo}" />
</p:column>
<p:column style="width:32px; align:center;">
<p:commandLink
actionListener="#{demandaController.removeArquivoParaUpload}"
update="gridViewArquivos">
<h:graphicImage library="images" name="close-32.png" height="16"
width="16" />
<f:setPropertyActionListener value="#{arq}"
target="#{demandaController.arquivoSelecionado}" />
</p:commandLink>
</p:column>
</p:dataTable>
</h:panelGrid>
</p:fieldset>
<p:growl id="growFaltaArquivo" globalOnly="true" />
<h:panelGrid id="displayBtn4" columns="2"
style="margin-top: 15px; float: right">
<p:commandLink oncomplete="anexosDialog.hide()"
update="formNovaDemanda" title="Confirmar Anexos">
<h:graphicImage library="images" name="confirmar.png" width="48"
height="48" />
</p:commandLink>
</h:panelGrid>
</p:dialog>
</h:form>
e o erro …
17/01/2012 11:05:34 org.primefaces.webapp.MultipartRequest parseRequest
SEVERE: Error in parsing fileupload request