dwr upload pdf file, error message "file upload not supported"

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

dwr upload pdf file, error message "file upload not supported"

yongyong313
Hallo,

I try to upload some pdf files on server, but I always get the error "dwr file upload not supported".

JSP:

<input type="file" id="f"/>
    <br/>
    <input type="button" value="upload" onclick="upload()"/>

    <script type="text/javascript">
        var upload = function(){
            var file = dwr.util.getValue("f");
            test.upload(file,file.value,function(data){
                alert(data);
            });
        }
       
    </script>


Sever-side:

public class test {
   
    public int upload(InputStream ins,String fileName){
      
        return 10;
    }
}


Error message:

Schwerwiegend: Commons File Upload jar file not found. Aborting request.
Warnung:   Exception while processing batch
java.lang.UnsupportedOperationException: File uploads not supported
    at org.directwebremoting.dwrp.UnsupportedFileUpload.parseRequest(UnsupportedFileUpload.java:41)
    at org.directwebremoting.dwrp.Batch.parsePost(Batch.java:165)
    at org.directwebremoting.dwrp.Batch.<init>(Batch.java:58)
    at org.directwebremoting.dwrp.CallBatch.<init>(CallBatch.java:46)
    at org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:79)
    at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:211)
    at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:185)
    at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:144)
    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)


It says  "Commons File Upload jar file cannot be found", but I have already added them into this project.

The version that I use:

commons-fileupload-1.2.2

commons-io-1.3.2

DWR-Version: 3.


By the way, I also tried to upload .txt file and got the same error.

Can anybody tell me why?


Regards!


Yong


Reply | Threaded
Open this post in threaded view
|

Re: dwr upload pdf file, error message "file upload not supported"

Mike Wilson
Administrator
DWR will only give you that error message if it fails to load these classes from commons-fileupload:
    org.apache.commons.fileupload.FileItem;
    org.apache.commons.fileupload.FileUploadBase.FileSizeLimitExceededException;
    org.apache.commons.fileupload.FileUploadException;
    org.apache.commons.fileupload.disk.DiskFileItemFactory;
    org.apache.commons.fileupload.servlet.ServletFileUpload;
 
I think there is something wrong with your runtime classpath. Check again that these classes are actually available and check your startup log for class loading errors.
 
Best regards
Mike Wilson
 
yonghu wrote:
Hallo,

I try to upload some pdf files on server, but I always get the error "dwr file upload not supported".

JSP:

<input type="file" id="f"/>
    <br/>
    <input type="button" value="upload" onclick="upload()"/>

    <script type="text/javascript">
        var upload = function(){
            var file = dwr.util.getValue("f");
            test.upload(file,file.value,function(data){
                alert(data);
            });
        }
       
    </script>


Sever-side:

public class test {
   
    public int upload(InputStream ins,String fileName){
      
        return 10;
    }
}


Error message:

Schwerwiegend: Commons File Upload jar file not found. Aborting request.
Warnung:   Exception while processing batch
java.lang.UnsupportedOperationException: File uploads not supported
    at org.directwebremoting.dwrp.UnsupportedFileUpload.parseRequest(UnsupportedFileUpload.java:41)
    at org.directwebremoting.dwrp.Batch.parsePost(Batch.java:165)
    at org.directwebremoting.dwrp.Batch.<init>(Batch.java:58)
    at org.directwebremoting.dwrp.CallBatch.<init>(CallBatch.java:46)
    at org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:79)
    at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:211)
    at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:185)
    at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:144)
    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)


It says  "Commons File Upload jar file cannot be found", but I have already added them into this project.

The version that I use:

commons-fileupload-1.2.2

commons-io-1.3.2

DWR-Version: 3.


By the way, I also tried to upload .txt file and got the same error.

Can anybody tell me why?


Regards!


Yong


Reply | Threaded
Open this post in threaded view
|

Re: dwr upload pdf file, error message "file upload not supported"

Mike Wilson
Administrator
BTW, you can debug your problem further by activating debug logging for DWR's startup activities:
    log4j.logger.org.directwebremoting.log.startup=DEBUG
 
Then you will see something like this in the log:
 
Selecting a org.directwebremoting.dwrp.FileUpload from org.directwebremoting.dwrp.CommonsFileUpload, org.directwebremoting.dwrp.UnsupportedFileUpload
- impl:  org.directwebremoting.dwrp.FileUpload = org.directwebremoting.dwrp.CommonsFileUpload
and if it fails to load CommonsFileUpload it will specify a reason.
 
Best regards
Mike
 
Mike Wilson wrote:
DWR will only give you that error message if it fails to load these classes from commons-fileupload:
    org.apache.commons.fileupload.FileItem;
    org.apache.commons.fileupload.FileUploadBase.FileSizeLimitExceededException;
    org.apache.commons.fileupload.FileUploadException;
    org.apache.commons.fileupload.disk.DiskFileItemFactory;
    org.apache.commons.fileupload.servlet.ServletFileUpload;
 
I think there is something wrong with your runtime classpath. Check again that these classes are actually available and check your startup log for class loading errors.
 
Best regards
Mike Wilson
 
yonghu wrote:
Hallo,

I try to upload some pdf files on server, but I always get the error "dwr file upload not supported".

JSP:

<input type="file" id="f"/>
    <br/>
    <input type="button" value="upload" onclick="upload()"/>

    <script type="text/javascript">
        var upload = function(){
            var file = dwr.util.getValue("f");
            test.upload(file,file.value,function(data){
                alert(data);
            });
        }
       
    </script>


Sever-side:

public class test {
   
    public int upload(InputStream ins,String fileName){
      
        return 10;
    }
}


Error message:

Schwerwiegend: Commons File Upload jar file not found. Aborting request.
Warnung:   Exception while processing batch
java.lang.UnsupportedOperationException: File uploads not supported
    at org.directwebremoting.dwrp.UnsupportedFileUpload.parseRequest(UnsupportedFileUpload.java:41)
    at org.directwebremoting.dwrp.Batch.parsePost(Batch.java:165)
    at org.directwebremoting.dwrp.Batch.<init>(Batch.java:58)
    at org.directwebremoting.dwrp.CallBatch.<init>(CallBatch.java:46)
    at org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:79)
    at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:211)
    at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:185)
    at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:144)
    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)


It says  "Commons File Upload jar file cannot be found", but I have already added them into this project.

The version that I use:

commons-fileupload-1.2.2

commons-io-1.3.2

DWR-Version: 3.


By the way, I also tried to upload .txt file and got the same error.

Can anybody tell me why?


Regards!


Yong