ECFPParameters problem: org.xml.sax.SAXException

User 22337819af

16-07-2014 18:42:21

Hi


I'm trying to use fingerprints (ECFP) but when I try to create a configuration file I get an exception.  (Mac OS X).  Here is the code:


ECFPParameters ecfpParameters = new ECFPParameters(new File("/Applications/ChemAxon/JChem/examples/config/ecfp.xml"))


Here is the exception:


Warning: Caught exception attempting to use SAX to load a SAX XMLReader 


Warning: Exception was: org.xml.sax.SAXException: Can't create default XMLReader; is system property org.xml.sax.driver set?


Warning: I will print the stack trace then carry on using the default SAX parser


org.xml.sax.SAXException: Can't create default XMLReader; is system property org.xml.sax.driver set?


at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Unknown Source)


at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:83)


at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894)


at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715)


at org.dom4j.io.SAXReader.read(SAXReader.java:435)


at org.dom4j.io.SAXReader.read(SAXReader.java:264)


at chemaxon.descriptors.MDParameters.readFromXmlFile(MDParameters.java:885)


at chemaxon.descriptors.ECFPParameters.<init>(ECFPParameters.java:137)


at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)


at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)


at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)


at java.lang.reflect.Constructor.newInstance(Constructor.java:526)


at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)


at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)


at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)


at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)


at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)


at generateFingerprints.run(generateFingerprints.groovy:27)


at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:258)


at groovy.lang.GroovyShell.run(GroovyShell.java:502)


at groovy.lang.GroovyShell.run(GroovyShell.java:491)


at groovy.ui.GroovyMain.processOnce(GroovyMain.java:650)


at groovy.ui.GroovyMain.run(GroovyMain.java:381)


at groovy.ui.GroovyMain.process(GroovyMain.java:367)


at groovy.ui.GroovyMain.processArgs(GroovyMain.java:126)


at groovy.ui.GroovyMain.main(GroovyMain.java:106)


at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)


at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)


at java.lang.reflect.Method.invoke(Method.java:606)


at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)


at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)


at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)


at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)


at java.lang.reflect.Method.invoke(Method.java:606)


at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)


Caught: chemaxon.descriptors.MDParametersException: Bad XML config file.


chemaxon.descriptors.MDParametersException: Bad XML config file.


at chemaxon.descriptors.MDParameters.readFromXmlFile(MDParameters.java:896)


at chemaxon.descriptors.ECFPParameters.<init>(ECFPParameters.java:137)


at generateFingerprints.run(generateFingerprints.groovy:27)


at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)


Caused by: org.dom4j.DocumentException: Can't create default XMLReader; is system property org.xml.sax.driver set? Nested exception: Can't create default XMLReader; is system property org.xml.sax.driver set?


at org.dom4j.io.SAXReader.read(SAXReader.java:484)


at org.dom4j.io.SAXReader.read(SAXReader.java:264)


at chemaxon.descriptors.MDParameters.readFromXmlFile(MDParameters.java:885)


... 3 more

ChemAxon d4fff15f08

17-07-2014 10:43:00

Hi David,


 


I moved your record to the appropriate topic. My colleagues will answer you in short time.


 


Best regards,


Norbert 

ChemAxon 8b644e6bf4

18-07-2014 15:34:27

Dear David,


 


Could you post the JChem version, Java version and OS version you used? Could you try to execute ECFP creation code using bare Java?


 


Regards,


Gabor

User 22337819af

20-07-2014 17:45:13

Thank you, here is the info:


 


JChem version:  14.7.14.0  (from this file:  jchem-14.7.14.0-macos.dmg)


Java version:  1.7.0_60


OS:  Mac OS X 10.9.4


 


It does work with plain java actually.

ChemAxon 8b644e6bf4

22-07-2014 10:42:29

Dear David,


 


Thanks for the info. I suspect classpath/class loading problem with the groovy launching. Is there a "fork JVM" option in your environment?


 


Regards,


Gabor



org.dom4j.verbose=true.

User 22337819af

22-07-2014 21:30:40

Hi


Thank you - I'm not sure how to do that - I'm using IntelliJ.  A quick google didn't turn up how to do it (there was an entry on forking tests).


I had written it as a Groovy script, but then I re-wrote it as a Main class and executed it as an application and it worked.  I then modified my Groovy script to include an additional external library (apache commons math) and that worked.


I would like to pursue why this doesn't work as a Groovy script, if possible.

ChemAxon 8b644e6bf4

23-07-2014 12:36:34

Dear David,


 


Glad to hear that working around the problem was possible.


To pursue the cause of the original problem i would recommend to follow the execution (based on the stack trace) of the problematic part simultaneously in both environment (standalone java vs Groovy script).


The relevant parts from ChemAxon sources:


// Import statements
import org.dom4j.Document;
import org.dom4j.io.SAXReader;

SAXReader reader = null; // Declaring reader
reader = new SAXReader(); // Creating reder
Document doc = reader.read( file );            // MDParameters.java:885; file is the passed File reference

The dom4j classes are declared in the dom4j-1.6.1.jar file. Online sources to follow stack trace can be found at http://grepcode.com/file/repo1.maven.org/maven2/dom4j/dom4j/1.6.1/org/dom4j/io/SAXReader.java?av=f#264


At a first glance the first possible difference in the execution paths is in SAXHelper.java, in line 78: http://grepcode.com/file/repo1.maven.org/maven2/dom4j/dom4j/1.6.1/org/dom4j/io/SAXHelper.java#78


In the failing execution org.dom4j.io.SAXHelper.createXMLReaderViaJaxp() must return null; in the not failing execution this method might return a not null value. I would recommend to check this first. (I think you need to put your code in org.dom4j.io package and subclass SAXHelper or use java reflection/setAccessible to invoke it)


If there is no difference then then the exception must come from the JRE (http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/org/xml/sax/helpers/XMLReaderFactory.java#133); i think duplicating the source of this method and executing step by step or printing trace info should yield further info.


 


Regards,


Gabor

User 22337819af

23-07-2014 17:18:14

Thank you Gabor!  I'll let you know what I find.