You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by sscott <ss...@mapit.net> on 2017/03/31 15:11:48 UTC
Node Returned from EJB causes StackOverflowError in Servlet
I am using TomEE-Plume (1.7.2).
I have a Servlet that makes a Service Layer call to an EJB.
The EJB has a Node (org.w3c.dom.Node) input parameter and a Node output
Parameter.
When the dataset is large and contains many elements in the returned Node, I
get a StackOverflowError
in the Servlet where the Node is returned.
Node outputData = service.serviceRequest(parameters);
What is the best practice to solve this situation?
Could I use SAX to parse/read the Node (org.w3c.dom.Node) as it is received?
Any pointers or advice are greatly appreciated.
Thank you.
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Node-Returned-from-EJB-causes-StackOverflowError-in-Servlet-tp4681420.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: Node Returned from EJB causes StackOverflowError in Servlet
Posted by sscott <ss...@mapit.net>.
Thank you for your thoughtful advice.
I encoded the XML as a string, and added it to another Node.
My in and out parameters are all still nodes, but if the "EncodedData"
element exists, I create a node from the decoded contents, and use it.
I also considered using the -Xss to set the stack size larger. I decided
against that due to concerns about performance and out of memory errors.
Thanks again, very helpful.
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Node-Returned-from-EJB-causes-StackOverflowError-in-Servlet-tp4681420p4681428.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: Node Returned from EJB causes StackOverflowError in Servlet
Posted by Paul Carter-Brown <pa...@smilecoms.com>.
Hi,
Not sure if you can change your API but when I deal with very large data
sets on SOAP, I pass the data as a string in a single element. The string
is Base64 encoded zip of the original string
My function I use:
public static String zip(String uncompressed) {
if (uncompressed == null || uncompressed.isEmpty()) {
return uncompressed;
}
GZIPOutputStream gzip = null;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
gzip = new GZIPOutputStream(out);
gzip.write(uncompressed.getBytes());
gzip.close();
return new
String(org.apache.commons.codec.binary.Base64.encodeBase64(out.toByteArray()),
"ISO-8859-1");
} catch (Exception e) {
myLogger.warn("Error zipping: ", e);
return "";
} finally {
if (gzip != null) {
try {
gzip.close();
} catch (IOException ex) {
myLogger.warn("Error zipping: ", ex);
}
}
}
}
then on the client:
public static String unzip(String compressed) {
if (compressed == null || compressed.isEmpty()) {
return compressed;
}
try {
byte[] b =
org.apache.commons.codec.binary.Base64.decodeBase64(compressed.getBytes("ISO-8859-1"));
ByteArrayInputStream in = new ByteArrayInputStream(b);
GZIPInputStream gzip = new GZIPInputStream(in);
return parseStreamToString(gzip, "ISO-8859-1");
} catch (Exception e) {
myLogger.warn("Error unzipping: ", e);
return "";
}
}
public static String parseStreamToString(java.io.InputStream is, String
encoding) throws Exception {
try {
return IOUtils.toString(is, encoding);
} finally {
is.close();
}
}
On 31 March 2017 at 17:11, sscott <ss...@mapit.net> wrote:
> I am using TomEE-Plume (1.7.2).
>
> I have a Servlet that makes a Service Layer call to an EJB.
> The EJB has a Node (org.w3c.dom.Node) input parameter and a Node output
> Parameter.
> When the dataset is large and contains many elements in the returned Node,
> I
> get a StackOverflowError
> in the Servlet where the Node is returned.
>
> Node outputData = service.serviceRequest(parameters);
>
> What is the best practice to solve this situation?
> Could I use SAX to parse/read the Node (org.w3c.dom.Node) as it is
> received?
> Any pointers or advice are greatly appreciated.
> Thank you.
>
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/Node-Returned-from-EJB-causes-StackOverflowError-in-Servlet-
> tp4681420.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>
--
*Paul Carter-Brown*
*Group Chief Information Officer*
*Smile Communications Pty (Ltd) *
Smile +234 (0) 702 000 1234
Mobile +27 (0) 83 4427 179
Skype PaulC-B
paul.carter-brown@smilecoms.com
www.smilecoms.com
--
This email is subject to the disclaimer of Smile Communications at http://www.smilecoms.com/home/email-disclaimer/ <http://www.smilecoms.com/disclaimer>
Re: Node Returned from EJB causes StackOverflowError in Servlet
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Can't you use chunks/subset and do multiple calls? ~ kind of pagination
like logic
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>
2017-03-31 17:11 GMT+02:00 sscott <ss...@mapit.net>:
> I am using TomEE-Plume (1.7.2).
>
> I have a Servlet that makes a Service Layer call to an EJB.
> The EJB has a Node (org.w3c.dom.Node) input parameter and a Node output
> Parameter.
> When the dataset is large and contains many elements in the returned Node,
> I
> get a StackOverflowError
> in the Servlet where the Node is returned.
>
> Node outputData = service.serviceRequest(parameters);
>
> What is the best practice to solve this situation?
> Could I use SAX to parse/read the Node (org.w3c.dom.Node) as it is
> received?
> Any pointers or advice are greatly appreciated.
> Thank you.
>
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/Node-Returned-from-EJB-causes-StackOverflowError-in-Servlet-
> tp4681420.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>