Substructure Search NullPointerException

User fe913a1448

28-11-2012 00:29:38

I am using JChem Version 5.11.3 with Java 7 and using an MSketchPane to retreive a Molecule from a sketch.


 


I have the following code executing a substructure search, where mol is a Molecule object:


 


try (Connection conn = ConnectionPool.getConnection()) {
final JChemSearch searcher = new JChemSearch();
searcher.setQueryStructure(mol);
final ConnectionHandler connHdl = new ConnectionHandler(conn, ConnectionHandler.DEFAULT_PROPERTY_TABLE);
searcher.setConnectionHandler(connHdl);
searcher.setStructureTable("structures");
final JChemSearchOptions options = new JChemSearchOptions(
SearchConstants.SUBSTRUCTURE);
searcher.setSearchOptions(options);
searcher.setResultTableMode(JChemSearch.NO_RESULT_TABLE);
searcher.setRunMode(JChemSearch.RUN_MODE_SYNCH_COMPLETE);
searcher.run();

while (searcher.isRunning()) {
;
}

final int cells = searcher.getResultCount();
 }

Whenever I execute this code, an error occurs in the searcher, and I get the following stack trace:


 java.lang.NullPointerException
at chemaxon.jchem.db.JChemSearch.printSearchInfo(JChemSearch.java:2932)
at chemaxon.jchem.db.JChemSearch.search1(JChemSearch.java:2847)
at chemaxon.jchem.db.JChemSearch.search(JChemSearch.java:2489)
at chemaxon.jchem.db.JChemSearch.setRunning(JChemSearch.java:2207)
at chemaxon.jchem.db.JChemSearch.run(JChemSearch.java:2236)
at edu.iup.chem.inventory.Test.findSubstructure(Test.java:48)


I'm not sure what is wrong, or what is causing the NullPointException here.


Any help would be much appreciated. Full source attached.

ChemAxon abe887c64e

28-11-2012 11:02:56

Hi,


Thank you for your enquiery. We will get back to you soon.



Krisztina

User fe913a1448

28-11-2012 17:04:19

I believe the issue was an expired license key, as it works now that I have installed a new one. 


 


It would be nice if an exception was thrown to indicate this, rather than an NPE. 

ChemAxon abe887c64e

29-11-2012 10:43:22

Thanks again for the report, we will investigate the origin of the misleading error message, and will give informative message in case of license problems in similar cases.


Kind regards,


Krisztina