Skip to main content

ClassCastException on MTOM WebService

27 replies [Last post]
eskatos
Offline
Joined: 2007-05-14
Points: 0

Hi,

I'm trying to build an upload web service that will deal with large data.

I'm following the docs available in the Metro user guide to enable MTOM.

When invoking my service I get the following error :

java.lang.ClassCastException: javax.activation.DataHandler cannot be cast to com.sun.xml.ws.developer.StreamingDataHandler

Here is the server code :

<br />
import java.io.File;<br />
import javax.ejb.Stateless;<br />
import javax.jws.WebService;<br />
import javax.jws.soap.SOAPBinding;<br />
import javax.xml.bind.annotation.XmlMimeType;<br />
import javax.xml.ws.soap.MTOM;<br />
import com.sun.xml.ws.developer.StreamingDataHandler;<br />
import javax.activation.DataHandler;<br />
import javax.xml.ws.BindingType;</p>
<p>@Stateless<br />
@MTOM<br />
@WebService(name = "UpdatePublish", serviceName = "UpdatePublishService", portName = "UpdatePublishPort")<br />
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)<br />
@BindingType(value = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)<br />
public class UpdatePublishServiceWS {</p>
<p>    public void fileUpload(String fileName, @XmlMimeType("application/octet-stream") DataHandler data) {<br />
        try {<br />
            StreamingDataHandler dh = (StreamingDataHandler) data; // ClassCastException occurs here   <=<br />
            File file = File.createTempFile(fileName, "");<br />
            dh.moveTo(file);<br />
            dh.close();<br />
        } catch ( Exception e) {<br />
            e.printStackTrace();<br />
        }<br />
    }</p>
<p>}<br />

Here is the client code :

<br />
import java.util.Map;<br />
import java.net.URL;<br />
import javax.activation.DataHandler;<br />
import com.sun.xml.ws.developer.JAXWSProperties;<br />
import javax.xml.ws.BindingProvider;<br />
import javax.xml.ws.soap.MTOMFeature;</p>
<p>public class Main {</p>
<p>    public static void main(String[] args) {<br />
        try {<br />
            UpdatePublishService service = new UpdatePublishService();<br />
            UpdatePublish port = service.getUpdatePublishPort(new MTOMFeature());<br />
            Map ctxt = ((BindingProvider) port).getRequestContext();<br />
            ctxt.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);<br />
            DataHandler dataHandler = new DataHandler(new URL("file:///home/eskatos/tmp/dumbfile.zip"));<br />
            port.fileUpload("myUploadedFile.zip", dataHandler);<br />
        } catch (Exception ex) {<br />
            ex.printStackTrace();<br />
        }<br />
    }</p>
<p>}<br />

The server is deployed in Glassfish v2 and the client is a plain JSE app.

What did I do wrong ?

Thanks in advance

Paul

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jitendra Kotamraju

metro@javadesktop.org wrote:
> so no response yet on the memory issue?
>
> how about this: i tried running the mtom-large sample and it fails:
>
> problem: jaxws libs are not deployed with war file
> solution: fixed ant task to include libs
>
> problem: wsdl points to non-existant web location as it doesn't match the war file name
> solution: hand-edit wsdl to point to correct location
>
> problem: compile/run client and get WebServiceException: No Content-type in header!
> solution: ??
> [Message sent by forum member 'netminkey' (netminkey)]
>
Can you run any other sample ?

Jitu
> http://forums.java.net/jive/thread.jspa?messageID=259265
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
> For additional commands, e-mail: users-help@metro.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net

netminkey
Offline
Joined: 2007-12-18
Points: 0

My mistake -- I thought the default deploy for the samples was to include the jar files with the war file when deploying to Tomcat. Reading the install docs, it states specifically that the tomcat.xml ant tasks must be run, which install all the JAXWS libs into the tomcat lib directory.

joe_roberts_z
Offline
Joined: 2009-06-09
Points: 0

I too I am having the same problem on the service side where no matter what I try the service always uses a DataHandler instance instead of a StreamingDataHandler instance. How did you resolve the issue on the service side? Did you use a DataHandler instead of StreamingDataHandler as suggested; it is not clear to me?

Why is the documentation still suggesting the use of a StreamingDataHandler instance instead of a regular DataHandler if it throws a ClassCastException? Shouldn't someone update the doc.? It seem to me that every person following the current doc. would run into the same thing if the doc. is not updated.

Can you please post your new code for how you solved the issue on the service side?

pablius
Offline
Joined: 2007-02-19
Points: 0

Netminkey,
That stacktrace is server side (service), right?
Can you paste the implementation code to see where the exception is being caused?

One thing to notice:
If you enable 'parseEagerly', then all the binary content will be stored in memory before your method is invoked. That means the amount of allocated memory will depend on your request's binary content size, and that's exactly what you want to avoid by using MTOM and the StreamingDataHandler.
If too many concurrent consumers invoke the same method sending large binary elements, it is not difficult to reach an OutOfMemoryException and get your service collapsed.

Please correct me if I'm wrong. Also, I apologize if you already knew this and you were doing it for testing purposes.

Regards,
Pablo Alvarez

netminkey
Offline
Joined: 2007-12-18
Points: 0

no joy, but thanks for the input thus far pablius and jitu :-)

here's what i've found:
1. ClassCastException is on server side and (as pablius stated) I'm getting passed a DataHandler and not a StreamingDataHandler
2. Removing the @SOAPBinding fixed the client-side endpoint args to match the interface args (so I can use a DataHandler on the client instead of a byte[])
3. I looked at the mtom-large sample as a guideline, but couldn't use it directly because I'm generating my wsdl at compile-time from my Java interface class
4. I run out of memory (server-side) when I upload a large file. I hooked up jconsole to my tomcat server and watched it spike up to 900m (my setting -Xmx900m) when I had the client invoke the web service

Here's my service:
@MTOM
@WebService(name = "MyServiceEndpoint", serviceName = "MyService", targetNamespace = "urn:myspace")
public class MyWebServiceImpl implements MyWebService
{
@Resource
WebServiceContext wsContext;
@WebMethod(operationName = "containMtom")
@WebResult(name = "paramSuffixForGetUrl")
public String containMtom(
@WebParam(name = "name")String name,
@WebParam(name = "data")
@XmlMimeType("application/octet-stream") DataHandler data
)
throws ServiceUnavailableException, VmTypeUnavailableException
{
// never gets past here on large files: java.lang.OutOfMemoryError: Java heap space

System.out.println("+++++++++++ " + data.getClass()); // javax.activation.DataHandler
System.out.println(data.getContentType()); // application/octet-stream
System.out.println(data.getName()); // null
try {
StreamingDataHandler dh = (StreamingDataHandler)data;
... never gets here due to ClassCastException
} catch (Exception e) {
try {
InputStream inputStream = new BufferedInputStream(data.getInputStream(), 8192);
byte[] buffer = new byte[8192];
int bytesRead = 0;
while ((bytesRead = inputStream.read(buffer, 0, buffer.length)) >= 0) {
System.out.println("))))))) " + Runtime.getRuntime().freeMemory() + " free of " + Runtime.getRuntime().totalMemory());
}
} catch (IOException e1) {
e1.printStackTrace();
}
}
return "success!";
}
}

Here's the client:
URL wsdlUrl = new URL(webServiceUrl);
QName qname = new QName("urn:myspace", "MyService");
Service service = Service.create(wsdlUrl, qname);
MyServiceEndpoint endpoint = service.getPort(MyServiceEndpoint.class,
new WebServiceFeature[] {
new StreamingAttachmentFeature(null, true, 4000000L),
}
);

((BindingProvider)endpoint).getRequestContext().put(
BindingProviderProperties.REQUEST_TIMEOUT, 30000);
DataHandler dh = new DataHandler(new URL("file:/home/netminkey/1.gig.file"));
endpoint.containMtom("test 1Gigabit file", dh);
}

alexj
Offline
Joined: 2007-03-02
Points: 0

I downloaded 2.1.3 and still getting the ClassCastException at
StreamingDataHandler sdh = (StreamingDataHandler)dh;

Was anybody able to solve this ?.

pablius
Offline
Joined: 2007-02-19
Points: 0

What I did is use the DataHandler methods. There's no need to cast to StreamingDataHandler to make it work. Of course, you will have to re-implement some things that are already provided by StreamingDataHandler, but it's no big deal.

The following is a code snippet form a service method that recevies a javax.activation.DataHandler as argument.
The idea is to store the binary data into a temporary file, then do whatever you want with it.

You will need to do this (or something similar) if you want to achieve a scalable implementation. (see my last post)

// ... code ....
InputStream inputStream = new BufferedInputStream(daServertaHandler.getInputStream(), BYTES_8K); //using an 8KB buffer

File tempFile =
File.createTempFile(TMP_FILE_PREFIX, "_" + String.valueOf(System.currentTimeMillis()));

OutputStream output = new BufferedOutputStream(new FileOutputStream(tempFile));

int bytesRead;
byte[] buffer = new byte[BYTES_2K];

while ((bytesRead = inputStream.read(buffer, 0, buffer.length)) != -1) {
output.write(buffer, 0, bytesRead);
}

output.close();
inputStream.close();

//don't know if this is necessary
if (dataHandler instanceof StreamingDataHandler) {
((StreamingDataHandler) dataHandler).close();
}
// ... code ....

alph486
Offline
Joined: 2012-04-24
Points: 0

Very nice! Took me long enough to find this article but I'm happy I did :).

Thanks all

alexj
Offline
Joined: 2007-03-02
Points: 0

Thanks. I agree, DataHandler seems to do the job.

BTW shortened the snippet to this

File tempFile = File.createTempFile(TMP_FILE_PREFIX, "_" + String.valueOf(System.currentTimeMillis()));

OutputStream output = new BufferedOutputStream(new FileOutputStream(tempFile));
dataHandler.writeTo(output);

output.close();

pablius
Offline
Joined: 2007-02-19
Points: 0

Great! Didn't realize DataHandler provided that method!

Glad to help!
Pablo

netminkey
Offline
Joined: 2007-12-18
Points: 0

so no response yet on the memory issue?

how about this: i tried running the mtom-large sample and it fails:

problem: jaxws libs are not deployed with war file
solution: fixed ant task to include libs

problem: wsdl points to non-existant web location as it doesn't match the war file name
solution: hand-edit wsdl to point to correct location

problem: compile/run client and get WebServiceException: No Content-type in header!
solution: ??

pablius
Offline
Joined: 2007-02-19
Points: 0

netminkey,
Are you monitoring your request/responses ? (You can do it with TcpMon for example)

If your consumer is sending inline (embedded) base64 encoded binary data, then JAX-WS will have no option but to allocate enough memory to keep that content referenced while parsing. As you explained, too many concurrent requesters (and big binary content transmitted) can easily cause an OutOfMemory.

If the consumer is sending a MIME multipart request, then JAX-WS will be able to handle it in a streaming fashion, achieving the desired scalability.

Verify that the consumer is not sending inline binary content in your SOAP message. And remember to check that 'parseEagerly' is deactivated.

Hope it helps!

Regards,
Pablo

Message was edited by: pablius

netminkey
Offline
Joined: 2007-12-18
Points: 0

pablo,
thanks for continuing input on this thread :-)

I'm working only on the devel side right now and need to get this stuff working before pushing it out the consumer -- so there is only 1 user (me!). I'm creating a client SDK for my software and want to provide a method like 'void uploadFile(String fileUrl)' for the client to invoke (yes, it's contrived; but it works for this forum).

I looked online and in the JAXWS docs/samples and haven't been able to find a good example of how to send the byte data as an attachment vs. inline. I followed the mtom-large example in the JAXWS samples directory, which just says to use a DataHandler. Any code showing how to send the byte data as an attachment (MIME multipart) would REALLY be helpful :-)

My "contrived" client code looks like this:

public void uploadFile(String fileUrl, String webServiceUrl) throws Exception {
URL wsdlUrl = new URL(webServiceUrl);
QName qname = new QName("urn:myspace", "MyService");
Service service = Service.create(wsdlUrl, qname);
MyServiceEndpoint endpoint = service.getPort(MyServiceEndpoint.class,
new WebServiceFeature[] {
new StreamingAttachmentFeature(null, true, 4000000L),
});

((BindingProvider)endpoint).getRequestContext().put(
BindingProviderProperties.REQUEST_TIMEOUT, 30000);
DataHandler dh = new DataHandler(new URL(fileUrl));
endpoint.containMtom(fileUrl, dh);
}

alexj
Offline
Joined: 2007-03-02
Points: 0

The large_upload sample works fine for me. Streaming 1GB file with no issues.

MTOMFeature feature = new MTOMFeature();
UploadImplService service = new UploadImplService();
UploadImpl proxy = service.getUploadImplPort(feature);
Map ctxt = ((BindingProvider)proxy).getRequestContext();
ctxt.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
proxy.fileUpload("file.bin", new DataHandler(new FileDataSource(PUT YOUR FILE HERE)));

netminkey
Offline
Joined: 2007-12-18
Points: 0

Okay, so the new week starts with everything working just fine. jconsole reports no significant change when uploading a large file. Thanks to all for their helpful input!

One last question: the online docs for jaxws state (section 5.2.3):

There are several ways to enable MTOM.

1. By doing nothing. If the server WSDL advertises that it supports MTOM, the MTOM support in the client will be automatically enabled. This is the preferable way.
2. By passing MTOMFeature as WebServiceFeature parameter while creating a proxy or a Dispatch. See the example below: ...

My question is, if I do #1 (and leave out the MTOMFeature) on the client, the server throws an OutOfMemory error. If I do #2, everything works fine. What do I need to add to my server-side code to get the server WSDL to advertise that it supports MTOM? Neither of the 3 options given in section 5.2.2 states how to make this happen (and, having done #1 (adding @MTOM) and #2 (adding the entry to sun-jaxws.xml), neither seems to change the operational flow).

Thanks again!

Jitendra Kotamraju

metro@javadesktop.org wrote:
> Okay, so the new week starts with everything working just fine. jconsole reports no significant change when uploading a large file. Thanks to all for their helpful input!
>
> One last question: the online docs for jaxws state (section 5.2.3):
>
> There are several ways to enable MTOM.
>
> 1. By doing nothing. If the server WSDL advertises that it supports MTOM, the MTOM support in the client will be automatically enabled. This is the preferable way.
> 2. By passing MTOMFeature as WebServiceFeature parameter while creating a proxy or a Dispatch. See the example below: ...
>
> My question is, if I do #1 (and leave out the MTOMFeature) on the client, the server throws an OutOfMemory error. If I do #2, everything works fine. What do I need to add to my server-side code to get the server WSDL to advertise that it supports MTOM? Neither of the 3 options given in section 5.2.2 states how to make this happen (and, having done #1 (adding @MTOM) and #2 (adding the entry to sun-jaxws.xml), neither seems to change the operational flow).
>
There needs to be MTOM policy in WSDL. Only metro(not JAXWS RI)
understands this option, see section 5.2.5.2. So this section's
documentation needs to be improved.

thanks,
Jitu
> Thanks again!
> [Message sent by forum member 'netminkey' (netminkey)]
>
> http://forums.java.net/jive/thread.jspa?messageID=259537
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
> For additional commands, e-mail: users-help@metro.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net

driesva
Offline
Joined: 2007-09-26
Points: 0

I'm having the same problem. Where you able to get it working? I'm also following the user guide which is found here: https://jax-ws.dev.java.net/guide/Large_Attachments.html#Server_Side

--
Regards
Dries

xyliu512
Offline
Joined: 2008-01-23
Points: 0

I tried this as well. What I found was you have to deploy this as a web application, not EJB module.

jitu
Offline
Joined: 2003-06-14
Points: 0

Casting to StreamingDataHandler works only in 2.1.3 onwards. See there is a similar sample "large_upload" that comes with the distribution.

eskatos
Offline
Joined: 2007-05-14
Points: 0

So, using 2.1.3 is it possible to use this feature with WebService deployed as stateless EJB ?

bhaktimehta
Offline
Joined: 2004-03-18
Points: 0

I think it should work with WebService deployed as stateless EJB. You can confirm with GF v2.1 builds from here https://glassfish.dev.java.net/public/alldownloads.html#GlassFish_v2_1_b...
The latest build b18 should have jaxws 2.1.3.1 https://glassfish.dev.java.net/downloads/v2.1-b18.html

Regards,
Bhakti

pablius
Offline
Joined: 2007-02-19
Points: 0

I had the same problem servicing a method that receives binary content.
In this case, if the consumer sent an XOP (multipart) message it worked fine. If it sent inline binary content (base64 encoded) then the instantiated handler would be a plain DataHandler, not the Streaming one.

Just use the DataHandler methods, there's no need to cast to StreamingDataHandler to make it work.

Regards,
Pablo

jitu
Offline
Joined: 2003-06-14
Points: 0

Can you paste the stack trace if you have.

netminkey
Offline
Joined: 2007-12-18
Points: 0

I get the same exception (included below). Also, my client method signature does not allow DataHandler to be used -- it requires a byte[].

@MTOM(threshold=0)
@StreamingAttachment(parseEagerly=true, memoryThreshold=4000000L)
@WebService(name = "MyServiceEndpoint", serviceName = "MyService", targetNamespace = "urn:myspace")
@HandlerChain(file = "/jaxws-handlers.xml")
@SOAPBinding(style = SOAPBinding.Style.RPC, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class MyWebSvcImpl implements MyWebSvc
{ ... }

Here's my declaration:
@WebMethod(operationName = "containMtom")
@WebResult(name = "myResponse")
public String containMtom(
@WebParam(name = "name")String name,
@WebParam(name = "data")
@XmlMimeType("application/octet-stream") DataHandler data
)

Here's my client
URL wsdlUrl = new URL(webServiceUrl);
QName qname = new QName("urn:myspace", "MyService");
Service service = Service.create(wsdlUrl, qname);
MyServiceEndpoint endpoint = service.getPort(MyServiceEndpoint.class,
new WebServiceFeature[] {
new StreamingAttachmentFeature(null, true, 4000000L),
}
);
endpoint.containMtom( "name", "bytes".getBytes()); // have to do this!

Stack Trace here:
+++++++++++ class javax.activation.DataHandler
application/octet-stream
null
java.lang.ClassCastException: javax.activation.DataHandler
at ziplock.frontend.webservice.impl.ZiplockWebServiceImpl.containMtom(ZiplockWebServiceImpl.java:83)
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.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:246)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:129)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:160)
at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)

Jitendra Kotamraju

metro@javadesktop.org wrote:
> I get the same exception (included below). Also, my client method signature does not allow DataHandler to be used -- it requires a byte[].
>
> @MTOM(threshold=0)
> @StreamingAttachment(parseEagerly=true, memoryThreshold=4000000L)
> @WebService(name = "MyServiceEndpoint", serviceName = "MyService", targetNamespace = "urn:myspace")
> @HandlerChain(file = "/jaxws-handlers.xml")
> @SOAPBinding(style = SOAPBinding.Style.RPC, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
>
Can you remove the @SOAPBinding annotation and try. "mtom-large" sample
does may to DataHandler instead of byte[]. May be there is a bug in
rpc/lit. I see that in some cases, we are returning DataHandler instead
of StreamingDataHandler. So you have to use instanceof. Other thing is,
having handlers in this case, would inline the binary data in envelope.

Jitu
> public class MyWebSvcImpl implements MyWebSvc
> { ... }
>
> Here's my declaration:
> @WebMethod(operationName = "containMtom")
> @WebResult(name = "myResponse")
> public String containMtom(
> @WebParam(name = "name")String name,
> @WebParam(name = "data")
> @XmlMimeType("application/octet-stream") DataHandler data
> )
>
> Here's my client
> URL wsdlUrl = new URL(webServiceUrl);
> QName qname = new QName("urn:myspace", "MyService");
> Service service = Service.create(wsdlUrl, qname);
> MyServiceEndpoint endpoint = service.getPort(MyServiceEndpoint.class,
> new WebServiceFeature[] {
> new StreamingAttachmentFeature(null, true, 4000000L),
> }
> );
> endpoint.containMtom( "name", "bytes".getBytes()); // have to do this!
>
> Stack Trace here:
> +++++++++++ class javax.activation.DataHandler
> application/octet-stream
> null
> java.lang.ClassCastException: javax.activation.DataHandler
> at ziplock.frontend.webservice.impl.ZiplockWebServiceImpl.containMtom(ZiplockWebServiceImpl.java:83)
> 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.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:246)
> at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
> at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
> at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)
> at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
> at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
> at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
> at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
> at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)
> at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444)
> at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
> at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
> at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:129)
> at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:160)
> at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:75)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> at java.lang.Thread.run(Thread.java:595)
> [Message sent by forum member 'netminkey' (netminkey)]
>
> http://forums.java.net/jive/thread.jspa?messageID=258603
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
> For additional commands, e-mail: users-help@metro.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net

gmazza
Offline
Joined: 2005-01-14
Points: 0

I don't believe you can assume that the DataHandler passed into your WS can be downcast to a StreamingDataHandler. I did something similar client-side though[1] that you might be able to leverage.

HTH,
Glen

[1] http://www.jroller.com/gmazza/date/20071102#NWSstep11

eskatos
Offline
Joined: 2007-05-14
Points: 0

gmazza, as driesva, I'm just following an official guide that read :

[code]
DataHandler dh = proxy.fileUpload(...);
StreamingDataHandler sdh = (StreamingDataHandler)dh;
[/code]

So, your answer disapoint me, what is the good way to write a mtom client ? Anybody ?