Search code examples
jsffile-uploadweblogic12cicefaces

fileupload not working when war is deployed in weblogic but working if exploded war folder is deployed


I am running with an issue. I have used ICEFaces jars in my application which I am deploying in weblogic. When I deploy the war and try uploading the war, It is not working and I am able to capture below exceptions. But, when I deploy the exploded war folder in weblogic, it is not working. As it is working for exploded war folder, I feel like its not able to create a folder where it wanted to upload the file. Is there something that I need to configure to resolve this issue?

part of web.xml:

<context-param>
        <param-name>com.icesoft.faces.uploadDirectory</param-name>
        <param-value>/upload</param-value>
    </context-param> 

part of jsp

<ice:inputFile
                            submitOnUpload="postUpload" id="inputFileComponent" 
                            actionListener="#{uploadAction.uploadActionListener}"
                            action="#{uploadAction.doUploadFile}" />

where uploadAction is the action class having methods uploadActionListener() as action listener and doUploadFile as action mapped

Stacktrace

    com.icesoft.faces.webapp.xmlhttp.PersistentFacesState   [pool-2-thread-1]       Exception occured during execute push on /jsp/upload.jspx
javax.faces.el.EvaluationException: /jsp/upload.jspx @64,48 actionListener="#{uploadAction.uploadActionListener}": java.lang.NullPointerException
        at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
        at javax.faces.component.UICommand.broadcast(UICommand.java:131)
        at com.icesoft.faces.component.inputfile.InputFile.broadcast(InputFile.java:152)
        at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:115)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:191)
        at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
        at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState.execute(PersistentFacesState.java:286)
        at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState.executeAndRender(PersistentFacesState.java:314)
        at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState.setupAndExecuteAndRender(PersistentFacesState.java:326)
        at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState$RenderRunner.run(PersistentFacesState.java:450)
        at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
        at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
        at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NullPointerException
        at java.io.FileInputStream.<init>(FileInputStream.java:134)
        at java.io.FileReader.<init>(FileReader.java:72)

Solution

  • You are on the right track. Deploying the exploded WAR creates a writable directory structure, but deploying just the WAR will not do that and you can't create a directory within that WAR.

    So you'll need put the file upload directory in a fixed location. See: How to specify an absolute path for com.icesoft.faces.uploadDirectory