Re: AW: AW: AW: java.io.IOException: Stream closed

2008-12-14 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Stefan,

Schuster Stefan wrote:
> As far as I can tell, the XML-Beans generated code works well - even if
> The stream is closed after reading, this should be no problem as the next
> request will submit a new stream, right?

Yes, your servlet can close an input stream when it's done reading (even
if the request is one of several keep-alive requests). You better make
sure you're done reading it, though ;)

Generally, I don't ever close servlet input streams (or readers). The
container will clean up after input streams after the request processing
has been completed by your servlet. I find that such cleanup adds
confusion to your servlet code and doesn't add any benefit.

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAklFJRgACgkQ9CaO5/Lv0PCI1ACeJIKLuvS28oyEvlku55jiAf4+
0Y0An0nwvNMKdlq3qPQsrl+oKilOVI7O
=goca
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



AW: AW: AW: java.io.IOException: Stream closed

2008-12-11 Thread Schuster Stefan
Hi,

sorry for the long delay - I needed some time away from tomcat and XML ;)
The client is XCelsius (an MS Excel extension that can be used to
access webservices and read XML files from web resources).

As far as I can tell, the XML-Beans generated code works well - even if
The stream is closed after reading, this should be no problem as the next
request will submit a new stream, right?

I will rework the servlet to use a reader, I let you know if that fixes the
Problem.

Thanks for your suggestions,

Stefan

-Ursprüngliche Nachricht-
Von: Christopher Schultz [mailto:[EMAIL PROTECTED] 
Gesendet: Freitag, 5. Dezember 2008 17:43
An: Tomcat Users List
Betreff: Re: AW: AW: java.io.IOException: Stream closed

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Stefan,

Schuster Stefan wrote:
> The code reading the stream is generated by XMLBeans. 
> 
> Is there something that I should not do with the stream? For example
> closing it or something like that?

You shouldn't have to do anything like that.

> <<>>
>   inDoc = DataDocument.Factory.parse(is, xmlOptions);
> <<>>

Looks reasonable to me. Does DataDocument.Factory.parse() do anything
weird like close the stream and then try to read from it again?

Your problem is probably caused by one of two things:

1. Some code stupidly closes the input stream, then tries reading
   from it later

2. The client didn't send enough data

I wonder if there's a character encoding problem, here. You are using an
InputStream from the request and not a Reader, so the Content-Type
encoding from the request is being ignored. If the XML processing
instruction includes an "encoding" parameter, this might be okay, but
I've seen XML documents saying one type of encoding while the actual
encoding is something else (whoops!).

What client are you using to submit this data to the servlet?

Also, what Connector are you using in Tomcat? AJP? HTTP? Nio?

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkk5WhMACgkQ9CaO5/Lv0PCfSwCfef6s6a3meZROUFiJsGBEgSgx
zbgAn1bOUSVVikoGJLNy3Dvgot0bHCoR
=rJcd
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: AW: AW: java.io.IOException: Stream closed

2008-12-05 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Stefan,

Schuster Stefan wrote:
> The code reading the stream is generated by XMLBeans. 
> 
> Is there something that I should not do with the stream? For example
> closing it or something like that?

You shouldn't have to do anything like that.

> <<>>
>   inDoc = DataDocument.Factory.parse(is, xmlOptions);
> <<>>

Looks reasonable to me. Does DataDocument.Factory.parse() do anything
weird like close the stream and then try to read from it again?

Your problem is probably caused by one of two things:

1. Some code stupidly closes the input stream, then tries reading
   from it later

2. The client didn't send enough data

I wonder if there's a character encoding problem, here. You are using an
InputStream from the request and not a Reader, so the Content-Type
encoding from the request is being ignored. If the XML processing
instruction includes an "encoding" parameter, this might be okay, but
I've seen XML documents saying one type of encoding while the actual
encoding is something else (whoops!).

What client are you using to submit this data to the servlet?

Also, what Connector are you using in Tomcat? AJP? HTTP? Nio?

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkk5WhMACgkQ9CaO5/Lv0PCfSwCfef6s6a3meZROUFiJsGBEgSgx
zbgAn1bOUSVVikoGJLNy3Dvgot0bHCoR
=rJcd
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



AW: AW: java.io.IOException: Stream closed

2008-12-05 Thread Schuster Stefan
Hi Chris,

the servlet contains no rocket science, so I am comfortable posting it 
completely ;) Error arrises on part marked with <<>>. The code reading 
the stream is generated by XMLBeans. 

Is there something that I should not do with the stream? For example
closing it or something like that?

Best regards and thanks for looking into the problem

Stefan




/**
 * Servlet implementation class XMLServiceServlet
 */
public class XMLServiceServlet extends HttpServlet {
private XmlOptions xmlOptions = new XmlOptions();
private static final long serialVersionUID = 1L;
private RequestTransformer reqT = new RequestTransformer();
private ResponseTransformer respT = new ResponseTransformer();

/**
 * @see HttpServlet#HttpServlet()
 */
public XMLServiceServlet() {
HashMap namespaceMap = new HashMap();
//  namespaceMap.put("", "http://cirquent.de/XcelsiusTable";);
//  namespaceMap.put("http://cirquent.de/XcelsiusTable","";);
xmlOptions.setLoadSubstituteNamespaces(namespaceMap);
}

/**
 * @see HttpServlet#doGet(HttpServletRequest request, 
HttpServletResponse
 *  response)
 */
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, 
IOException {
handleRequest(request, response);
}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, 
HttpServletResponse
 *  response)
 */
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, 
IOException {
handleRequest(request, response);
}

private void handleRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, 
IOException {

InputStream is = request.getInputStream();
DataDocument dDoc = getDocument(is);
DataDocument resultDoc = this.callService(dDoc);

response.getOutputStream().write(resultDoc.toString().getBytes());
response.setHeader("Connection", "close");
}

private DataDocument getDocument(InputStream is) {
DataDocument inDoc = null;
try {
<<>>
inDoc = DataDocument.Factory.parse(is, xmlOptions);
<<>>
} catch (Exception ex) {
ex.printStackTrace();
}
return inDoc;
}

private DataDocument callService(DataDocument dDoc) {
boolean test = false;
if(test){
TestTransformer tt = new TestTransformer();
tt.getRequestFromDataDocument(dDoc);
return tt.getDataDocumentFromResponse(null);
}

try {
GetQueryViewData request = 
reqT.getRequestFromDataDocument(dDoc);

mc_style.functions.soap.sap.document.sap_com.Query_view_dataServiceStub stub = 
new 
mc_style.functions.soap.sap.document.sap_com.Query_view_dataServiceStub();// the
GetQueryViewDataResponse response = 
stub.GetQueryViewData(request);
return respT.getDataDocumentFromResponse(response);
} catch (Exception ex) {
ex.printStackTrace();
return null;
}

}
}

-Ursprüngliche Nachricht-
Von: Christopher Schultz [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 4. Dezember 2008 23:22
An: Tomcat Users List
Betreff: Re: AW: java.io.IOException: Stream closed

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Stafan,

Schuster Stefan wrote:
> I still have the problem mentioned below. I just don't have any idea
> where to start with problem solving?  Can it be a problem in Tomcat? I guess
> not as this is a very simple use-case (read the stream in the servlet) and
> it would have probably come up ealier...

In case you didn't see my other post, please post as much of your
de.cirquent.nwfi.xcelsius.XMLServiceServlet as you can.

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkk4WAwACgkQ9CaO5/Lv0PDtMQCeKRYlIZ+IztOUenCtEvMO3jKI
XuwAn39eTXUhNbb7Krz2FQDNMW9rc3Oh
=jQeB
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: AW: java.io.IOException: Stream closed

2008-12-04 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Stafan,

Schuster Stefan wrote:
> I still have the problem mentioned below. I just don't have any idea
> where to start with problem solving?  Can it be a problem in Tomcat? I guess
> not as this is a very simple use-case (read the stream in the servlet) and
> it would have probably come up ealier...

In case you didn't see my other post, please post as much of your
de.cirquent.nwfi.xcelsius.XMLServiceServlet as you can.

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkk4WAwACgkQ9CaO5/Lv0PDtMQCeKRYlIZ+IztOUenCtEvMO3jKI
XuwAn39eTXUhNbb7Krz2FQDNMW9rc3Oh
=jQeB
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



AW: java.io.IOException: Stream closed

2008-12-04 Thread Schuster Stefan
Hi everybody,

I still have the problem mentioned below. I just don't have any idea
where to start with problem solving?  Can it be a problem in Tomcat? I guess
not as this is a very simple use-case (read the stream in the servlet) and
it would have probably come up ealier...

Any Ideas? Please?

Thanks
Stefan

-Ursprüngliche Nachricht-
Von: Schuster Stefan [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 2. Dezember 2008 15:24
An: users@tomcat.apache.org
Betreff: java.io.IOException: Stream closed

Hi everybody,

I have the following problem with tomcat 6.0.18:
I wrote a servlet that reads the input stream with
XML Beans. An application sends requests to the servlet, but only the first 
request succeedes. Every
Second call results in the following exception:


java.io.IOException: Stream closed
at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:325)
at 
org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:193)
at 
org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader.fillByteBuffer(XMLStreamReader.java:209)
at 
org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader.reset(XMLStreamReader.java:97)
at 
org.apache.xmlbeans.impl.piccolo.xml.DocumentEntity.open(DocumentEntity.java:94)
at 
org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.reset(PiccoloLexer.java:982)
at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:709)
at 
org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3454)
at 
org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1276)
at 
org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1263)
at 
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
at noNamespace.DataDocument$Factory.parse(Unknown Source)
at 
de.cirquent.nwfi.xcelsius.XMLServiceServlet.getDocument(XMLServiceServlet.java:71)02.12.2008
 14:55:19 org.apache.catalina.core.StandardWrapperValve invoke
SCHWERWIEGEND: Servlet.service() for servlet XMLServiceServlet threw exception


I do not cache the input stream in the servlet, so I do not understand how the
subsequent transmissions are related? I am even sending a "connection close" 
with
the response to make shure that there is no issue with a reused connection.

Any ideas?


Best regards,
Stefan Schuster

Consultant NW FI


cirquent | softlab group

Cirquent GmbH

Königsberger Straße 29 | 60487 Frankfurt a.M.

Telefon +49 69 97261-800 | Fax +49 69 97261-899
E-Mail [EMAIL PROTECTED] | Mobil +49 151 1822 5456
Internet http://www.cirquent.de

Cirquent GmbH | Geschäftsführung: Peter Broicher (Vorsitzender), Dr. Stefan 
Aicher,
Thomas Balgheim (stellvertretender Vorsitzender), Bernd Stroppel, Said Tabet
Sitz und Amtsgericht: München HRB 51846

 


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]