ObjectInputStream 中的 EOFException 仅发生在 Webstart 上,而不是由 java(w).exe 发生?

发布于 2024-08-28 06:57:29 字数 3108 浏览 1 评论 0原文

任何熟悉启动 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

横笛休吹塞上声 2024-09-04 06:57:29

我认为您可能需要在 JNLP 文件中请求许可。尝试添加

<security>
   <all-permissions/>
</security>

请参阅 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

<security>
   <all-permissions/>
</security>

See http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguide/syntax.html.

三生池水覆流年 2024-09-04 06:57:29

天哪!!

我发现问题是什么了..
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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文