JSF : Issues with File Upload using Icefaces component

Go To StackoverFlow.com

1

I am trying to get FileUpload feature working with Icefaces ace:fileEntry but my fileUploadListener on server is not called, here is the code:

xhtml piece:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ace="http://www.icefaces.org/icefaces/components"
      xmlns:ice-cc="http://www.icesoft.com/icefaces-composite-comps"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ice="http://www.icesoft.com/icefaces/component">
<h:head>
    <link rel="stylesheet" type="text/css" href="/xmlhttp/css/rime/rime.css"/>
</h:head>
<h:body>
    <h:form enctype="multipart/form-data">
        <ace:fileEntry id="fileEntryComp"
                       label="File Entry"
                       relativePath="uploaded"
                       fileEntryListener="#{fileUpload.uploadFile}"/>
        <h:commandButton value="Upload File"/>
    </h:form>
</h:body>
</html>

java piece

public void uploadFile(FileEntryEvent event)
    {
        FileEntry fileEntry = (FileEntry) event.getSource();
        FileEntryResults results = fileEntry.getResults();
        for (FileEntryResults.FileInfo fileInfo : results.getFiles())
        {
            if (fileInfo.isSaved())
            {
                log.debug("########### FILE IS SAVED ########");
            }
        }
    }

Log Information:

    FINE  lifecycle        - Entering RestoreViewPhase
FINE  lifecycle        - New request: creating a view for /trade_entry/UploadBlotter.xhtml
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - Created component with component type of 'javax.faces.ViewRoot'
FINE  application      - Created new view for /trade_entry/UploadBlotter.xhtml
FINE  application      - RenderKitId for this view as determined by calculateRenderKitId HTML_BASIC
FINE  lifecycle        - Exiting RestoreViewPhase
FINE  timing           -  [TIMING] - [2ms] : Execution time for phase (including any PhaseListeners) -> RESTORE_VIEW 1
FINE  lifecycle        - render(com.sun.faces.context.FacesContextImpl@1dc6429)
FINE  lifecycle        - Entering RenderResponsePhase
FINE  lifecycle        - About to render view /trade_entry/UploadBlotter.xhtml
FINE  application      - Building View: /trade_entry/UploadBlotter.xhtml
FINE  application      - Created component with component type of 'javax.faces.Output'
FINE  component        - /trade_entry/UploadBlotter.xhtml @7,9 <h:head> Component[-1351329185_508ba5ae] Created: javax
.faces.component.UIOutput
FINE  application      - Created component with component type of 'javax.faces.Output'
FINE  component        - /trade_entry/UploadBlotter.xhtml @10,9 <h:body> Component[-1351329185_508ba588] Created: java
x.faces.component.UIOutput
FINE  application      - Created component with component type of 'javax.faces.HtmlForm'
FINE  component        - /trade_entry/UploadBlotter.xhtml @11,13 <h:form> Component[-1351329185_508ba5e2] Created: jav
ax.faces.component.html.HtmlForm
FINE  application      - Created component with component type of 'org.icefaces.ace.component.FileEntry'
FINE  application      - Created component with component type of 'javax.faces.Output'
FINE  application      - Created component with component type of 'javax.faces.ComponentResourceContainer'
FINE  application      - Created component with component type of 'javax.faces.Output'
FINE  application      - Created component with component type of 'javax.faces.Output'
FINE  component        - /trade_entry/UploadBlotter.xhtml @15,70 <ace:fileEntry> Component[-1351329185_508ba5fc] Creat
ed: org.icefaces.ace.component.fileentry.FileEntry
FINE  application      - Created component with component type of 'javax.faces.HtmlCommandButton'
FINE  component        - /trade_entry/UploadBlotter.xhtml @16,47 <h:commandButton> Component[-1351329185_508ba5c9] Cre
ated: javax.faces.component.html.HtmlCommandButton
FINE  application      - Created component with component type of 'javax.faces.ComponentResourceContainer'
FINE  component        - No renderer-type for component j_id1
FINE  component        - No renderer-type for component javax_faces_location_BODY
FINE  application      - Rendering View: /trade_entry/UploadBlotter.xhtml
FINE  component        - No renderer-type for component javax_faces_location_HEAD
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  component        - No renderer-type for component _captureFileOnsubmit
FINE  application      - Begin writing marker for viewId /trade_entry/UploadBlotter.xhtml
FINE  application      - End writing marker for viewId /trade_entry/UploadBlotter.xhtml
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - Begin writing marker for viewId /trade_entry/UploadBlotter.xhtml
FINE  application      - End writing marker for viewId /trade_entry/UploadBlotter.xhtml
FINE  lifecycle        - Exiting RenderResponsePhase

Now, in current state, i can open file-system navigation popup and i can select file but then fileUploadListener should be hit but right now it does not, also i am able to get some data that i set on server side so server trip is working only issue i have is fileUploadListener is not hit, any suggestions?

Update I am still looking for answer as I have not been able to successfully upload File to the server.

Update 2 Now am getting Content is not allowed in prolog exception, not sure what exactly that means, here is the stacktrace:

    ERROR [Faces Servlet]  - Servlet.service() for servlet Faces Servlet threw exception: javax.faces.view.facelets.Facele
tException: Error Parsing /trade_entry/UploadBlotter.xhtml: Error Traced[line: 2] Content is not allowed in prolog.
        at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:417) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.compiler.SAXCompiler.doMetadataCompile(SAXCompiler.java:400) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.compiler.Compiler.metadataCompile(Compiler.java:130) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.impl.DefaultFaceletFactory.createMetadataFacelet(DefaultFaceletFactory.java:327) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.impl.DefaultFaceletFactory.access$200(DefaultFaceletFactory.java:93) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:166) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:164) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:94) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:89) [:2.1.7-SNAPSHOT]
        at com.sun.faces.util.ExpiringConcurrentCache$1.call(ExpiringConcurrentCache.java:99) [:2.1.7-SNAPSHOT]
2012-04-05 15:15
by Rachel
now the thing, i do not see any thing in the server log and debugger does not hit fileUploadListener - Rachel 2012-04-05 16:02
I have exactly the same problem, my fileEntryListener is never called, did you get any other results or was switching to richfaces the only option - Volker 2012-10-17 14:08


2

I don't see any <h:form> surrounding your component, is there any in your code? I don't have any experience with icefaces but I'm using to richFaces. With a

<rich:fileUpload immediate="true" id="fileUploadId" 
                        ajaxSingle="true" listHeight="70px" listWidth="500px"
                        uploadButtonClass="otherButton" styleClass="backgroundColorInput"
                        addButtonClass="otherButton"
                        fileUploadListener="#{paramActions.fileUploadListener}">
                        <a:support event="onuploadcomplete" reRender="paramsForm" />
                    </rich:fileUpload>

it needs to be enclosed in a

<h:form id="paramsForm" enctype="multipart/form-data">

multipart/form-data enctype is needed for fileUpload

2012-04-05 15:43
by Real
I am using <ice:form> instead of <h:form>Rachel 2012-04-05 15:50
can you add an enctype to your ice:form - Real 2012-04-05 15:52
Used enctype but it did not made any changes - Rachel 2012-04-05 15:54
if your fileUploadListener called fine without any issues - Rachel 2012-04-05 15:55
yes, it's a working production component ; - Real 2012-04-05 15:57
This is giving me real pain since yesterday - Rachel 2012-04-05 15:57
Can you check this updated piece in her - Rachel 2012-04-05 16:00
you need to replace by Real 2012-04-05 16:02
I have updated with enctype informatio - Rachel 2012-04-05 16:03
and it still doesn't hit your file listener - Real 2012-04-05 16:07
Yes, it does not hit my file listener - Rachel 2012-04-05 16:07
Oh the enctype is only needed if you use a base fileUpload component (like seam:fileUpload) so that musn't be the cause, i looked out for an example : http://icefaces-showcase.icesoft.org/showcase.jsf;jsessionid=D91E1EEDF6C7564BD02C8A822271C0F9?grp=aceMenu&exp=fileEntry but I didn't find any difference with your cod - Real 2012-04-05 16:13
That's the thing, i have my code based on this example only and that is most troubling thing that I am not able to get it working - Rachel 2012-04-05 16:15
I know it's going to look uglier, but what if you try an icefaces fileUpload - Real 2012-04-05 16:19
You mean that complete complex example - Rachel 2012-04-05 16:21
let us continue this discussion in chatRachel 2012-04-05 16:21
Hey i have one configuration related question, let me know when you are avaiable - Rachel 2012-04-05 17:01


1

Most of the time unclosed tags causes that exception. Check you xhtml, you might locate any tag which open.

e.g : Any open div or span..

2012-04-05 20:21
by Vyoma
no, that is not the issue in here, also this exception is random in nature and related to one css file that am including, if i remove that file then am not getting this exception - Rachel 2012-04-05 20:28


0

remove the enctype="multipart/form-data" from the h:form it should work fine without it.

2012-04-08 08:19
by Mahmoud Saleh
I have tried removing enctype from h:form but still it is not working fine, can you post your complete working example so that i can verify what is causing the issue here, this is real pain - Rachel 2012-04-08 13:47


0

I had exactly this problem on a JBoss 7.1 server. I had an EAR project, some EJB projects and a couple of WAR projects. When I had the problem I deployed the icefaces jars in the EAR library, but when I moved them to the WAR project that used ace:fileentry it started to work.

2012-05-28 17:08
by Pierre
Ads