0

I have read this article, and follow the suggested configuration, also I have read few StackOverFlow posts on that issue: 1, 2, 3, but yet none of the suggestion worked for me, not for simple mode nor advanced mode.

pom.xml:

    <repositories>
    <repository>
        <id>in-project</id>
        <name>In-Project-Repo</name>
        <url>file:${project.basedir}/lib</url>
    </repository>
</repositories>

<dependencies>

    <!-- Force API -->
    <dependency>
        <groupId>partner</groupId>
        <artifactId>partner-api</artifactId>
        <version>30.0</version>
    </dependency>

    <dependency>
        <groupId>wsc</groupId>
        <artifactId>wsc-api</artifactId>
        <version>30.0</version>
    </dependency>

    <!-- Jetty -->
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-servlet</artifactId>
        <version>7.6.0.v20120127</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-webapp</artifactId>
        <version>7.6.0.v20120127</version>
    </dependency>
    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jsp-2.1-glassfish</artifactId>
        <version>2.1.v20100127</version>
    </dependency>

    <!-- Servlet Faces API -->
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.7</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.2.7</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
    </dependency>

    <!-- PRIMEFACES -->
    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>5.0</version>
    </dependency>
    <dependency>
        <groupId>org.primefaces.extensions</groupId>
        <artifactId>primefaces-extensions</artifactId>
        <version>2.1.0</version>
    </dependency>
    <dependency>
        <groupId>org.primefaces.extensions</groupId>
        <artifactId>all-themes</artifactId>
        <version>1.0.8</version>
    </dependency>

    <!-- apache commons -->
    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3.1</version>
    </dependency>

    <!-- JSON -->
    <dependency>
        <groupId>org.codehaus.jettison</groupId>
        <artifactId>jettison</artifactId>
        <version>1.3.5</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <webXml>WebContent\WEB-INF\web.xml</webXml>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

web.xml:

    <!-- Change to "Production" when you are ready to deploy -->
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>bootstrap</param-value>
</context-param>

<context-param>
    <param-name>primefaces.UPLOADER</param-name>
    <param-value>auto</param-value><!-- |native|commons -->
</context-param>

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

<!-- ############################################# -->
<!-- # File upload # -->
<!-- ############################################# -->
<filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

<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>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

<context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
</context-param>
<context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
</context-param>

<listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

index.xhtml:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:define name="content">
    <h:form enctype="multipart/form-data">
        <p:fileUpload value="#{articleBean.uploadFile}" mode="simple" />
        <p:commandButton value="Import" ajax="false" action="#{articleBean.importKB}">
        </p:commandButton>
    </h:form>
</ui:define>

Bean:

    private UploadedFile uploadFile;

public UploadedFile getUploadFile()
{
    return this.uploadFile;
}

public void setUploadedFile(UploadedFile uploadFile)
{
    this.uploadFile = uploadFile;
}

public void importKB()
{
    System.out.println(this.uploadFile.getFileName());
}
Community
  • 1
  • 1
GoldenAxe
  • 838
  • 3
  • 9
  • 26
  • Why did you map the file upload filter on forward dispatcher only? I'm not seeing other filters in your webapp which might perform URL rewriting or what not for which the request would be forwarded before the file upload filter is hit. Get rid of the `` entry altogether and retry. As of now, it's namely basically never hit. – BalusC Aug 27 '14 at 19:29
  • sorry the dispatcher was left from one of my tries, I have now removed it. The server side is still not invoked when pressing the button after selecting a file, the same happens with advanced mode with fileUploadListener method. There is no error or any message indicating what the problem might be, the server just not invoked. other tags like p:ajax works great with the server. – GoldenAxe Aug 28 '14 at 06:26
  • @BalusC: I have tried h:inputFile, which also didn't invoked the server (the file setter in that case), I'm starting to believe the problem is with the jetty server. – GoldenAxe Sep 01 '14 at 08:57
  • I have changed the server to Tomcat, everything works as expected, meaning this is some configuration of the jetty server... – GoldenAxe Sep 01 '14 at 09:51
  • same here. it's a problem connected to Jetty Server for sure. Is there a javascript workaround please? – Alessandro Mattiuzzi Jun 11 '15 at 12:57

0 Answers0