gpt4 book ai didi

java - 需要修复此: java. io.IOException:过早的EOF

转载 作者:行者123 更新时间:2023-12-01 06:20:34 24 4
gpt4 key购买 nike

我正在尝试访问 uniprot 网站以检索蛋白质序列列表及其配置文件(XML 文件)。文件大小很大。我正在使用 JBPM 完整包附带的 eclipse。另外,我在虚拟盒子下使用ubuntu。现在,当我运行代码时,我得到了这个堆栈跟踪:

 java.io.IOException: Premature EOF
at sun.net.www.http.ChunkedInputStream.fastRead(ChunkedInputStream.java:234)
at sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:662)
at java.io.FilterInputStream.read(FilterInputStream.java:116)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2512)
at edu.uga.uniprot.amna.QueryExecuter.ExecuteQuery(QueryExecuter.java:40)
at edu.uga.uniprot.amna.Uniprot.getProteenStringByDFamily(Uniprot.java:40)
at edu.uga.uniprot.amna.Uniprot.getProteensByDFamily(Uniprot.java:55)
at org.drools.bpmn2.Process_org_drools_bpmn2_Hello_World_0.action4(Process_org_drools_bpmn2_Hello_World_0.java:60)
at org.drools.bpmn2.Process_org_drools_bpmn2_Hello_World_0Action4Invoker.execute(Process_org_drools_bpmn2_Hello_World_0Action4Invoker.java:14)
at org.jbpm.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:47)
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:150)
at org.jbpm.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)
at org.jbpm.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35)
at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:188)
at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:302)
at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:154)
at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:124)
at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1095)
at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:306)
at com.sample.ProcessTest.main(ProcessTest.java:49)
java.lang.RuntimeException: unable to execute Action
at org.jbpm.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:49)
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:150)
at org.jbpm.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)
at org.jbpm.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35)
at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:188)
at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:302)
at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:154)
at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:124)
at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1095)
at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:306)
at com.sample.ProcessTest.main(ProcessTest.java:49)
Caused by: java.lang.NullPointerException
at java.io.StringReader.<init>(StringReader.java:33)
at edu.uga.uniprot.amna.Uniprot.loadProteenFromString(Uniprot.java:117)
at edu.uga.uniprot.amna.Uniprot.getProteensByDFamily(Uniprot.java:58)
at org.drools.bpmn2.Process_org_drools_bpmn2_Hello_World_0.action4(Process_org_drools_bpmn2_Hello_World_0.java:60)
at org.drools.bpmn2.Process_org_drools_bpmn2_Hello_World_0Action4Invoker.execute(Process_org_drools_bpmn2_Hello_World_0Action4Invoker.java:14)
at org.jbpm.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:47)
... 14 more

谁能帮忙解决这个错误或者是什么原因造成的?

这是生成错误的代码:

public static String ExecuteQuery(String queryURL, boolean writeFile) { 

URL url;

try {

System.out.println("Strat getting Data");

String output = "";

int read;

RandomAccessFile file = null;

url = new URL(queryURL);

HttpURLConnection connection =

(HttpURLConnection) url.openConnection();



connection.setRequestProperty("Content-Type", "application/xml");

connection.connect();



//read the result from the server

if(writeFile == true) {

file = new RandomAccessFile(fileName, "rw");

}

InputStream stream = connection.getInputStream();

byte[] buffer = new byte[1024];

BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));



while((read = stream.read(buffer, 0, 1024)) != -1) {

//System.out.println(new String(buffer));

output = output + new String(buffer).substring(0, read);

if(writeFile == true) {

file.write(buffer, 0, read);

}

buffer = new byte[1024];

}

System.out.println(output);

return output;

} catch (MalformedURLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return null;

}

最佳答案

此错误是由于您将 null 值传递到 Uniprot.java 第 117 行的 new StringReader() 引起的。

您可以通过堆栈跟踪看到这一点:

Caused by: java.lang.NullPointerException
at java.io.StringReader.<init>(StringReader.java:33)
at edu.uga.uniprot.amna.Uniprot.loadProteenFromString(Uniprot.java:117)
at edu.uga.uniprot.amna.Uniprot.getProteensByDFamily(Uniprot.java:58)

StringReader 的构造函数如下:

public StringReader(String   s) {
this.str = s;
this.length = s.length(); // line 33
}

查看更多StringReader .

关于java - 需要修复此: java. io.IOException:过早的EOF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8286349/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com