Ok, so here's the deal.... I implemented a MultiplexedInputStream (and
MultiplexedOutputStream). Calling unmarshal indirectly closes the
stream BECAUSE XmlReader$Utf8Reader closes the stream once it is done
reading. I am looking at overriding the close method, but..... there
REALLY needs to be a better way to read/write JAXB from/to a SOCKET.
reading taskman from the socket
com.temporalwave.io.MultiplexedInputStream is closing!
** TRACE START
com.temporalwave.util.RuntimeUtil(printStackTrace): line #-1
com.temporalwave.util.RuntimeUtil(printStackTrace): line #-1
com.temporalwave.io.MultiplexedInputStream(close): line #-1
java.io.PushbackInputStream(close): line #303
org.apache.crimson.parser.XmlReader$BaseReader(close): line #595
org.apache.crimson.parser.XmlReader$Utf8Reader(read): line #647
org.apache.crimson.parser.XmlReader(read): line #487
org.apache.crimson.parser.InputEntity(fillbuf): line #1068
org.apache.crimson.parser.InputEntity(isXmlDeclOrTextDeclPrefix): line
#914
org.apache.crimson.parser.Parser2(maybeXmlDecl): line #1150
org.apache.crimson.parser.Parser2(parseInternal): line #620
org.apache.crimson.parser.Parser2(parse): line #333
org.apache.crimson.parser.XMLReaderImpl(parse): line #448
com.temporalwave.spec.taskman.impl.runtime.UnmarshallerImpl(unmarshal):
line #-1
javax.xml.bind.helpers.AbstractUnmarshallerImpl(unmarshal): line #131
javax.xml.bind.helpers.AbstractUnmarshallerImpl(unmarshal): line #178
com.temporalwave.util.JAXBUtil(read): line #-1
com.temporalwave.taskman.server.RequestHandler(run): line #-1
** TRACE END
-----Original Message-----
From: Malachi de Aelfweald
Sent: Friday, August 22, 2003 8:52 AM
To: 'users_at_jaxb.dev.java.net'
Yes, but for the simple case of sending a single XML document over the
output stream, and a response xml document over the input stream -- that
shouldn't be needed.
Also, I don't think PI can exist after the end of the root tag, can
they? I thought nothing could exist after the end of the root tag. My
real comment is that ONLY JAXB has a problem sending/receiving XML
documents over a socket.
As a side note, I did an implementation as suggested. Still trying to
figure it out though. I am sending character 0x17 (ETB, ie:
EndTransmissionBlock) as the marker -- but for some reason, unmarshall
is still closing the socket before I can send any data back in response.
Still trying to figure it out.
Malachi
-----Original Message-----
From: Robert Lowe [mailto:rmlowe_at_rmlowe.com]
Sent: Friday, August 22, 2003 4:37 AM
To: users_at_jaxb.dev.java.net
Personally I think Kohsuke's explanation makes perfect sense. Without
the
EOF marker, there could be some ambiguous cases. For example, consider a
character stream like this:
<root>The first document.</root>
<?some-processing-instruction?>
<!-- A comment. -->
<root>The second document.</root>
Now which document does the PI belong to? What about the comment?
Without an
EOF marker there's no way to tell.
Admittedly JAXB doesn't care about PIs and comments, but a generic SAX
or
DOM parser certainly would.
- Rob
-----Original Message-----
From: Malachi de Aelfweald [mailto:malachid_at_temporal-wave.com]
Sent: Friday, August 22, 2003 7:11 AM
To: users_at_jaxb.dev.java.net
Subject: RE: Re: Unmarshalling via InputStream
I'll try to follow that and come up with something, although I disagree
with the solution. In the second link, it sounds as if Kohsuke is
saying that this is the case with any XML over TCP... However, I have
another application that currently does the following (and works):
DOMParser parser = new DOMParser();
parser.parse(new InputSource(socket.getInputStream));
return (new DOMBuilder()).build(parser.getDocument());
Yet, doing
unmarshaller.unmarshal(socket.getInputStream())
or even
unmarshaller.unmarshal(new
InputSource(socket.getInputStream()))does not work...
which means....
DOMParser can parse the data coming in, but JAXB's unmarshaller can not.
It is not an XML thing, it is a JAXB thing.
I think that is a serious bug, since anyone trying to use the
unmarshal(InputSource) or unmarshal(InputStream) will find they do not
work.
If they are going to require some custom InputStream to work, then that
class should be provided AND required by the API [ie:
unmarshal(CustomInputStream)]. It does not make sense to provide these
functions if they do not work out of the box.
Malachi
-----Original Message-----
From: Ryan Shoemaker - JavaSoft East [mailto:Ryan.Shoemaker_at_Sun.COM]
Sent: Thursday, August 21, 2003 2:36 PM
To: users_at_jaxb.dev.java.net
Malachi de Aelfweald wrote:
> I am trying to send data through a socket, using a marshaller at one
end
> and an unmarshaller at the other. To ensure that the problem was not
on
> the marshaller side (perhaps, flushing, etc), I put a filter stream on
> the unmarshaller side and saw that all the data was in fact being sent
> (including an extra blank line at the end).
>
> The unmarshaller never returns from the unmarshall call, even though
all
> the data is there. If I hard-close the stream on the sending side,
then
> it returns with the content just fine, but then the socket is hosed
for
> further communication.
>
>
A similiar question[1] has already been posted and I think Kohsuke's
reply[2]
covers your use-case as well. There's also a sample app bundled with
the
release that you may be able to leverage - look for samples/xml-channel.
Thanks,
--Ryan
[1]
https://jaxb.dev.java.net/servlets/ReadMsg?list=users&msgId=10789
[2]
https://jaxb.dev.java.net/servlets/ReadMsg?list=users&msgId=10835
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net