Biomart Team,
We are attempted to use the Java API from Biomart 0.8 candidate 6 by
writing a very simple Java client. We used the MartConfigurator tool to
create a registry XML file and to start the server on port 9000. We
successfully executed a query through the webapp GUI and then grabbed
the java code snippet from the query results page. The java code is
shown below:
public class QueryTest {
public static void main(String[] args) throws Exception {
String xmlPath = "registry/snp.xml";
//String keyPath = "registry/.snp";
String keyPath = null;
MartRegistryFactory factory = new
XmlMartRegistryFactory(xmlPath, keyPath);
Portal portal = new Portal(factory, null);
Query query = new Query(portal);
query.setProcessor("TSV");
query.setClient("biomartclient");
query.setLimit(10);
query.setHeader(true);
Query.Dataset ds = query.addDataset("hsapiens_snp",
"hsapiens_snp_config");
ds.addFilter("chr_name", "1");
ds.addAttribute("refsnp_id");
// Print to System.out, but you can pass in any
java.io.OutputStream
query.getResults(System.out);
System.exit(0);
}
}
When we execute this java application (with all the dist/lib JAR files
on the classpath), we can a NullPointerException as shown from the
STDOUT trace below:
2012-06-06 10:25:00,739 INFO [main:Log.java:164]: Loading resources
from org/biomart/configurator/resources/messages
2012-06-06 10:25:00,750 INFO [main:Log.java:164]: Done loading
resources
2012-06-06 10:25:01,249 INFO [main:Log.java:164]: Loading resources
from org/biomart/configurator/resources/messages
2012-06-06 10:25:01,250 INFO [main:Log.java:164]: Done loading
resources
2012-06-06 10:25:01,643 INFO [main:Log.java:164]: Incoming XML query:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Query>
<Query client="biomartclient" processor="TSV" limit="10"
header="1"><Dataset name="hsapiens_snp"
config="hsapiens_snp_config"><Filter name="chr_name" value="1"
/><Attribute name="refsnp_id" /></Dataset></Query>
2012-06-06 10:25:01,660 ERROR [main:Log.java:220]: Error during querying
org.biomart.common.exceptions.ValidationException
at
org.biomart.queryEngine.QueryController.<init>(QueryController.java:113)
at
org.biomart.queryEngine.QueryController.<init>(QueryController.java:118)
at org.biomart.api.Portal.executeQuery(Portal.java:218)
at org.biomart.api.Query.getResults(Query.java:108)
at QueryTest.main(QueryTest.java:31)
Caused by: org.biomart.common.exceptions.ValidationException
at
org.biomart.queryEngine.QueryController.initializeProcessor(QueryControl
ler.java:256)
at
org.biomart.queryEngine.QueryController.<init>(QueryController.java:86)
... 4 more
Caused by: java.lang.NullPointerException
at
org.biomart.queryEngine.QueryController.initializeProcessor(QueryControl
ler.java:229)
... 5 more
Exception in thread "main" org.biomart.api.BioMartApiException
at org.biomart.api.Portal.executeQuery(Portal.java:222)
at org.biomart.api.Query.getResults(Query.java:108)
at QueryTest.main(QueryTest.java:31)
I stepped through the Biomart code and traced the cause of the
NullPointerException we were seeing. It ends up being a HashMap named
"lookup" in the ProcessorRegistry class not being initialized properly.
It's completely empty and returns a null when
ProcessorRegistry.get("TSV") is called. There's a static method named
ProcessorRegistry.install() that does initialize the "lookup" hashmap
properly so that the "TSV" key is present and a proper value is returned
rather than null.
If I add ProcessRegistry.install(); to the start of my Java main method,
the query runs perfectly. Is there something wrong with our
installation/approach?
Thank you,
-Patrick Duffy
_______________________________________________
Users mailing list
[email protected]
https://lists.biomart.org/mailman/listinfo/users