0 Replies Latest reply on Aug 7, 2007 10:16 AM by newlukai

    When uploading a file via ice:inputFile, a component is nul

      Hi,

      I don't know, if it's a Seam issue or an ICEfaces issue. So I'll ask both of you ;). Before I forget it: I'm using Seam 1.2.1.GA, ICEfaces 1.6 on a JBoss AS 4.0.5.GA.

      I've a page where an ice:inputFile is in an ice:popupPanel.

      <ice:panelPopup draggable="true"
       rendered="#{testactionDeveloper.showUpDownloadDialog}"
       visible="#{testactionDeveloper.showUpDownloadDialog}">
       <f:facet name="header">
       ... omitted ...
       </f:facet>
      
       <f:facet name="body">
       <ice:panelGrid columns="1" cellpadding="0" cellspacing="0" border="0">
       <h:dataTable value="#{testactionDeveloper.attachedFiles}"
       var="attachedFile"
       rendered="#{!empty testactionDeveloper.attachedFiles}">
       ... omitted ...
       </h:dataTable>
       <ice:inputFile actionListener="#{testactionDeveloper.upload}" style="margin-top: 30px;" id="upload" />
       </ice:panelGrid>
       </f:facet>
      </ice:panelPopup>


      The "testactionDeveloper" is a Seam component which is defined as follows:
      @Stateful
      @Scope(ScopeType.SESSION)
      @LoggedIn
      @Name("testactionDeveloper")
      public class TestactionDeveloperAction extends TestactionHandling implements TestactionDeveloper, Serializable {
       @In(required=false)
       private Release selectedRelease;
      
       @In(required=false)
       private Priorityclass selectedPriority;
      
       @In(required=false)
       private Severityclass selectedSeverity;
      
       @In(required=false)
       private User selectedUser;
      
       ... omitted, you'll see why ;) ...
      }


      As you can see TestactionDeveloperAction subclasses TestactionHandling:
      public class TestactionHandling {
       @PersistenceContext(unitName = "aresDatabase")
       protected transient EntityManager em;
      
       @In
       protected transient FacesContext facesContext;
      
       @In
       protected transient UpDownload upDownload;
      
       @In @Valid
       protected User user;
      
       public String upload(ActionEvent event) {
       InputFile uploadedFile = (InputFile) event.getSource();
       boolean success = false;
       if(uploadedFile.getStatus() == InputFile.SAVED) {
       if(testaction == null) {
       testaction = testactions.get(testactionIndex);
       }
       UpDownloadFileinfo fileInfo = new UpDownloadFileinfo();
       fileInfo.setName(uploadedFile.getFileInfo().getFileName());
       fileInfo.setFile(uploadedFile.getFile());
       fileInfo.setContentType(uploadedFile.getFileInfo().getContentType());
       fileInfo.setTestactionID(testaction.getID());
       success = upDownload.upload(fileInfo);
       }
       if( !success ) {
       return "failed";
       }
       return "uploaded";
       }
      
       public List<UpDownloadFileinfo> getAttachedFiles() {
       return upDownload.getAttachedFiles(testaction.getID());
       }
      
       ... omitted ...
      }


      Here you can see that upload() and getAttachedFiles() delegate to another Seam component. This component ("upDownload") is configured via components.xml and looks like this:
      @Scope(ScopeType.SESSION)
      @Stateful
      @LoggedIn
      public class UpDownloadDatabase implements UpDownload, Serializable {
       @PersistenceContext(unitName = "aresDatabase")
       private transient EntityManager em;
      
       @In
       private transient FacesContext facesContext;
      
       private boolean showUpDownloadDialog;
      
       public boolean upload(UpDownloadFileinfo fileInfo) {
       com.idsscheer.ares.entities.File dbFile = new com.idsscheer.ares.entities.File();
       dbFile.setName(fileInfo.getName().replaceAll(" ", "_"));
       dbFile.setTActID(fileInfo.getTestactionID());
       dbFile.setContenttype(fileInfo.getContentType());
      
      
       ... get the data ...
      
       dbFile.setData(dataFromFile.toByteArray());
      
       em.persist(dbFile);
       em.flush();
       return true;
       }
      
       public List<UpDownloadFileinfo> getAttachedFiles(long testactionID) {
       List<File> files = EMHelper.execQuery(em, "from File where TACT_ID=" + testactionID + " order by NAME ASC");
       List<UpDownloadFileinfo> result = new ArrayList<UpDownloadFileinfo>(files.size());
      
       for(File file : files) {
       UpDownloadFileinfo fileInfo = new UpDownloadFileinfo();
       fileInfo.setContentType(file.getContenttype());
       fileInfo.setName(file.getName());
       fileInfo.setTestactionID(file.getTActID());
       result.add(fileInfo);
       }
      
       return result;
       }
      }


      This additional "upDownload" component is necessary since it should be possible to switch between saving files in a db or on a filesystem. So I just use the interface UpDownload in the clients and set the implementation in components.xml.

      But my problem is now that as soon as I click on "Upload" the attribute "user" in TestactionDeveloperAction (TestactionHandling) is null. Therefore a RequiredException is thrown. But this attribute shouldn't be null, it isn't involved in the upload process. I don't know, what's wrong.

      Perhaps you can read sth out of the stack trace:
      15:51:33,015 WARN [UploadServlet] File upload failed
      javax.faces.el.EvaluationException: /showTestactionForDeveloper.xhtml @247,114 actionListener="#{testactionDeveloper.upload}": javax.ejb.EJBException: org.jboss.seam.RequiredException: In attribute requires non-null value: testactionDeveloper.user
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
       at com.icesoft.faces.component.inputfile.InputFile.notifyDone(InputFile.java:254)
       at com.icesoft.faces.component.inputfile.InputFile.upload(InputFile.java:206)
       at com.icesoft.faces.webapp.http.servlet.UploadServlet.service(UploadServlet.java:66)
       at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
       at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
       at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:97)
       at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:35)
       at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
       at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
       at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:85)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
       at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
       at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:359)
       at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
       at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:54)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.ejb.EJBException: org.jboss.seam.RequiredException: In attribute requires non-null value: testactionDeveloper.user
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:203)
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
       at $Proxy134.upload(Unknown Source)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:72)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:40)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:31)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:113)
       at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
       at org.javassist.tmp.java.lang.Object_$$_javassist_36.upload(Object_$$_javassist_36.java)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at com.sun.el.parser.AstValue.invoke(AstValue.java:130)
       at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
       at org.jboss.seam.ui.facelet.OptionalParameterMethodExpression.invoke(OptionalParameterMethodExpression.java:34)
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
       ... 37 more
      Caused by: org.jboss.seam.RequiredException: In attribute requires non-null value: testactionDeveloper.user
       at org.jboss.seam.Component.getValueToInject(Component.java:1919)
       at org.jboss.seam.Component.injectAttributes(Component.java:1368)
       at org.jboss.seam.Component.inject(Component.java:1195)
       at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:53)
       at sun.reflect.GeneratedMethodAccessor275.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       ... 77 more


      Thanks in advance
      Newlukai