forwadring to Servlet from Remote object fails

hi guys
I am generating Pdf from flex. From my flex client i call 'RemoteCustomer'  a java remote object and call generatePdf()method. In this method i am trying to forward to a java Servlet called PDFServlet which is in the same package as RemoteCustomer but i get error shown below


public class RemoteCustomer{

public void generatePdf(Workflow workflow){
boolean pdfStatus = true;
try{
String sessionKeyName = "PDF_BYTESTREAM";
ByteArrayOutputStream pdfByteStream = null;
HttpServletRequest request = flex.messaging.FlexContext.getHttpRequest();
HttpServletResponse response = flex.messaging.FlexContext.getHttpResponse();
pdfByteStream = PdfMaker.makePdf(workflow); -- this contains the byte stream which needs to be passed to servlet
request.getSession().setAttribute(sessionKeyName,p dfByteStream);
request.getRequestDispatcher("PDFServlet").forward(request, response); //PDFServlet exist in same package as this class
}
}

PDFServlet is my servlet class but unfortunately its not forwarding to the servlet.

It says

org.springframework.flex.servlet.MessageBrokerHand lerAdapter handle Received invalid request for endpoint path '/messagebroker/PDFServlet'.[4/26/11 12:58:10:850 EDT] 00000029 srt W com.ibm.ws.webcontainer.srt.SRTServletResponse addHeader WARNING: Cannot set header. Response already committed.
[4/26/11 12:58:10:865 EDT] 00000029 srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setDateHeader WARNING: Cannot set header. Response already committed.
[4/26/11 12:58:10:865 EDT] 00000029 srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setHeader WARNING: Cannot set header. Response already committed.
[4/26/11 12:58:10:928 EDT] 00000029 srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader WARNING: Cannot set header. Response already committed.
[4/26/11 12:58:10:944 EDT] 00000029 SystemOut O [BlazeDS]SRVE0209E: Writer already obtained
java.lang.IllegalStateException: SRVE0209E: Writer already obtained
at com.ibm.ws.webcontainer.srt.SRTServletResponse.get Outpu

Any help will be greatly appreciated
thanks
royjaydAsked:
Who is Participating?
 
ChristoferDutzConnect With a Mentor Commented:
Well one byte is one byte of size ... the Java Object Byte is a lot bigger. I encountered really major memory issues as Flex Uploade of about 10MB used more than 100MB of memory on the server. ... Guess this is because BlazeDS reads the AMF for a starting array and therefore creates An Object[] ... unfortunately each element of the array is one byte to BlazeDS creates one byte Object and not a byte primitive and adds that to the array.

My solution was to do uploads and downloads of byte data parralell to AMF/BlazeDS using Spring MVC components.
0
 
ChristoferDutzCommented:
Well I guess you are recieving this error because you are using the http-request and response objects to output your data. Unfortunately blazeds uses these objects to output an AMF serialized form of the data returned by a method call. So you are bypassing the AMF serialization and this is what BlazeDS and Flex are complaining about. In BlazeDS ByteArrays are extremely imperformant (byte[] would be great, but Byte[] really sucks (takes about 10 times the memory).

I would suggest to call your Servlet directly from the Flex client using an UrlRequest or something like that.
0
 
royjaydAuthor Commented:
yeah, makes sense

when you said
>>>byte[] would be great, but Byte[] really sucks

whats the difference between byte[] and Byte[]

thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.