MolSearch - NoSuchMethodError

User 9cadc86c7c

28-01-2014 11:49:40

Hello, my first thread :)


 


I'm trying to use the MolSearch class - http://www.chemaxon.com/jchem/doc/dev/java/api/chemaxon/sss/search/MolSearch.html


Unfortunately whenever I actually call any of the "find" methods, I get this stack trace:


java.lang.NoSuchMethodError: chemaxon.common.util.ArrayTools.extendArray([II)[I
    at chemaxon.sss.search.Search.addMatch(Search.java:434)
    at chemaxon.sss.search.AromatizedSearch.addMatch(AromatizedSearch.java:1441)
    at chemaxon.sss.search.MolSearch.setPreMatchOnSearcher(MolSearch.java:1181)
    at chemaxon.sss.search.MolSearch.initSearch(MolSearch.java:1092)
    at chemaxon.sss.search.MolSearch.findAllHits(MolSearch.java:731)
    at test.HyperstructuresTest.isSubstructure(HyperstructuresTest.java:693)
    at test.HyperstructuresTest.testNonRingEnforcementMapping(HyperstructuresTest.java:556)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)




 


I'm using JChem 6.1.7 with Java 1.6 on Ubuntu 13.10.  I'm unsure what's the cause of this, though I should point out that I'm not using the entire JChem installation - I've copied the minimum number of .jar files to my plugin directory as I'm doing work on this with KNIME.


 


Here's the method I wrote to call this, which is yielding this error:





private boolean isSubstructure(String querySMILES, String targetSMARTS) {
         Molecule query = null, target = null;
        
         try {
             MolSearch s = new MolSearch();
 
             
             try {
                 MolImporter mim1 = new MolImporter( new StringBufferInputStream( querySMILES ), "smiles" );
                 MolImporter mim2 = new MolImporter( new StringBufferInputStream( targetSMARTS ), "smarts" );
                 query = mim1.read();
                 target = mim2.read();
             } catch (IOException e2) {
                 // TODO Auto-generated catch block
                 e2.printStackTrace();
             }
             
             s.setQuery(query);
             s.setTarget(target);
 
             // search all matching substructures and print hits
             int[] hitAtoms = null;
 
             //s.findAllHits();
             s.findAll();
             hitAtoms = s.findFirst();
             if (hitAtoms == null)
                 System.out.println("No hits");
             else {
                 System.out.println( "There are " + hitAtoms.length + " matched atoms" );
             }// end else
         } catch (SearchException e) {
             e.printStackTrace();
             System.exit(1);
         }// end catch
         
         return false;
     }// end method





Thanks in advance,


Ed.

ChemAxon a9ded07333

28-01-2014 14:05:04

Hi Ed,


It seems that somehow you are using incompatible jar files (jars from different versions). E.g. you mention you are using JChem 6.1.7, but MolSearch.setPreMatchOnSearcher has been deleted in 6.0 already, so it shouldn't appear in your stacktrace.


You may check your jars' creation time or doublecheck which jars your program uses.


Best regards,


Tamás



MolSearch.setPreMatchOnSearcher

User 9cadc86c7c

04-02-2014 14:23:22

 






"You may check your jars' creation time or doublecheck which jars your program uses."



 


Thanks cheese/Tamás, looks like that was the issue.  I was using Eclipse and for some reason you have to use "PDE Tools -> Update Classpath" on the project in question whenever you use new jar files.  I evidently didn't do that which was why this occured,