ObjectInputStream 中的 EOFException 仅发生在 Webstart 上,而不是由 java(w).exe 发生?
任何熟悉启动 Webstart(javaws.exe) 与启动应用程序的差异的人。使用 java.exe 或 javaw.exe 关于流?
这是我仅在使用 Webstart 时遇到的异常:
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at fasttools.jtools.dss.api.core.remoting.thinclient.RemoteSocketChannel.<init>(RemoteSocketChannel.java:77)
这是我在两侧设置连接的方式
//==Server side==
//Thread{
Socket mClientSocket = cServSock.accept();
new DssServant(mClientSocket).start();
//}
DssServant(Socket socket) throws DssException {
try {
OutputStream mOutputStream = new BufferedOutputStream( socket.getOutputStream() );
cObjectOutputStream = new ObjectOutputStream(mOutputStream);
cObjectOutputStream.flush(); //publish streamHeader
InputStream mInputStream = new BufferedInputStream( socket.getInputStream() );
cObjectInputStream = new ObjectInputStream(mInputStream);
..
} catch (IOException e) {
..
}
..
}
//==Client side==
public RemoteSocketChannel(String host, int port, IEventDispatcher eventSubscriptionHandler) throws DssException {
cHost = host;
port = (port == 0 ? DssServer.PORT : port);
try {
cSocket = new Socket(cHost, port);
OutputStream mOutputStream = new BufferedOutputStream( cSocket.getOutputStream() );
cObjectOut = new ObjectOutputStream(mOutputStream);
cObjectOut.flush(); //publish streamHeader
InputStream mInputStream = new BufferedInputStream( cSocket.getInputStream() );
cObjectIn = new ObjectInputStream(mInputStream);
} catch (IOException e) {
..
}
..
}
[编辑] Webstart 控制台说: Java Web 启动 1.6.0_19 使用 JRE 版本 1.6.0_19-b04 Java HotSpot(TM) 客户端 VM
服务器运行相同的 1.6u19
[编辑] JNLP 包含:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://127.0.0.1:8080/">
<information>
<title>..</title>
<vendor>..</vendor>
<homepage href="http://127.0.0.1:8080/index.html"/>
<description>..</description>
<icon href="/jws/.."/>
<icon kind="splash" href="/jws/...jpg"/>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+" initial-heap-size="128M" max-heap-size="512M"/>
<jar href="http://127.0.0.1:8080/lib/xx.jar"/>
<jar href="http://127.0.0.1:8080/lib/yy.jar"/>
</resources>
<application-desc main-class="..">
<argument>-host</argument> <argument>127.0.0.1</argument>
<argument>-port</argument> <argument>4359</argument>
<argument>-httpport</argument> <argument>8080</argument>
</application-desc>
</jnlp>
谢谢
Anyone familiar with the differences in starting with Webstart(javaws.exe) compared to starting the app. using java.exe or javaw.exe regarding streams ?
This is the exception which i ONLY get when using Webstart :
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at fasttools.jtools.dss.api.core.remoting.thinclient.RemoteSocketChannel.<init>(RemoteSocketChannel.java:77)
This is how i setup the connections on both sides
//==Server side==
//Thread{
Socket mClientSocket = cServSock.accept();
new DssServant(mClientSocket).start();
//}
DssServant(Socket socket) throws DssException {
try {
OutputStream mOutputStream = new BufferedOutputStream( socket.getOutputStream() );
cObjectOutputStream = new ObjectOutputStream(mOutputStream);
cObjectOutputStream.flush(); //publish streamHeader
InputStream mInputStream = new BufferedInputStream( socket.getInputStream() );
cObjectInputStream = new ObjectInputStream(mInputStream);
..
} catch (IOException e) {
..
}
..
}
//==Client side==
public RemoteSocketChannel(String host, int port, IEventDispatcher eventSubscriptionHandler) throws DssException {
cHost = host;
port = (port == 0 ? DssServer.PORT : port);
try {
cSocket = new Socket(cHost, port);
OutputStream mOutputStream = new BufferedOutputStream( cSocket.getOutputStream() );
cObjectOut = new ObjectOutputStream(mOutputStream);
cObjectOut.flush(); //publish streamHeader
InputStream mInputStream = new BufferedInputStream( cSocket.getInputStream() );
cObjectIn = new ObjectInputStream(mInputStream);
} catch (IOException e) {
..
}
..
}
[EDIT]
Webstart console says:
Java Web Start 1.6.0_19
Using JRE version 1.6.0_19-b04 Java HotSpot(TM) Client VM
Server is running same 1.6u19
[EDIT]
JNLP contains:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://127.0.0.1:8080/">
<information>
<title>..</title>
<vendor>..</vendor>
<homepage href="http://127.0.0.1:8080/index.html"/>
<description>..</description>
<icon href="/jws/.."/>
<icon kind="splash" href="/jws/...jpg"/>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+" initial-heap-size="128M" max-heap-size="512M"/>
<jar href="http://127.0.0.1:8080/lib/xx.jar"/>
<jar href="http://127.0.0.1:8080/lib/yy.jar"/>
</resources>
<application-desc main-class="..">
<argument>-host</argument> <argument>127.0.0.1</argument>
<argument>-port</argument> <argument>4359</argument>
<argument>-httpport</argument> <argument>8080</argument>
</application-desc>
</jnlp>
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您可能需要在 JNLP 文件中请求许可。尝试添加
请参阅 http://java.sun .com/javase/6/docs/technotes/guides/javaws/developersguide/syntax.html。
I think that you may have to request for permission in your JNLP file. Try adding
See http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguide/syntax.html.
天哪!!
我发现问题是什么了..
JNLP 文件由从现有程序复制的 servlet 生成,提供 port-nr 参数。但端口号没有更正..
提供的端口是(现有)安全套接字。我的应用程序使用了非安全套接字!
多么可怕的错误
oH mY!!
I found out what the problem was..
The JNLP file which was generated by a servlet which was copied from an existing program, supplied port-nr arameters. But the port-numbers weren't corrected..
The supplied port was an (Existing) Secure Socket.. my app used a Non-Secure Socket !!
What an awfull mistake