0

I'm giving a try to the Servlet 3.0 fileupload feature, with the code parsed from here: http://www.codejava.net/java-ee/servlet/java-file-upload-example-with-servlet-30-api

Well, I try to upload some file, and I always get the same exceptions:

Web error:

type Exception report

message Internal Server Error

description The server encountered an internal error that prevented it from fulfilling this request.

exception java.io.FileNotFoundException: C:\Users\usuario1.s00win81\GlassFish_Server\glassfish\domains\domain1\generated\jsp\UploadingFiles\C:\Users\usuario1.s00win81\Documents\NetBeansProjects\UploadingFiles\build\web\uploadFiles\Soluciones evaluación.txt (El nombre de archivo, el nombre de directorio o la sintaxis de la etiqueta del volumen no son correctos)

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.1 logs.

Glassfish server:

Advertencia: StandardWrapperValve[Servlets.UploadServlet]: Servlet.service() for servlet Servlets.UploadServlet threw exception java.io.FileNotFoundException: C:\Users\usuario1.s00win81\GlassFish_Server\glassfish\domains\domain1\generated\jsp\UploadingFiles\C:\Users\usuario1.s00win81\Documents\NetBeansProjects\UploadingFiles\build\web\uploadFiles\filetest.txt (El nombre de archivo, el nombre de directorio o la sintaxis de la etiqueta del volumen no son correctos) at java.io.FileOutputStream.open0(Native Method) at java.io.FileOutputStream.open(FileOutputStream.java:270) at java.io.FileOutputStream.(FileOutputStream.java:213) at java.io.FileOutputStream.(FileOutputStream.java:162) at org.apache.catalina.fileupload.PartItem.write(PartItem.java:450) at org.apache.catalina.fileupload.PartItem.write(PartItem.java:505) at Servlets.UploadServlet.doPost(UploadServlet.java:49) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) at java.lang.Thread.run(Thread.java:745)

Am I doing something wrong?

More info:

  • JDK 8
  • Netbeans 8.1
  • Glassfish 4.1
  • I tried to upload several files, all of them tiny (just a few KBs).

edit: FIXED

The path was wrong. Actually, I guess that the code I copied wasn't good. I created manually the folder where the uploaded file will go, and just used a relative path instead of an absolute one, and it began to work. Gotta add later a better answer with what I changed!

Zerok
  • 227
  • 4
  • 19
  • Particularly check the "Saving uploaded file" section of the abovelinked duplicate. – BalusC Sep 12 '16 at 07:47
  • @BalusC This is a different problem... the uploading logic is all here, nothing's missing. This question is to assess the exception I'm having (which I don't find a solution for). – Zerok Sep 12 '16 at 07:54
  • Ok, I found out what was happening! Gotta edit in a moment – Zerok Sep 12 '16 at 08:06
  • 1
    All due respect, it's not a different problem, Zerok. The duplicate explains that many online sources are doing a terrible bad job in this, and shows the correct way and links to a.o. http://stackoverflow.com/questions/18664579. The code snippet you found is in one word terrible. It's clearly written by an amateur with lack of fundamental understanding. Never ever trust so-called "online tutorial" sites founded somewhere in south east Asia when they are full of copypasted code and advertisement banners. With no exception they are all terrible. – BalusC Sep 12 '16 at 08:16

0 Answers0