How to calling API of D2S in tomcat?

User 22c88daf92

15-06-2013 05:21:36

hello!


We can use D2C API to get the structure of word doc file in java code,  But when we dispose these java programs in catalog of tomcat's webapps, the D2C can't word, and show following error message:


chemaxon.formats.MolFormatException: Cannot create record reader for Text/Office Document (supported by Document to Structure)
 chemaxon.formats.MFileFormat.createRecordReader(MFileFormat.java:960)
 chemaxon.formats.MFileFormatUtil.createRecordReader(MFileFormatUtil.java:938)
 chemaxon.formats.MFileFormatUtil.createRecordReader(MFileFormatUtil.java:897)
 chemaxon.marvin.io.MRecordImporter.<init>(MRecordImporter.java:274)
 chemaxon.formats.MolImporter.init(MolImporter.java:595)
 chemaxon.formats.MolImporter.<init>(MolImporter.java:266)
 com.scienview.util.ChemaxonDocu2Stru.Docu2Stru(ChemaxonDocu2Stru.java:20)
 com.scienview.util.ChemaxonDocu2Stru.main(ChemaxonDocu2Stru.java:87)
 org.apache.jsp.index_jsp._jspService(index_jsp.java:86)
 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:96)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:96)



root cause


java.lang.NoSuchMethodError: chemaxon.naming.n2s.Options.<init>(Ljava/lang/Boolean;ZZZZIZZZ)V
 chemaxon.naming.document.D2S$Options.<init>(D2S.java:58)
 chemaxon.marvin.io.formats.d2s.D2SRecordReader.parseOptions(D2SRecordReader.java:179)
 chemaxon.marvin.io.formats.d2s.D2SRecordReader.<init>(D2SRecordReader.java:47)
 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
 java.lang.reflect.Constructor.newInstance(Constructor.java:513)
 chemaxon.formats.MFileFormat.createRecordReader(MFileFormat.java:939)
 chemaxon.formats.MFileFormatUtil.createRecordReader(MFileFormatUtil.java:938)
 chemaxon.formats.MFileFormatUtil.createRecordReader(MFileFormatUtil.java:897)
 chemaxon.marvin.io.MRecordImporter.<init>(MRecordImporter.java:274)
 chemaxon.formats.MolImporter.init(MolImporter.java:595)
 chemaxon.formats.MolImporter.<init>(MolImporter.java:266)
 com.scienview.util.ChemaxonDocu2Stru.Docu2Stru(ChemaxonDocu2Stru.java:20)
 com.scienview.util.ChemaxonDocu2Stru.main(ChemaxonDocu2Stru.java:87)
 org.apache.jsp.index_jsp._jspService(index_jsp.java:86)
 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:96)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:96)


how to use D2C api in tomcat webapps?


java code:


  MolImporter importer = new MolImporter(document, "d2s");
        
  for (Molecule m : importer) {
    String mrv= m.toFormat("mrv").
    String name = m.getName();
    String sourceText = m.getProperty(DocumentToStructure.SOURCE_TEXT);
    //...
  }

ChemAxon e7b9408ca1

17-06-2013 15:33:23

Your code looks fine. The error suggests that there is a mix of different versions of Marvin. Could you double check your installation and your classpath?