Announcement Announcement Module
Collapse
No announcement yet.
Cannot upload file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot upload file

    Please help.
    I use Primefaces 3.3 + Spring Workflow 2.3.1.RELEASE
    This is my web.xml

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    	version="2.4">
    
    	<!-- The master configuration file for this Spring web application -->
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>
    			/WEB-INF/config/web-application-config.xml
    		</param-value>
    	</context-param>
    	
    	<!-- Use JSF view templates saved as *.xhtml, for use with Facelets -->
    	<context-param>
    		<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    		<param-value>.xhtml</param-value>
    	</context-param>
    	
    	<!-- Enables special Facelets debug output during development -->
      	<context-param>
            <param-name>javax.faces.PROJECT_STAGE</param-name>
       		<param-value>Development</param-value>
      	</context-param>
      	
      	<!-- Causes Facelets to refresh templates during development -->
      	<context-param>
      		<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
      		<param-value>1</param-value>
      	</context-param>
    
        <context-param>
            <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
            <param-value>true</param-value>
        </context-param>
    
      	<!-- Declare Spring Security Facelets tag library -->
      	<context-param>
      		<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
      		<param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
      	</context-param>
      	
        <!-- Enforce UTF-8 Character Encoding -->
        <filter>
            <filter-name>charEncodingFilter</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>UTF-8</param-value>
            </init-param>
            <init-param>
                <param-name>forceEncoding</param-name>
                <param-value>true</param-value>
            </init-param>
        </filter>
        
        <filter-mapping>
            <filter-name>charEncodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        
    	<!-- Enables Spring Security -->
    	<filter>
            <filter-name>springSecurityFilterChain</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>
    	 
        <filter-mapping>
          <filter-name>springSecurityFilterChain</filter-name>
          <url-pattern>/*</url-pattern>
        </filter-mapping>
    
        <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>
            <!--<url-pattern>/*</url-pattern>-->
            <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        </filter-mapping>
    
       <!-- Loads the Spring web application context -->
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
      	
    	<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
    	<servlet>
    		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<init-param>
    			<param-name>contextConfigLocation</param-name>
    			<param-value></param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    		
    	<!-- Map all /spring requests to the Dispatcher Servlet for handling -->
    	<servlet-mapping>
    		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    		<url-pattern>/spring/*</url-pattern>
    	</servlet-mapping>
    
    	<!-- Just here so the JSF implementation can initialize, *not* used at runtime -->
    	<servlet>
    		<servlet-name>Faces Servlet</servlet-name>
    		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	
    	<!-- Just here so the JSF implementation can initialize -->
    	<servlet-mapping>
    		<servlet-name>Faces Servlet</servlet-name>
    		<url-pattern>*.faces</url-pattern>
    	</servlet-mapping>
    
        <welcome-file-list>
    		<welcome-file>index.html</welcome-file>
    	</welcome-file-list>
    
    </web-app>
    I deploy war file to Tomcat server and get error :

    Code:
    30.05.2012 23:14:29 com.sun.faces.config.ConfigureListener$WebConfigResourceMonitor$Monitor <init>
    INFO: Monitoring jndi:/localhost/rose/WEB-INF/faces-config.xml for modifications
    30.05.2012 23:14:29 org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error filterStart
    If I remove the Primefaces Upload Filter

    Code:
    <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>
            <!--<url-pattern>/*</url-pattern>-->
            <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        </filter-mapping>
    the application starts and works properly.
    But my code for uploading doesn't work
    Code:
     page.xhtml : 
                   <h:form id="file_form" enctype="multipart/form-data">
                        <p:fileUpload value="#{adminBean.uploadedFile}"  mode="simple"/>
                        <p:commandButton value="Submit" ajax="false" action="handle-file-upload"/>
                    </h:form>
    Code:
    flow.xml :
          <view-state id="create_article_view" view="create-article-desktop.xhtml">
            <transition on="handle-file-upload">
                <evaluate expression="adminBean.handleFileUpload()"/>
            </transition>
        </view-state>
    Code:
    AdminBean.java  : 
      public void handleFileUpload()
        {
            String uploadedFileName = uploadedFile.getFileName();
            System.out.println("uploadedFile == " + uploadedFile);
         }
    I cannot even print this message. So the clicking on the button doesn't invoke AdminBean's method.


    What is the problem? Could you help?

  • #2
    This is my solution.
    It did not work because of absent init param for Spring MVC Servlet

    Code:
    <servlet>
            <servlet-name>Spring MVC Servlet</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/config/webmvc-config.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>

    Comment

    Working...
    X