0

FileUpload throws NotSerializableException in JBoss Cluster / ZK 6

asked 2012-02-29 19:58:17 +0800

LarsLi gravatar image LarsLi
18

Hi there,

I experience NotSerializableExceptions when I'm testing a FileUpload in this environment:

JBoss AS 5.1 cluster (one node only)
ZK 6.0.0
web.xml is configured as "distributable".

I followed clustering guidelines according to:
http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/Clustering

and zk.xml is configured:

	<system-config>
		<ui-factory-class>
			org.zkoss.zk.ui.http.SerializableUiFactory
		</ui-factory-class>
		<disable-zscript>true</disable-zscript>
		<disable-event-thread>true</disable-event-thread>
	</system-config>


FileUpload is handled by a custom composer with a SerializableEventListener:

public class EntryComposer extends GenericForwardComposer {

	private final static long serialVersionUID = -6886252025064558162L;
	private static Logger logger = LoggerFactory.getLogger("EntryComposer");
	private Window devWindow;
    
	@Override
	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);

		devWindow.addEventListener(Events.ON_UPLOAD, new SerializableEventListener() {
			private static final long serialVersionUID = -4371040477798783952L;

			@Override
			public void onEvent(Event event) throws Exception {
				handleFileUpload((UploadEvent)event);
			}
		});
	}

	public void onClick$upload() {
		try {
			int maxFiles = 3; 
			int maxSize = 104857600; 
			boolean alwaysNative = true;
			
			// always returns null, handle UploadEvent in listener 
			Fileupload.get("message", "title", maxFiles, maxSize, alwaysNative);
		} catch (Exception e) {
			logger.error("{} Upload failed", "onClick$upload()", e);			
		} 
	}
		
	public void handleFileUpload(UploadEvent event) throws WebException {
		try {
			Media[] multiMedia = event.getMedias();
			
			for (Media uploadedMedia : multiMedia) {				
				logger.debug("{} Media inMemory? {}", "handleFileUpload()", uploadedMedia.inMemory());			
				logger.debug("{} Media isBinary? {}", "handleFileUpload()", uploadedMedia.isBinary());			
			}
		} catch (Exception e) {
			throw new WebException("Failed to handle UploadEvent", e);
		} 
	}
}


Triggered by a simple index.zul with upload button:

<window id="devWindow" apply="web.ui.EntryComposer"
	title="ZK Version: ${desktop.webApp.version}">

	<div>
		Fileupload: <button id="upload" label="Upload" />
	</div>	
</window>


I tested the upload with some jpg-Files. As long as a file is small enough to be processed in memory everything is fine.
But if I pick a file that is not processed in memory (already at 1 MB) the server (Jboss cache) throws an exception and ZK logs an error:

server.log
20:24:32,760 ERROR java.io.NotSerializableException: org.zkoss.zk.au.http.AuUploader$ItemFactory

20:24:32,761 WARN Failed to replicate session KVgDVR1r9TmlNSo0YawarA__
java.lang.RuntimeException: Failure to marshal argument(s)
at org.jboss.cache.marshall.CommandAwareRpcDispatcher$ReplicationTask.call(CommandAwareRpcDispatcher.java:374)
at org.jboss.cache.marshall.CommandAwareRpcDispatcher$ReplicationTask.call(CommandAwareRpcDispatcher.java:341)
at org.jboss.cache.util.concurrent.WithinThreadExecutor.submit(WithinThreadExecutor.java:82)
at org.jboss.cache.marshall.CommandAwareRpcDispatcher.invokeRemoteCommands(CommandAwareRpcDispatcher.java:206)
at org.jboss.cache.RPCManagerImpl.callRemoteMethods(RPCManagerImpl.java:748) ...
Caused by: java.io.NotSerializableException: org.zkoss.zk.au.http.AuUploader$ItemFactory
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at java.util.LinkedList.writeObject(LinkedList.java:960)
...


app.log
20:24:31,938 SEVERE [org.zkoss.io.serializable]
- Unable to serialize entry: z__ul_2=[testfoto.jpg]
20:24:38,277 DEBUG [web.ui.EntryComposer]
- handleFileUpload() Media inMemory? false
20:24:38,277 DEBUG [web.ui.EntryComposer]
- handleFileUpload() Media isBinary? true


Setting the parameter "alwaysNative" to true or false in method call Fileupload.get(...) doesn't make a difference. Both are throwing the exception.


I found this related Bug that is supposed to be fixed since 5.0.11:
http://tracker.zkoss.org/browse/ZK-845
and I wonder why the testcase is using <zscript> despite the guidelines consider it harmful for clustering...

Any help or reports of similar experiences are appreciated.

A nested class of AuUploader appears to be not serializable - a bug?
Or do I have to adjust my implementation?

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2012-03-07 11:54:21 +0800

LarsLi gravatar image LarsLi
18

I'd like to add that I don't get any other serialization related issues so far in that ZK webapplication.

And some legacy applications deployed in the same JBoss server, that are also utilizing Apache Commons FileUpload, are up and running without any serialization exceptions for a long time.

link publish delete flag offensive edit

answered 2012-03-08 01:57:30 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Hi LarsLi,

It has been identified as a ZK bug
http://tracker.zkoss.org/browse/ZK-845
We have fixed it and the fix will be available in the upcoming 5.0.11 and 6.0.1 version.

The freshly release with this fix is available here: http://www.zkoss.org/download/freshly/

link publish delete flag offensive edit

answered 2012-03-08 09:31:59 +0800

LarsLi gravatar image LarsLi
18

thank you for your reply and link to the freshly releases.
I just did a retest with zkee-bin-eval-6.0.1-FL-2012-03-07.zip and the application still throws the same exceptions.
If you need any further information to find bug, please let me know.

link publish delete flag offensive edit

answered 2012-03-27 11:17:01 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

We have fixed the issue and the fix will be available in the upcoming 5.0.11 and 6.0.1 version.
http://tracker.zkoss.org/browse/ZK-930

The freshly release with this fix is available here: http://www.zkoss.org/download/freshly/ (zkee-bin-eval-6.0.1-FL-2012-03-19.zip)

You need to update commons-io.jar to version 1.4 (http://commons.apache.org/io/) and add the "jboss-web.xml"file under the WEB-INF folder.

jboss-web.xml

<jboss-web>
    <context-root>FileUpload</context-root>
    
   <replication-config>
      <cache-name>standard-session-cache</cache-name>
      <replication-trigger>SET_AND_GET</replication-trigger>
      <replication-granularity>SESSION</replication-granularity>
      <replication-field-batch-mode>true</replication-field-batch-mode>
      <use-jk>true</use-jk>
      <max-unreplicated-interval>30</max-unreplicated-interval>
      <snapshot-mode>INSTANT</snapshot-mode>
      <snapshot-interval>1000</snapshot-interval>
<!--      <session-notification-policy>com.example.CustomPolicy</session-notification-policy>-->
   </replication-config>
   
   <max-active-sessions>5</max-active-sessions>
   <passivation-config>
      <use-session-passivation>true</use-session-passivation>
      <passivation-min-idle-time>60</passivation-min-idle-time>
      <passivation-max-idle-time>600</passivation-max-idle-time>
   </passivation-config>
</jboss-web>

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-02-29 19:58:17 +0800

Seen: 658 times

Last updated: Mar 27 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More