8 Replies Latest reply on Jan 29, 2009 6:03 AM by Andrei Markavtsov

    fileupload and

    Fab Mars Novice

      Hello
      My environment: JSF-RI 1.2_12, Facelets, Glassfish, RF3.3.0

      I'm experiencing this problems with fileUpload. I didn't have this before, with 3.2.2.

      This exception happens just after the upload has started. The upload listener is not even called. It looks like the id of the component is badly parsed.
      It doesn't happen on every page where I used fileUpload is. Maybe it happens when *several* fileUpload are present on the same page, but I'm not sure yet.

      ATTENTION: java.lang.NumberFormatException: For input string: "releaseEditForm:j_id97"
       at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
       at java.lang.Long.parseLong(Long.java:403)
       at java.lang.Long.valueOf(Long.java:518)
       at com.sun.el.lang.ELSupport.coerceToNumber(ELSupport.java:301)
       at com.sun.el.lang.ELSupport.coerceToNumber(ELSupport.java:279)
       at com.sun.el.lang.ELSupport.coerceToType(ELSupport.java:354)
       at com.sun.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:66)
       at com.sun.faces.el.ELUtils.coerce(ELUtils.java:440)
       at com.sun.faces.mgbean.BeanBuilder$Expression.evaluate(BeanBuilder.java:580)
       at com.sun.faces.mgbean.ManagedBeanBuilder$BakedBeanProperty.set(ManagedBeanBuilder.java:606)
       at com.sun.faces.mgbean.ManagedBeanBuilder.buildBean(ManagedBeanBuilder.java:133)
       at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:108)
       at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:368)
       at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:230)
       at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:86)
       at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
       at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
       at com.sun.faces.el.ChainAwareVariableResolver.resolveVariable(ChainAwareVariableResolver.java:108)
       at com.sun.jsftemplating.el.PageSessionResolver.resolveVariable(PageSessionResolver.java:73)
       at com.sun.faces.el.VariableResolverChainWrapper.getValue(VariableResolverChainWrapper.java:107)
       at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
       at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
       at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:86)
       at com.sun.el.parser.AstValue.getTarget(AstValue.java:80)
       at com.sun.el.parser.AstValue.setValue(AstValue.java:160)
       at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:273)
       at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:93)
       at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:234)
       at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:239)
       at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:239)
       at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:239)
       at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:239)
       at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:239)
       at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:239)
       at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:239)
       at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:194)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
       at org.mars.toolkit.jsf.FacesServlet.service(Unknown Source)
       at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:333)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:365)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313)
       at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
       at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
       at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
       at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
       at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
       at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
       at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
       at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
       at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
       at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
       at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
       at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
       at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
       at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
       at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:569)
       at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:821)
       at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
       at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.process(SSLReadTask.java:440)
       at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.doTask(SSLReadTask.java:228)
       at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
       at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)


      Can you guys help me?

        • 1. Re: fileupload and
          Nick Belaevski Master

          Hello,

          How can we reproduce it?

          • 2. Re: fileupload and
            Fab Mars Novice

            Sorry, I was first trying to see if similar reports were made. Seems not.

            I've tried to reproduce in a separate form but didn't succeed until now. I'll have to strip the page where the problem appears till I can isolate what's wrong. In any case I'll submut my conclusions here.

            • 3. Re: fileupload and
              Ilya Shaikovsky Master

              Thanks for your efforts! will wait for your input.

              • 4. Re: fileupload and
                Fab Mars Novice

                I got it. It's a nasty one and even now I'm not sure what to think about it:

                The managed bean I used behind the page had this:

                <managed-bean>
                 <managed-bean-name>releaseEdit</managed-bean-name>
                 <managed-bean-class>my.package.ReleaseEditHandler</managed-bean-class>
                 <managed-bean-scope>request</managed-bean-scope>
                 <managed-property>
                 <property-name>id</property-name>
                 <property-class>java.lang.Long</property-class>
                 <value>#{param.id}</value>
                 </managed-property>
                 </managed-bean>


                that managed bean had naturally this setter:
                public void setId(Long id) {
                 this.id = id;
                 }



                And my page code had:
                <a4j:keepAlive beanName="releaseEdit"/>
                <h:form>
                 <rich:dataTable id="tracksTable" binding="#{releaseEdit.tracksTable}" value="#{releaseEdit.tracks}" var="track">
                 <rich:column>
                 <rich:fileUpload fileUploadListener="#{track.uploadListener}"/>
                 </rich:column>
                
                 <f:facet name="footer">
                 <a4j:commandLink value="Add" actionListener="#{releaseEdit.doAddTrack}" reRender="tracksTable" ajaxSingle="true"/>
                 </f:facet>
                 </rich:dataTable>
                </h:form>



                Well, at every upload, the setId() method was called and EACH input field id from the form above was passed into it!
                releaseEditForm:j_id97 being the kind of id's you can find in my application, coertion to Long's was impossible, thus the error.



                I tried to workaround a bit, seting ajaxSingle="true", or allowFlash="true" in the fileUpload, but it didn't work. So I changed #{param.id} in my faces-config to something else and all finally worked :)

                Now, I'm not sure this behavior is normal... Can anyone please confirm?

                • 5. Re: fileupload and
                  Fab Mars Novice

                  May I add that I have other pages with the same #{param.id} thing and rich:fileUpload involved, and they cause no problem.

                  This page causing the issue is the only one where fileUpload's are in a dataTable!

                  • 6. Re: fileupload and
                    Andrei Markavtsov Apprentice

                    Hello,

                    FileUpload component sends custom id parameter to server on each upload. It need for internal component purpose.
                    This parameter is type of String, so it cannot be recognized as Long value.

                    I cannot understand why you need to set id to bean, because there are no <f:param> inside the form with 'id' name in your code part.
                    So, if you want to set fileUpload's id use String type or if you want set any other parameter just rename it.

                    • 7. Re: fileupload and
                      Fab Mars Novice

                      Ah, no, you didn't understand. I don't want to set fileUpload Id's anywhere!

                      Look: my page can be called with URL's like http://server/application/releaseEdit.jsf?id=123
                      The #{param.id} is meant to handle the 123 (as a Long) and call the method setId() in the "releaseEdit" managed bean, after its construction, so that some entity can be loaded from the database and edited thanks to that form. Classic stuff.

                      What I noticed in this example, is that, in a way I cannot understand, my managed bean's setId() method is called upon each upload ALSO, and the value passed is the actual rich:fileUpload component id's! Strange, right?

                      In my opinion this shouldn't happen. I worked it around, so it's no problem to me anymore, but I'm almost sure that it's a bug and wanted to notify it to you guys.

                      I'm sure that if I download the source code and search a little I'll find some loophole or side effect where some "id" gets injected in the wrong bean in cerain conditions.

                      • 8. Re: fileupload and
                        Andrei Markavtsov Apprentice

                        Ok. I see.

                        You may not download source. :)
                        I already said that currently fileupload sends id parameter on each request.
                        You right that this should be fixed. We will remove this or rename parameter to something special. I added the issue for this: https://jira.jboss.org/jira/browse/RF-5960.

                        Before fix I can only suggest implement checking of id parameter if it's an instance of Long.

                        Thanks for the post.