2.2M1+Glassfish3.0.1: fileUpload not call handleFileUpload

UI Components for JSF
Post Reply
webel
Posts: 87
Joined: 18 Sep 2010, 09:29
Location: Sydney, Australia
Contact:

19 Sep 2010, 01:39

Primefaces2.2M1
Glassfish3.0.1
Netbeans6.9.1
JSF2.0
Mojarro-2.0.3-FCS (which is not quite the same as distributed with Netbeans6.9.1's Glassfish3.0.1)
Browsers: Firefox3.0.19, Chrome, same experience.
Mac OS X 10.5.8

The handleFileUpload method of my managed UploadBean registered as fileUploadListener is never called.

I have scoured these forums and elsewhere for solutions to similar reported problems without success:

FileUpload not working, Event not fired (PrimeFaces 2.0.0-RC on a Glassfish v3)

Issue 545: File Upload Growl and messages not working

File Upload Growl & Messages are not working for me (JSF 2.0 mojarra, Tomcat 6, IE6, Primefaces 2.0)

Here is (a simplified version of) my UploadBean without writing the file:

Code: Select all

@ManagedBean
@SessionScoped
public class UploadBean implements Serializable {

    private static final Logger logger = Logger.getLogger(UploadBean.class.getName());

    public UploadBean() {}

    public void handleFileUpload(FileUploadEvent event) {
        logger.info("handleFileUpload:"+event.getFile().getFileName());
        ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
        File result = new File(extContext.getRealPath("//WEB-INF//upload") + "//" + event.getFile().getFileName());
        try {
            String $message = event.getFile().getFileName() + " is uploaded.";
            logger.info($message);
            FacesMessage msg = new FacesMessage("Succesful", $message);
            FacesContext.getCurrentInstance().addMessage(null, msg);
        } catch (Exception e) {
            e.printStackTrace();
            //String $message = event.getFile().getFileName() + " is uploaded.";
            String $message = "The files were not uploaded!";
            logger.log(Level.WARNING,$message);
            FacesMessage error = new FacesMessage();
            FacesContext.getCurrentInstance().addMessage(null, error);
        }
    }
}
I've tried both request and (serializable) session scope.

It was adapted from an example at: PPR multi-file upload with PrimeFaces 2.0 (3 Apr 2010). Also adapted from that example I have the following XHTML snippet:

Code: Select all

<h:form enctype="multipart/form-data" prependId="false">
 <p:growl id="messages" showSummary="true" showDetail="true" />
 <p:fileUpload fileUploadListener="#{uploadBean.handleFileUpload}" 
   update="messages"  
   sizeLimit="1073741824"
   multiple="true" 
   label="choose" 
   allowTypes="*.jpg;*.png;*.gif;*.txt;*.pdf;" 
   description="Files"
/>
</h:form>
BTW I've also tried exactly as shown in the Primefaces showcase for fileUpload. No luck.

I've tried using a form without any attributes at all. No luck.

I've tried using mulitple=false. No luck.

I've tried calling with direct URL index.xhtml or with referral. No luck.

I've tried using regular h:messages instead of growl; makes no difference. I introduced the logger to catch entry into handleFileUpload, it is definitely not being called on Upload.

The Glassfish output window in Netbeans shows nothing on Upload.

I looked in the server.log under glassfish-3.0.1/glassfish/domains/domain1/logs/. Nothing.

Here is my web.xml (I've tried all sorts of different ordering of other web xml element, but always with the file upload filter first:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>
org.primefaces.webapp.filter.FileUploadFilter
</filter-class>
<init-param>
 <param-name>uploadDirectory</param-name>
 <param-value>/tmp/files</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
    
<context-param>
 <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
 <param-value>server</param-value>
</context-param>

    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>

    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>

<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping>

<context-param>
<param-name>com.sun.faces.allowTextChildren</param-name>
<param-value>true</param-value>
</context-param>
</web-app>

I've tried with and without the Resource Servlet. No differenc (and other Primefaces components work ok without the Resource Servlet under Glassfish3).

By now truly exasperated with this , and very grateful for specific help to achieve file upload.

Webel.

icordoba
Posts: 67
Joined: 20 Nov 2010, 19:20

20 Nov 2010, 19:28

Hello,
did you or anybody solve this issue? Is so, could someone upload a simple working example of file upload? I have exactly this same problem and I've tested many combinations (managed beans, DCI, PFaces 2.1 and 2.2beta, ...). No luck :-(

I am also using GFish 3.0.1

webel
Posts: 87
Joined: 18 Sep 2010, 09:29
Location: Sydney, Australia
Contact:

21 Nov 2010, 09:39

No, no luck at all. And I really need this to work !
Thanks for posting a confirmation of your difficulties,
at least this way I am more confident I'm no doing something silly.

Webel
Primefaces 6.1
JSF Mojarra 2.3.0
(Netbeans 8.2+Glassfish 4.1.1 OR Payara 4.1)
Mac OS X "Yosemite" 10.10.5 / Linux CentOS 6.7

tony bonn
Posts: 5
Joined: 29 Nov 2010, 02:31

29 Nov 2010, 02:38

to add to the chorus i have not been able to make this work using netbeans / glassfish v3.

like a couple of other posters i have tried so many differnt components and techniques with no success. i never thought uploading a file would be so difficult. i have spent 30+ hours trying to find something which would work.

one of the examples posted by the publishers in a thread does not work. the xhtml page used non-jsf tags which glassfish/ie did not like. one of the tag attributes was invalid. the bean implemented an interface which was not available. the jsf page generates a load error which i have not had time to explore.

so maybe this works in a lab environment but it would be nice to see it work elsewhere.

webel
Posts: 87
Joined: 18 Sep 2010, 09:29
Location: Sydney, Australia
Contact:

02 Feb 2011, 21:32

Hi Primefaces, I would really appreciate some feedback on this crucial feature which is not working for me yet with Primefaces 2.2M1+Glassfish3.0.1.
Primefaces 6.1
JSF Mojarra 2.3.0
(Netbeans 8.2+Glassfish 4.1.1 OR Payara 4.1)
Mac OS X "Yosemite" 10.10.5 / Linux CentOS 6.7

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 61 guests