我们刚刚从Sun更新了我们的服务器,运行Solaris 9,32位。 (安装在2005年)到新的CentOS 5,(linux)64位。
最新的Java版本是1.6.0_20(但我们不再能够访问有关旧版Java的信息)。
Java applet(OPMClient)的一部分开始抛出IOExeption:
import java.applet.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import java.util.*;
public class OPMClient extends Applet {
...
public static final int PORT = 8888;
MineCanvas minecanvas;
...
public void clientSend() {
try {
s = new Socket(this.getCodeBase().getHost(), PORT);
in = new DataInputStream(s.getInputStream());
out = new DataOutputStream(s.getOutputStream());
listener = new SolutionListener(in, minecanvas);
}
catch (IOException e) {e.printStackTrace();} //showStatus("IOException in clientSend()");}
...
}
public boolean action(Event e, Object arg) {
...
if (arg.equals("Submit")) {
if (action(null, "Update Grid")) {
minecanvas.Submit();
} else {
return true;
}
}
...
}
class MineCanvas extends Canvas {
...
public void Submit() {
if (position == -1) {
errorString = "No ore has been entered!";
mode = ERROR;
repaint();
} else {
ComputeGridValue();
parent.clientSend();
}
}
...
}
我们试图弄清楚为什么会这样,但经过几个小时的努力,没有成功。任何人都可以帮助我们解决这个问题吗?堆栈跟踪在
之下java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at OPMClient.clientSend(OPMClient.java:128)
at MineCanvas.Submit(OPMClient.java:423)
at OPMClient.action(OPMClient.java:118)
at java.awt.Component.handleEvent(Unknown Source)
at java.awt.Component.postEvent(Unknown Source)
at java.awt.Component.postEvent(Unknown Source)
at java.awt.Component.postEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at OPMClient.clientSend(OPMClient.java:138)
at MineCanvas.Submit(OPMClient.java:423)
at OPMClient.action(OPMClient.java:118)
at java.awt.Component.handleEvent(Unknown Source)
at java.awt.Component.postEvent(Unknown Source)
at java.awt.Component.postEvent(Unknown Source)
at java.awt.Component.postEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
非常感谢。 P.S。:希望这不是一个明显的问题。
真诚的,你的, 颜
答案 0 :(得分:0)
哪个特定行抛出IOException?你能不能抓住它,所以我知道吗? 行“s = new Socket(this.getCodeBase()。getHost(),PORT);”如果在创建套接字时发生I / O错误,则会抛出它,可能是因为this.getCodeBase()有一个I / O异常(可能是因为坏的url?)。如果在创建输入流时发生I / O错误,套接字关闭,套接字未连接或套接字输入已使用shutdownInput()关闭,则IOException将仅发生在输入流部分中。同样,如果在创建输出流时发生I / O错误或者套接字未连接,它只会出现在输出流部分。