I'm trying to access the uniprot website to retrieve a list of protein sequences with their profiles as an XML file. The file size is huge. I'm using the eclipse that come with JBPM full package. Also, I'm using ubuntu under virtual box. Now when I run my code I'm getting this stacktrace:
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
can any one help how to resolve this error OR what cause's it?
Here is the code that generates the error:
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;
}
I finally resolved the problem which seems to be happened because of the fast read with slow connection. once I've added a System.out.println(new String(buffer))
it works fine.
The println
statement slow down the read operation and make it compatible with the connection speed.
I wish this be helpful to anyone face the same problem.