Results 1 to 16 of 16
  1. #1
    irakli_dev is offline Member
    Join Date
    Dec 2011
    Location
    Tbilisi (Georgia)
    Posts
    24
    Rep Power
    0

    Default problem with uploading file

    i want to do upload file in my app and i took this example
    Uploading Files in a Visual Web JSF Application - NetBeans IDE 6.5 Tutorial
    but after uploadedFile.write(file); i getting null pont exception but i have file name choosen
    anyone can help me?

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    irakli_dev is offline Member
    Join Date
    Dec 2011
    Location
    Tbilisi (Georgia)
    Posts
    24
    Rep Power
    0

    Default Re: problem with uploading file

    Java Code:
    try {
                    File file = new File(this.realImageFilePath);
                    uploadedFile.write(file);
                } catch (Exception ex) {    
                    error("Cannot upload file: " + justFileName);
                }
    there appears ex=(java.lang.NullPointerException) java.lang.NullPointerException
    Last edited by Eranga; 01-10-2012 at 12:53 PM. Reason: code tags added

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default Re: problem with uploading file

    That is not the complete error you end with. There should be more. If you have look at the error message carefully you can see line number where your error picks.

  5. #5
    irakli_dev is offline Member
    Join Date
    Dec 2011
    Location
    Tbilisi (Georgia)
    Posts
    24
    Rep Power
    0

    Default Re: problem with uploading file

    Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.

    Exception Details: java.lang.NullPointerException
    null

    Possible Source of Error:
    Class Name: com.sun.webui.jsf.util.UploadFilterFileItem
    File Name: UploadFilterFileItem.java
    Method Name: write
    Line Number: 459

    Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    com.sun.webui.jsf.util.UploadFilterFileItem.write( UploadFilterFileItem.java:459)
    com.sun.webui.jsf.component.Upload$UploadedFileImp l.write(Upload.java:435)
    fileuploadexample.Page1.uploadFileButton_action(Pa ge1.java:280)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ eMethodAccessorImpl.java:-2)
    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.sun.el.parser.AstValue.invoke(AstValue.java:18 7)
    com.sun.el.MethodExpressionImpl.invoke(MethodExpre ssionImpl.java:297)
    javax.faces.component.MethodBindingMethodExpressio nAdapter.invoke(MethodBindingMethodExpressionAdapt er.java:77)
    com.sun.faces.application.ActionListenerImpl.proce ssAction(ActionListenerImpl.java:91)
    com.sun.rave.web.ui.appbase.faces.ActionListenerIm pl.processAction(ActionListenerImpl.java:91)
    javax.faces.component.UICommand.broadcast(UIComman d.java:383)
    com.sun.webui.jsf.component.WebuiCommand.broadcast (WebuiCommand.java:160)
    javax.faces.component.UIViewRoot.broadcastEvents(U IViewRoot.java:447)
    javax.faces.component.UIViewRoot.processApplicatio n(UIViewRoot.java:752)
    com.sun.faces.lifecycle.InvokeApplicationPhase.exe cute(InvokeApplicationPhase.java:97)
    com.sun.faces.lifecycle.LifecycleImpl.phase(Lifecy cleImpl.java:251)
    com.sun.faces.lifecycle.LifecycleImpl.execute(Life cycleImpl.java:117)
    com.sun.faces.extensions.avatar.lifecycle.PartialT raversalLifecycle.execute(PartialTraversalLifecycl e.java:94)
    javax.faces.webapp.FacesServlet.service(FacesServl et.java:244)
    org.apache.catalina.core.ApplicationFilterChain.se rvletService(ApplicationFilterChain.java:427)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:333)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:214)
    com.sun.webui.jsf.util.UploadFilter.doFilter(Uploa dFilter.java:370)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:246)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:214)
    org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:313)
    org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:287)
    org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:218)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
    com.sun.enterprise.web.WebPipeline.invoke(WebPipel ine.java:94)
    com.sun.enterprise.web.PESessionLockingStandardPip eline.invoke(PESessionLockingStandardPipeline.java :98)
    org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:222)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
    org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:587)
    org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:1096)
    org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:166)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
    org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:587)
    org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:1096)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:288)
    com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.invokeAdapter(DefaultProcessorTask.jav a:647)
    com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.doProcess(DefaultProcessorTask.java:57 9)
    com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.process(DefaultProcessorTask.java:831)
    com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.executeProcessorTask(DefaultReadTask.java:3 41)
    com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.doTask(DefaultReadTask.java:263)
    com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.doTask(DefaultReadTask.java:214)
    com.sun.enterprise.web.connector.grizzly.TaskBase. run(TaskBase.java:265)
    com.sun.enterprise.web.connector.grizzly.ssl.SSLWo rkerThread.run(SSLWorkerThread.java:106)


    Exception Details: javax.faces.el.EvaluationException
    java.lang.NullPointerException

    Possible Source of Error:
    Class Name: javax.faces.component.MethodBindingMethodExpressio nAdapter
    File Name: MethodBindingMethodExpressionAdapter.java
    Method Name: invoke
    Line Number: 91

    Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    javax.faces.component.MethodBindingMethodExpressio nAdapter.invoke(MethodBindingMethodExpressionAdapt er.java:91)
    com.sun.faces.application.ActionListenerImpl.proce ssAction(ActionListenerImpl.java:91)
    com.sun.rave.web.ui.appbase.faces.ActionListenerIm pl.processAction(ActionListenerImpl.java:91)
    javax.faces.component.UICommand.broadcast(UIComman d.java:383)
    com.sun.webui.jsf.component.WebuiCommand.broadcast (WebuiCommand.java:160)
    javax.faces.component.UIViewRoot.broadcastEvents(U IViewRoot.java:447)
    javax.faces.component.UIViewRoot.processApplicatio n(UIViewRoot.java:752)
    com.sun.faces.lifecycle.InvokeApplicationPhase.exe cute(InvokeApplicationPhase.java:97)
    com.sun.faces.lifecycle.LifecycleImpl.phase(Lifecy cleImpl.java:251)
    com.sun.faces.lifecycle.LifecycleImpl.execute(Life cycleImpl.java:117)
    com.sun.faces.extensions.avatar.lifecycle.PartialT raversalLifecycle.execute(PartialTraversalLifecycl e.java:94)
    javax.faces.webapp.FacesServlet.service(FacesServl et.java:244)
    org.apache.catalina.core.ApplicationFilterChain.se rvletService(ApplicationFilterChain.java:427)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:333)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:214)
    com.sun.webui.jsf.util.UploadFilter.doFilter(Uploa dFilter.java:370)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:246)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:214)
    org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:313)
    org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:287)
    org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:218)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
    com.sun.enterprise.web.WebPipeline.invoke(WebPipel ine.java:94)
    com.sun.enterprise.web.PESessionLockingStandardPip eline.invoke(PESessionLockingStandardPipeline.java :98)
    org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:222)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
    org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:587)
    org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:1096)
    org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:166)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
    org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:587)
    org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:1096)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:288)
    com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.invokeAdapter(DefaultProcessorTask.jav a:647)
    com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.doProcess(DefaultProcessorTask.java:57 9)
    com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.process(DefaultProcessorTask.java:831)
    com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.executeProcessorTask(DefaultReadTask.java:3 41)
    com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.doTask(DefaultReadTask.java:263)
    com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.doTask(DefaultReadTask.java:214)
    com.sun.enterprise.web.connector.grizzly.TaskBase. run(TaskBase.java:265)
    com.sun.enterprise.web.connector.grizzly.ssl.SSLWo rkerThread.run(SSLWorkerThread.java:106)


    Exception Details: javax.faces.FacesException
    #{Page1.uploadFileButton_action}: java.lang.NullPointerException

    Possible Source of Error:
    Class Name: com.sun.faces.application.ActionListenerImpl
    File Name: ActionListenerImpl.java
    Method Name: processAction
    Line Number: 107

    Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    com.sun.faces.application.ActionListenerImpl.proce ssAction(ActionListenerImpl.java:107)
    com.sun.rave.web.ui.appbase.faces.ActionListenerIm pl.processAction(ActionListenerImpl.java:91)
    javax.faces.component.UICommand.broadcast(UIComman d.java:383)
    com.sun.webui.jsf.component.WebuiCommand.broadcast (WebuiCommand.java:160)
    javax.faces.component.UIViewRoot.broadcastEvents(U IViewRoot.java:447)
    javax.faces.component.UIViewRoot.processApplicatio n(UIViewRoot.java:752)
    com.sun.faces.lifecycle.InvokeApplicationPhase.exe cute(InvokeApplicationPhase.java:97)
    com.sun.faces.lifecycle.LifecycleImpl.phase(Lifecy cleImpl.java:251)
    com.sun.faces.lifecycle.LifecycleImpl.execute(Life cycleImpl.java:117)
    com.sun.faces.extensions.avatar.lifecycle.PartialT raversalLifecycle.execute(PartialTraversalLifecycl e.java:94)
    javax.faces.webapp.FacesServlet.service(FacesServl et.java:244)
    org.apache.catalina.core.ApplicationFilterChain.se rvletService(ApplicationFilterChain.java:427)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:333)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:214)
    com.sun.webui.jsf.util.UploadFilter.doFilter(Uploa dFilter.java:370)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:246)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:214)
    org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:313)
    org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:287)
    org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:218)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
    com.sun.enterprise.web.WebPipeline.invoke(WebPipel ine.java:94)
    com.sun.enterprise.web.PESessionLockingStandardPip eline.invoke(PESessionLockingStandardPipeline.java :98)
    org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:222)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
    org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:587)
    org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:1096)
    org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:166)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
    org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:587)
    org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:1096)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:288)
    com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.invokeAdapter(DefaultProcessorTask.jav a:647)
    com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.doProcess(DefaultProcessorTask.java:57 9)
    com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.process(DefaultProcessorTask.java:831)
    com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.executeProcessorTask(DefaultReadTask.java:3 41)
    com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.doTask(DefaultReadTask.java:263)
    com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.doTask(DefaultReadTask.java:214)
    com.sun.enterprise.web.connector.grizzly.TaskBase. run(TaskBase.java:265)
    com.sun.enterprise.web.connector.grizzly.ssl.SSLWo rkerThread.run(SSLWorkerThread.java:106)


    Exception Details: com.sun.rave.web.ui.appbase.ApplicationException
    #{Page1.uploadFileButton_action}: java.lang.NullPointerException

    Possible Source of Error:
    Class Name: com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl
    File Name: ViewHandlerImpl.java
    Method Name: cleanup
    Line Number: 603

    Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl. cleanup(ViewHandlerImpl.java:603)
    com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl. renderView(ViewHandlerImpl.java:311)
    com.sun.faces.lifecycle.RenderResponsePhase.execut e(RenderResponsePhase.java:106)
    com.sun.faces.lifecycle.LifecycleImpl.phase(Lifecy cleImpl.java:251)
    com.sun.faces.lifecycle.LifecycleImpl.render(Lifec ycleImpl.java:144)
    com.sun.faces.extensions.avatar.lifecycle.PartialT raversalLifecycle.render(PartialTraversalLifecycle .java:106)
    javax.faces.webapp.FacesServlet.service(FacesServl et.java:245)
    org.apache.catalina.core.ApplicationFilterChain.se rvletService(ApplicationFilterChain.java:427)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:333)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:214)
    com.sun.webui.jsf.util.UploadFilter.doFilter(Uploa dFilter.java:370)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:246)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:214)
    org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:313)
    org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:287)
    org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:218)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
    com.sun.enterprise.web.WebPipeline.invoke(WebPipel ine.java:94)
    com.sun.enterprise.web.PESessionLockingStandardPip eline.invoke(PESessionLockingStandardPipeline.java :98)
    org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:222)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
    org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:587)
    org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:1096)
    org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:166)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:648)
    org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:593)
    org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:587)
    org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:1096)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:288)
    com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.invokeAdapter(DefaultProcessorTask.jav a:647)
    com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.doProcess(DefaultProcessorTask.java:57 9)
    com.sun.enterprise.web.connector.grizzly.DefaultPr ocessorTask.process(DefaultProcessorTask.java:831)
    com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.executeProcessorTask(DefaultReadTask.java:3 41)
    com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.doTask(DefaultReadTask.java:263)
    com.sun.enterprise.web.connector.grizzly.DefaultRe adTask.doTask(DefaultReadTask.java:214)
    com.sun.enterprise.web.connector.grizzly.TaskBase. run(TaskBase.java:265)
    com.sun.enterprise.web.connector.grizzly.ssl.SSLWo rkerThread.run(SSLWorkerThread.java:106)

  6. #6
    irakli_dev is offline Member
    Join Date
    Dec 2011
    Location
    Tbilisi (Georgia)
    Posts
    24
    Rep Power
    0

    Default Re: problem with uploading file

    so, haven't u found solusion on this problem?

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default Re: problem with uploading file

    This is the relevant code from UploadFilterFileItem:
    Java Code:
                    if (!outputFile.renameTo(file)) {
                        BufferedInputStream in = null;
                        BufferedOutputStream out = null;
                        try {
                            in = new BufferedInputStream(
                                new FileInputStream(outputFile));
                            out = new BufferedOutputStream(
                                    new FileOutputStream(file));
                            byte[] bytes = new byte[2048];
                            int s = 0;
                            while ((s = in.read(bytes)) != -1) {
                                out.write(bytes, 0, s);
                            }
                        } finally {
                            try {
                                in.close();
                            } catch (IOException e) {
                                // ignore
                            }
                            try {
                                out.close();
                            } catch (IOException e) {
                                // ignore
                            }
                        }
                    }
    The out.close is where the exception is coming from, which implies that out is null.
    I don't like the lack of checking for nulls in that catch block as it is eating the underlying exception.
    I suspect it is that out has failed to initialise, throwing an IOException, which implies there's something up with your destination location for the file.

    ETA: The quickest way to find out what is to try and open a BufferedOutputStream to that file (as in the code above) and see what exception you get.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default Re: problem with uploading file

    Quote Originally Posted by irakli_dev View Post
    so, haven't u found solusion on this problem?
    Have a look what Tolls suggest and let us know.

  9. #9
    irakli_dev is offline Member
    Join Date
    Dec 2011
    Location
    Tbilisi (Georgia)
    Posts
    24
    Rep Power
    0

    Default Re: problem with uploading file

    how to initializate outputFile and if u can explain why i can't use file instead of outputFile?

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default Re: problem with uploading file

    Write code to check your destination File object is correct.
    Try and write something to that destination...anything.
    Instead of this:
    Java Code:
    File file = new File(this.realImageFilePath);
    uploadedFile.write(file);
    do this:
    Java Code:
    File file = new File(this.realImageFilePath);
    BufferedOutputStream out = null;
    try {
        out = new BufferedOutputStream(new FileOutputStream(file));
        out.write(1);
    } catch (IOException ex) {
        ex.printStackTrace();
    } finally {
        if (out != null) out.close();
    }
    Something like that, and check you can write to that file.

  11. #11
    irakli_dev is offline Member
    Join Date
    Dec 2011
    Location
    Tbilisi (Georgia)
    Posts
    24
    Rep Power
    0

    Default Re: problem with uploading file

    Tolls
    out = new BufferedOutputStream(new FileOutputStream(file)); getting exception
    Exception Details: java.io.FileNotFoundException
    D:\My documents\NBProjects\netbeans 6.5 examples\FileUploadExample\build\web\resources\ima ge-file (Access is denied)
    but when i wrote the pass in window its opening, so i dont guess whats problem

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default Re: problem with uploading file

    "Access is denied" implies a privileges thing.
    So for some reason your code is not allowed to write to that location.
    Can the user you are executing this as create a file in that directory?

  13. #13
    irakli_dev is offline Member
    Join Date
    Dec 2011
    Location
    Tbilisi (Georgia)
    Posts
    24
    Rep Power
    0

    Default Re: problem with uploading file

    manuallly i can create file in this folder

  14. #14
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default Re: problem with uploading file

    Yes, but are you the same user?
    How are you running this?

  15. #15
    irakli_dev is offline Member
    Join Date
    Dec 2011
    Location
    Tbilisi (Georgia)
    Posts
    24
    Rep Power
    0

    Default Re: problem with uploading file

    i using netbeans 6.7 visual jsf
    so i think user is same

  16. #16
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default Re: problem with uploading file

    I have no idea how that is run.
    Could it have restrictions like an applet for example?
    You'll need to hunt down documentation for it all, but it's privileges that are your problem.

Similar Threads

  1. Uploading file via FTP or servlet
    By mr_anderson in forum Java Servlet
    Replies: 0
    Last Post: 08-15-2011, 02:24 AM
  2. uploading a file
    By itssiva in forum Java Servlet
    Replies: 4
    Last Post: 01-16-2009, 10:41 AM
  3. Problem in reading HTML input field while uploading file
    By sudipanand in forum Java Servlet
    Replies: 1
    Last Post: 11-27-2008, 09:26 AM
  4. Uploading a file with Servlet
    By farakhkhan@yahoo.com in forum New To Java
    Replies: 0
    Last Post: 03-10-2008, 08:02 PM
  5. File Uploading
    By aaliadhurue in forum Advanced Java
    Replies: 4
    Last Post: 01-16-2008, 06:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •