users@jax-rpc.java.net

Re: Using DataHandler as return value from a method

From: Vivek Pandey <Vivek.Pandey_at_Sun.COM>
Date: Thu, 07 Oct 2004 11:04:49 -0700

Martin,

This exception is because the JVM is out of heap memory. You can try
increasing the jvm heap momory size by using Xms and Xmx jvm arguments
on the server.

something like:

java -Xms16mb -Xmx256mb ....

-vivek.

Martin Marinschek wrote:

> Hi,
>
> would there be no one interested in problems with large attachments?
> Are webservices really only useful for small junks of data?
>
> regards,
>
> Martin
>
> >> My original message
>
> Hi there,
>
> I am using JAX-RPC, and compile my WSDL from the following interface:
>
> public interface ContentServer extends Remote
> {
> public DataHandler downloadContent(String userName, String passWord,
> long id)
> throws RemoteException;
> }
>
> Now I am filling the return value with the code in the respective
> Impl-class (code of the impl-class can be found further below).
>
> Finally, I compile client stubs for the code and run a small client
> against those stubs - printing out the retrieved values:
>
> public class DemoClient
> {
> public static void main (String args[])
> throws Exception
> {
> ContentServer_Service_Impl service =
> new ContentServer_Service_Impl();
> ContentServer_PortType stub = service.getContentServerPort();
>
> DataHandler handler = stub.downloadContent("exmam","xxx",45);
>
> BufferedReader instr = new BufferedReader(
> new InputStreamReader(handler.getInputStream()));
>
> String str=null;
>
> while((str = instr.readLine())!=null)
> System.out.println(str);
>
> System.out.println("success");
>
> }
> }
>
> This works fine if the file is a rather small one (let's say up to a
> megabyte), with larger files (I tried a 16MB file) I inevitably run
> into the following exception, even though my memory should easily be
> able to cope with the size of the file and I am using only stream-based
> access....
>
> Are there any restrictions on how large an attached file can grow in
> using the JAX-RPC Datahandler mapping?
>
> regards,
>
> Martin
>
> java.lang.OutOfMemoryError
> 04.10.2004 13:10:55 com.sun.xml.messaging.saaj.soap.MessageImpl <init>
> SCHWERWIEGEND: SAAJ0535: Unable to internalize message
> java.rmi.RemoteException: HTTP transport error:
> com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to internalize
> message; nested exception is:
> HTTP transport error: com.sun.xml.messaging.saaj.SOAPExceptionImpl:
> Unable to internalize message
> at
> at.oekb.clearinghouse.webservices.client.content.ContentServer_PortType_Stub.downloadContent(ContentServer_PortType_Stub.java:89)
>
> at
> at.oekb.clearinghouse.webservices.client.content.DemoClient.main(DemoClient.java:27)
>
> 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:324)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
> Caused by: HTTP transport error:
> com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to internalize
> message
> at
> com.sun.xml.rpc.client.http.HttpClientTransport.invoke(HttpClientTransport.java:140)
>
> at
> com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:92)
> at
> at.oekb.clearinghouse.webservices.client.content.ContentServer_PortType_Stub.downloadContent(ContentServer_PortType_Stub.java:72)
>
> ... 6 more
> Exception in thread "main"
>
> public class ContentServerImpl implements ContentServer
> {
> public DataHandler downloadContent(String userName, String passWord,
> long id)
> {
>
> String dsName1 = "jdbc/roncalli_dev"; // JNDI name
> javax.sql.DataSource ds1 = null;
> Connection conn = null;
>
> try
> {
> Context ic = new InitialContext();
> Context ctx = (Context) ic.lookup("java:comp/env");
> ds1 = (javax.sql.DataSource)ctx.lookup(dsName1); // Problem
> here
> conn = ds1.getConnection();
>
> } catch (Exception e) {
> e.printStackTrace();
> }
>
>
> InputStream dataStream =
> XMLLoader.getAsAsciiStream(conn,"contents","id","data",id);
> StreamDataSource src = new StreamDataSource();
> src.setInputStream(dataStream);
> src.setName("content.xml");
>
> DataHandler handler = new DataHandler(src);
>
> return handler;
> }
>
> public static class StreamDataSource implements DataSource
> {
> private InputStream _inputStream;
> private OutputStream _outputStream;
> private String _name;
> private String _contentType = "text/xml";
>
> public void setInputStream(InputStream inputStream)
> {
> _inputStream = inputStream;
> }
>
> public void setName(String name)
> {
> _name = name;
> }
>
> public void setOutputStream(OutputStream outputStream)
> {
> _outputStream = outputStream;
> }
>
> public InputStream getInputStream() throws IOException
> {
> return _inputStream;
> }
>
> public OutputStream getOutputStream() throws IOException
> {
> return _outputStream;
> }
>
> public String getContentType()
> {
> return _contentType;
> }
>
> public String getName()
> {
> return _name;
> }
>
> public void setContentType(String contentType)
> {
> _contentType = contentType;
> }
> }
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
> For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
>

-- 
Vivek Pandey
Web Technologies and Standards
Sun Microsystems Inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net