I worked it out.
File Transfers don't work in hessian.
The fact that it did work is strange, but kind-of makes sense. I was
testing on my dev machine and running the server locally, so the File
handle pointed to the same location on the hard drive.
I have actually ended up bypassing Hessian for file transfer in the end
- we already had a mechanism for sending very large files, so I have
used that instead (the files being sent by hessian were actually icons,
so thought i could get away wityh it).
Thanks for your help though.
Christian Campo wrote:
>Hi Toby,
>just looked into your past posting on the same problem and you link to an entry
>in the java forum.http://forum.java.sun.com/thread.jspa?tstart=135&forumID=62&threadID=520000&trange=15
>
>Knowing the Hessian implementation a little bit (and having changed
>the code every now and then) I have doubts that transfering a FILE
>object as property works at all.
>
>Hessian has quit a number of built in serializers and deserializers
>but none for FILE. As the entry in the java forum states (and
>something I also observed). Hessian calls the constructor with
>shortest argument least (preferable none). Since FILE only has a
>constructor with one argument, Hessian calls it with the parameter
>NULL. Since the FILE constructor checks on that and throws a
>NullPointerException, constructing a FILE object that way fails (you
>see the NullPointerException somewhere in your stacktrace). The
>InvocationTargetException is thrown because calling an constructor
>(initializer or <init>) failed when using reflection (that what
>hessian does).
>
>I can't believe it ever worked is the bottom line. A FILE object is a
>handle to a physical file location on disk. Such a FILE handle is
>meaning less when transported via a webservice.
>
>What you want in the end is to transport a binary blob using
>Webservices. I implemented such a thing and its pretty simple.
>Create a class, call it Attachment. Allow it to be constructed with a
>empty constructor (which does nothing and is used by hessian) and from
>a FILE object or a URL or whatever.
>
>When Hessian tries to transport it, it will call the methode
>"writeReplace". Use it read the file
>content into a byte array and set the file handle to NULL.
>
>On the target platform (service or client does not matter), Hessian
>calls the empty constructor, sets the byte array which is a private
>property of your attachment instance and calls a method with
>the name "readResolve". There you can create a temp file, write the
>byte array into it, set the FILE handle and there you go.
>
>BTW: read and writing file content that you don't know becomes easier
>if you use JAF the
>Java Activation Framework because it handles mime-types and all that.
>So a file could
>be easier accessed using the dataHandler from JAF and its easier to
>write it if you
>use JAF.
>
>and questions, let me know
>
>christian campo
>
>
>On Tue, 14 Dec 2004 02:45:04 -0600, ejf <sun_king@xxx.net> wrote:
>
>
>>you say that one the file transfers worked. was that transfer with Hessian?
>>do you have example code??
>>i'd love to work on an example...
>>
>>e.j. fuhr
>>
>>
>>
>>
>>Toby Hede wrote:
>>
>>
>>
>>>I guess there is not much interest in the hessian interest list.
>>>Is there another forum that addresses hessian issues?
>>>
>>>I am still experiencing my strange file transfer problem with with
>>>Hessian.
>>>
>>>I am trying to send a serialized file through Hessian. Where
>>>previously one of my file transfers worked and another failed, despite
>>>using the same code, now they both fail.
>>>
>>>Any help would be appreciated.
>>>
>>>Windows XP SP2, JDK1.4.2_05, latest version Hessian
>>>
>>>Stack Trace:
>>>java.lang.reflect.InvocationTargetException
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>>Method)
>>> at
>>>sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>>
>>> at
>>>sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>>>
>>> at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.instantiate(JavaDeserializer.java:168)
>>>
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:103)
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:995)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:128)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:105)
>>> at
>>>com.caucho.hessian.io.SerializerFactory.readMap(SerializerFactory.java:222)
>>>
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1120)
>>> at
>>>com.caucho.hessian.io.CollectionDeserializer.readList(CollectionDeserializer.java:106)
>>>
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1015)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:128)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:105)
>>> at
>>>com.caucho.hessian.io.SerializerFactory.readMap(SerializerFactory.java:222)
>>>
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1120)
>>> at
>>>com.caucho.hessian.io.CollectionDeserializer.readList(CollectionDeserializer.java:106)
>>>
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1015)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:128)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:105)
>>> at
>>>com.caucho.hessian.io.SerializerFactory.readMap(SerializerFactory.java:222)
>>>
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1120)
>>> at
>>>com.caucho.hessian.io.CollectionDeserializer.readList(CollectionDeserializer.java:106)
>>>
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1015)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:128)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:105)
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:999)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:128)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:105)
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:999)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:128)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:105)
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:999)
>>> at
>>>com.caucho.hessian.server.HessianSkeleton.invoke(HessianSkeleton.java:134)
>>>
>>> at
>>>com.caucho.hessian.server.HessianServlet.service(HessianServlet.java:293)
>>> at
>>>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
>>>
>>> at
>>>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
>>>
>>> at
>>>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
>>>
>>> at
>>>org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
>>>
>>> at
>>>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
>>>
>>> at
>>>org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
>>>
>>> at
>>>org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
>>>
>>> at
>>>org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
>>>
>>> at
>>>org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
>>>
>>> at
>>>org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
>>>
>>> at
>>>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
>>>
>>> at
>>>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
>>>
>>> at
>>>org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
>>>
>>> at
>>>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
>>>
>>> at
>>>org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
>>>
>>> at
>>>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
>>>
>>> at
>>>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>>>
>>> at
>>>org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
>>>
>>> at
>>>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
>>>
>>> at
>>>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
>>> at
>>>org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
>>> at
>>>org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
>>>
>>> at
>>>org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
>>>
>>> at
>>>org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
>>>
>>> at
>>>org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
>>>
>>> at java.lang.Thread.run(Thread.java:534)
>>>Caused by: java.lang.NullPointerException
>>> at sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:189)
>>> ... 62 more
>>>StandardWrapperValve[EcommerceService]: Servlet.service() for servlet
>>>EcommerceService threw exception
>>>java.io.IOException: java.lang.reflect.InvocationTargetException
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:112)
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:995)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:128)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:105)
>>> at
>>>com.caucho.hessian.io.SerializerFactory.readMap(SerializerFactory.java:222)
>>>
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1120)
>>> at
>>>com.caucho.hessian.io.CollectionDeserializer.readList(CollectionDeserializer.java:106)
>>>
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1015)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:128)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:105)
>>> at
>>>com.caucho.hessian.io.SerializerFactory.readMap(SerializerFactory.java:222)
>>>
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1120)
>>> at
>>>com.caucho.hessian.io.CollectionDeserializer.readList(CollectionDeserializer.java:106)
>>>
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1015)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:128)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:105)
>>> at
>>>com.caucho.hessian.io.SerializerFactory.readMap(SerializerFactory.java:222)
>>>
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1120)
>>> at
>>>com.caucho.hessian.io.CollectionDeserializer.readList(CollectionDeserializer.java:106)
>>>
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:1015)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:128)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:105)
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:999)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:128)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:105)
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:999)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:128)
>>> at
>>>com.caucho.hessian.io.JavaDeserializer.readMap(JavaDeserializer.java:105)
>>> at
>>>com.caucho.hessian.io.HessianInput.readObject(HessianInput.java:999)
>>> at
>>>com.caucho.hessian.server.HessianSkeleton.invoke(HessianSkeleton.java:134)
>>>
>>> at
>>>com.caucho.hessian.server.HessianServlet.service(HessianServlet.java:293)
>>> at
>>>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
>>>
>>> at
>>>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
>>>
>>> at
>>>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
>>>
>>> at
>>>org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
>>>
>>> at
>>>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
>>>
>>> at
>>>org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
>>>
>>> at
>>>org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
>>>
>>> at
>>>org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
>>>
>>> at
>>>org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
>>>
>>> at
>>>org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
>>>
>>> at
>>>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
>>>
>>> at
>>>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
>>>
>>> at
>>>org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
>>>
>>> at
>>>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
>>>
>>> at
>>>org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
>>>
>>> at
>>>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
>>>
>>> at
>>>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>>>
>>> at
>>>org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
>>>
>>> at
>>>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
>>>
>>> at
>>>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
>>> at
>>>org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
>>> at
>>>org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
>>>
>>> at
>>>org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
>>>
>>> at
>>>org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
>>>
>>> at
>>>org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
>>>
>>> at java.lang.Thread.run(Thread.java:534)
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
>
>
-- Toby Hede Software Engineer Web Alive Technologies Pty Ltd The OSSI Group Pty Ltd Level 1, Innovation Building Digital Harbour, 1010 La Trobe Street Melbourne VIC 3000 P: +61 3 9934 0888 F: +61 3 9934 0899 E: toby.hede@xxx.biz W: www.webalive.biz This email (including all attachments) is intended solely for the named addressee. It is confidential and may contain legally privileged information. If you receive it in error, please let us know by reply email, delete it from your system and destroy any copies. This email is also subject to copyright. No part of it should be reproduced, adapted or transmitted without the written consent of the copyright owner. Emails may be interfered with, may contain computer viruses or other defects and may not be successfully replicated on other systems. We give no warranties in relation to these matters. If you have any doubts about the authenticity of an email purportedly sent by us, please contact us immediately.Received on Tue 14 Dec 2004 17:58:24 -0800
This archive was generated by hypermail 2.1.8 : Thu Sep 28 2006 - 20:16:40 PDT