-
1. Re: rich:FileUpload @ Seam
danielc.roth Apr 1, 2008 2:58 PM (in response to danielc.roth)I found MultipartFilter.java in the richfaces trunk, but is seem's a bit
disabled
/** * A filter for decoding multipart requests, for * use with the file upload control. * * @author Shane Bryzak * */ //@Scope(APPLICATION) //@Name("org.jboss.seam.web.multipartFilter") //@Install(precedence = BUILT_IN) //@BypassInterceptors //@Filter(within={"org.jboss.seam.web.ajax4jsfFilter", "org.jboss.seam.web.exceptionFilter"}) public class MultipartFilter implements Filter
-
2. Re: rich:FileUpload @ Seam
danielc.roth Apr 1, 2008 3:10 PM (in response to danielc.roth)Installed Shanes filter (precedence > BUILT_IN), same result. Data is null.
-
3. Re: rich:FileUpload @ Seam
nathandennis Apr 1, 2008 10:43 PM (in response to danielc.roth)im right behind you implementing this new fileupload component.
i read somewhere on the richfaces board last night,, that multipart wasnt needed for this. just h:form.. i guess im about a day behind you.. so im watching your progress with great anticipation . -
4. Re: rich:FileUpload @ Seam
dwsmith75 Apr 2, 2008 1:41 AM (in response to danielc.roth)This works for me
public void listener(UploadEvent event) throws IOException { UploadItem item = event.getUploadItem(); String name = "unnamed_attachment"; byte[] data = item.getData(); if (item.isFile()) { name = FilenameUtils.getName(item.getFileName()); data = FileUtils.readFileToByteArray( item.getFile() ); } debug("file uploaded '#0' : '#1'", name, item.getFileName()); ... ...
-
5. Re: rich:FileUpload @ Seam
danielc.roth Apr 2, 2008 8:25 AM (in response to danielc.roth)Works for me too. Thanks!
-
6. Re: rich:FileUpload @ Seam
mcsous Apr 17, 2008 9:00 PM (in response to danielc.roth)I'm with similar problem, but in my case listener method isn't called.
I'm using Seam 2.0.2 CR1. My configurations are pretty similar. What can be?
-
7. Re: rich:FileUpload @ Seam
bogdanminciu.bogdan.minciu.yahoo.com Apr 22, 2008 2:01 PM (in response to danielc.roth)I'm using RichFaces 3.2.1-SNAPSHOT, Seam 2.0.1-GA and Facelets.
I try to use the rich:fileUpload component to upload 5 pictures at once. This is from my editImageSet.xhtml page:
<rich:fileUpload fileUploadListener="#{imageSetView.imageUploadListener}" maxFilesQuantity="5" id="upload" acceptedTypes="jpg, jpeg, gif, png"> <a:support event="onuploadcomplete" reRender="currentImageSetA, messagesA" /> </rich:fileUpload>
The editImageSet.xhtml page is called like this: <s:link action="#{imageSetView.editImageSet(imageSet)}" view="editImageSet.xhtml" value="edit"/>, so it starts a new CONVERSATION when entering the page.
And this is my listener:
@Stateful @AutoCreate @Name("imageSetView") @Scope(ScopeType.CONVERSATION) public class ImageSetViewBean implements LocalImageSetView { ... @In private EntityManager entityManager; private ImageSet currentImageSet; @Begin(join = true) public void editImageSet(ImageSet selectedImageSet) { setCurrentImageSet(imageSetDAO.findImageSetById( selectedImageSet.getId() )); setImages(currentImageSet.getImages()); log.info("images= #0", getImages()); } // also tried without the @Begin // also tried with @Begin(join = true) @Begin(nested = true) public void imageUploadListener(org.richfaces.event.UploadEvent event) throws IOException { if (event == null) { log.warn("imageUploadListener(): null upload event"); return; } org.richfaces.model.UploadItem item = event.getUploadItem(); if(item.isFile()) { java.io.File tempFile = item.getFile(); fileName = tempFile.getAbsolutePath(); // --- // --- some image copying, resizing that was removed from this forum post --- // --- try { Image db_main = new Image(); db_main.setUrl(fileName); log.info("em= #0, db_main= #1", entityManager, db_main); entityManager.persist(db_main); currentImageSet.getImages().add(db_main); entityManager.merge(currentImageSet); } catch(Throwable t) { t.printStackTrace(); return; } } log.info("Image uploaded."); } ... }
Well, the problem is when it comes to the entityManager.persist(db_main) line. It jumps out to the /home.xhtml page saying that
The conversation ended, timed out or was processing another request
. If I comment the lines that deal with the database (persist, merge) everything works well, all 5 files are uploaded, resized, moved.The interesting thing is that the first file (image) uploaded is saved on disk, and even persisted. And it is even added to the currentImageSet. So the method works well just for the first file.
Could anyone please tell me why is the imageUploadListener() method ending my conversation the first time it is called?
Thank you in advance for any hint,
Bogdan.
-
8. Re: rich:FileUpload @ Seam
adlerauge Apr 24, 2008 11:39 AM (in response to danielc.roth)I'm having the same problem with Richfaces 3.2.0.GA, Seam 2.0.1.GA and I'm using Facelets also. I'm also forwarded to the home page defined in the pages.xml descriptor.
When I check for the conversation, then it's still active and available. I encountered these problems sometimes also with the default onblur validation for the input components. When I saved the form I was always forwarded to the no-conversation-view-id page . I still have that problem and no fix for both yet.
My upload file data from the Richfaces fileUpload is also null, but I can read it directly from the filesystem because I can get the uploaded filename.
I hope anyone can give help on that.
-
-
10. Re: rich:FileUpload @ Seam
bogdanminciu.bogdan.minciu.yahoo.com Apr 25, 2008 6:04 PM (in response to danielc.roth)I solved this problem by modifying the concurrent-request-timeout value from:
<core:manager concurrent-request-timeout="500" conversation-timeout="120000" conversation-id-parameter="cid"/> to
<core:manager concurrent-request-timeout="5000" conversation-timeout="180000" conversation-id-parameter="cid"/>
Thanks to Zahid: http://www.seamframework.org/Community/RichfileUploadListenerIsJumpingOutOfTheConversation
-
11. Re: rich:FileUpload @ Seam
kellyds.skelly.akimeka.com May 7, 2008 3:28 PM (in response to danielc.roth)Hello All,
I'm running into a problem also where I'm getting null for the filename and size. However, upon close inspection the file is actually being written to the temp location on the servers' hard drive with an autogenerated filename.
I'm pretty much at a loss as to why the attributes of the UploadItem are not being populated.
Details are below. Any assistance would be greatly appreciated!
Sean
I've disabled the normal Multipart Filter in the components.xml using:
<web:multipart-filter create-temp-files="true" max-request-size="1000000" url-pattern="*.seam" disabled="true" />
We are using facelet's and this is the snippet from the page:
<a4j:form> <rich:fileUpload id="upload1" uploadData="#{uploadAction2.data}" fileUploadListener="#{uploadAction2.listener}" listWidth="#{uploadAction2.width}" listHeight="#{uploadAction2.height}" maxFilesQuantity="#{uploadAction2.maxFiles}" acceptedTypes="#{uploadAction2.fileTypes}"> <f:facet name="label"> <h:outputText value="{_KB}KB from {KB}KB uploaded --- {mm}:{ss}"> </h:outputText> </f:facet> </rich:fileUpload> ...
And this is the fragment from the listener:
@Stateful @AutoCreate @Name("uploadAction2") @Scope(ScopeType.CONVERSATION) @Synchronized public class UploadActionBean2 implements UploadAction2 { ... public void listener(UploadEvent event) throws IOException { try { UploadItem item = event.getUploadItem(); String name = "unnamedattachment"; byte[] data = item.getData(); if (item.isFile()) { name = FilenameUtils.getName(item.getFileName()); data = FileUtils.readFileToByteArray( item.getFile() ); } else { ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write(item.getData()); System.out.println(b.toString()); } System.out.println("file uploaded " + name + " : " + item.getFileName()); } catch (Exception e) { System.out.println("FileUpload Listener Exception"); e.printStackTrace(); } } ...
The results of the SOP is:
file uploaded unnamedattachement : nullAn exception is also thrown when it fails the item.isFile() and attempts to read from a ByteArrayOutputStream:
08/05/07 08:30:17 java.lang.NullPointerException 08/05/07 08:30:17 at java.io.OutputStream.write(OutputStream.java:58) 08/05/07 08:30:17 at jmat.utils.UploadActionBean2.listener(UploadActionBean2.java:112) 08/05/07 08:30:17 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 08/05/07 08:30:17 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 08/05/07 08:30:17 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 08/05/07 08:30:17 at java.lang.reflect.Method.invoke(Method.java:585) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:27) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101) 08/05/07 08:30:17 at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44) 08/05/07 08:30:17 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56) 08/05/07 08:30:17 at org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:48) 08/05/07 08:30:17 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 08/05/07 08:30:17 at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31) 08/05/07 08:30:17 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 08/05/07 08:30:17 at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42) 08/05/07 08:30:17 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 08/05/07 08:30:17 at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26) 08/05/07 08:30:17 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 08/05/07 08:30:17 at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27) 08/05/07 08:30:17 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 08/05/07 08:30:17 at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) 08/05/07 08:30:17 at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50) 08/05/07 08:30:17 at sun.reflect.GeneratedMethodAccessor392.invoke(Unknown Source) 08/05/07 08:30:17 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 08/05/07 08:30:17 at java.lang.reflect.Method.invoke(Method.java:585) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.MethodBasedInterceptor.invoke(MethodBasedInterceptor.java:45) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.system.SetContextActionInterceptor.invoke(SetContextActionInterceptor.java:44) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:50) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.system.JAASInterceptor$1.run(JAASInterceptor.java:52) 08/05/07 08:30:17 at java.security.AccessController.doPrivileged(Native Method) 08/05/07 08:30:17 at javax.security.auth.Subject.doAsPrivileged(Subject.java:517) 08/05/07 08:30:17 at oracle.oc4j.security.SecurityServices.doAsPrivileged(SecurityServices.java:150) 08/05/07 08:30:17 at oracle.oc4j.security.SecurityServices.doAsPrivileged(SecurityServices.java:420) 08/05/07 08:30:17 at oracle.oc4j.security.JaasModeImpl$DoAsPrivilegedExecutor.execute(JaasModeImpl.java:280) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.system.JAASInterceptor.invoke(JAASInterceptor.java:57) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52) 08/05/07 08:30:17 at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:101) 08/05/07 08:30:17 at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:58) 08/05/07 08:30:17 at com.evermind.server.ejb.StatefulSessionEJBObject.OC4J_invokeMethod(StatefulSessionEJBObject.java:828) 08/05/07 08:30:17 at UploadActionBean2_LocalProxy_2n598p4.listener(Unknown Source) 08/05/07 08:30:17 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 08/05/07 08:30:17 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 08/05/07 08:30:17 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 08/05/07 08:30:17 at java.lang.reflect.Method.invoke(Method.java:585) 08/05/07 08:30:17 at org.jboss.seam.util.Reflections.invoke(Reflections.java:21) 08/05/07 08:30:17 at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31) 08/05/07 08:30:17 at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76) 08/05/07 08:30:17 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56) 08/05/07 08:30:17 at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41) 08/05/07 08:30:17 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 08/05/07 08:30:17 at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32) 08/05/07 08:30:17 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 08/05/07 08:30:17 at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) 08/05/07 08:30:17 at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54) 08/05/07 08:30:17 at org.javassist.tmp.java.lang.Object_$$_javassist_16.listener(Object_$$_javassist_16.java) 08/05/07 08:30:17 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 08/05/07 08:30:17 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 08/05/07 08:30:17 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 08/05/07 08:30:17 at java.lang.reflect.Method.invoke(Method.java:585) 08/05/07 08:30:17 at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329) 08/05/07 08:30:17 at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:342) 08/05/07 08:30:17 at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58) 08/05/07 08:30:17 at org.jboss.el.parser.AstValue.invoke(AstValue.java:96) 08/05/07 08:30:17 at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) 08/05/07 08:30:17 at org.jboss.seam.el.OptionalParameterMethodExpression.invoke(OptionalParameterMethodExpression.java:39) 08/05/07 08:30:17 at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68) 08/05/07 08:30:17 at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69) 08/05/07 08:30:17 at org.richfaces.component.UIFileUpload.broadcast(UIFileUpload.java:160) 08/05/07 08:30:17 at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:316) 08/05/07 08:30:17 at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:289) 08/05/07 08:30:17 at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:248) 08/05/07 08:30:17 at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:404) 08/05/07 08:30:17 at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:101) 08/05/07 08:30:17 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251) 08/05/07 08:30:17 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) 08/05/07 08:30:17 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) 08/05/07 08:30:17 at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65) 08/05/07 08:30:17 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:302) 08/05/07 08:30:17 at org.ajax4jsf.Filter.doFilter(Filter.java:142) 08/05/07 08:30:17 at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15) 08/05/07 08:30:17 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) 08/05/07 08:30:17 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73) 08/05/07 08:30:17 at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64) 08/05/07 08:30:17 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) 08/05/07 08:30:17 at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45) 08/05/07 08:30:17 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) 08/05/07 08:30:17 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:302) 08/05/07 08:30:17 at org.ajax4jsf.Filter.doFilter(Filter.java:142) 08/05/07 08:30:17 at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60) 08/05/07 08:30:17 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) 08/05/07 08:30:17 at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58) 08/05/07 08:30:17 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) 08/05/07 08:30:17 at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) 08/05/07 08:30:17 at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:17) 08/05/07 08:30:17 at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147) 08/05/07 08:30:17 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276) 08/05/07 08:30:17 at org.ajax4jsf.Filter.doFilter(Filter.java:142) 08/05/07 08:30:17 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:617) 08/05/07 08:30:17 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368) 08/05/07 08:30:17 at com.evermind.server.http.HttpRequestHandler.doDispatchRequest(HttpRequestHandler.java:889) 08/05/07 08:30:17 at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:797) 08/05/07 08:30:17 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:607) 08/05/07 08:30:17 at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:376) 08/05/07 08:30:17 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:161) 08/05/07 08:30:17 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:142) 08/05/07 08:30:17 at oracle.oc4j.network.ServerSocketReadHandler$ClientRunnable.run(ServerSocketReadHandler.java:275) 08/05/07 08:30:17 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) 08/05/07 08:30:17 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) 08/05/07 08:30:17 at java.lang.Thread.run(Thread.java:595)
-
12. Re: rich:FileUpload @ Seam
kellyds.skelly.akimeka.com May 9, 2008 7:47 PM (in response to danielc.roth)Found the problem.
We recently upgraded to SEAM 2.0 and still had the web.xml configured for SEAM 1.2 After going through and removing the RichFaces specific filters the FileUpload component started working.
Sean
-
13. Re: rich:FileUpload @ Seam
hurzeler Jun 6, 2008 9:54 AM (in response to danielc.roth)Silly question: Does the UploadActionBean2 bean need to be a statless session bean or can it be a POJO so that we can continue using a war for hotdeployment?
-
14. Re: rich:FileUpload @ Seam
gothmog Jun 10, 2008 11:29 AM (in response to danielc.roth)So forgive me,
but can someone actually shed some light on what actually makes this component work??
I've spent 2 hours following threads and still get a null data upon upload.. :(
I have all the above code and configuration mentioned but it still doesn't work.
Troy