weird runtime error

User 870ab5b546

01-08-2008 21:02:12

I am getting a runtime error:





Code:
2008-08-01 16:56:16 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception


java.lang.NoSuchMethodError: chemaxon.struc.Molecule.contains(Lchemaxon/struc/CNode;)Z


        at com.prenhall.epoch.chem.MolFunctions.getSubstituent(MolFunctions.java:1040)






The offending method is:





Code:
    private static String getSubstituent(Molecule cpd, MolAtom atom,


            int ligIndex) {


        // get indices of mapped atom and ligand


        int atomIndex = cpd.indexOf(atom);


        int ligAtomIndex = cpd.indexOf(atom.getLigand(ligIndex));


        // make clone to modify, fragment


        Molecule clonedCpd = (Molecule) cpd.clone();


        // add attachment point to ligand, remove bond from ligand to mapped atom


        MolAtom attachPt = new MolAtom(MolAtom.PSEUDO);


        attachPt.setAliasstr("ATTACH_PT");


        clonedCpd.add(attachPt);


        MolAtom cloneLigand = clonedCpd.getAtom(ligAtomIndex);


        MolBond ligToAttachPt = new MolBond(cloneLigand, attachPt);


        clonedCpd.add(ligToAttachPt);


        clonedCpd.removeEdge(clonedCpd.getAtom(atomIndex).getBond(ligIndex));


        // fragment clone, find the fragment with the attachment point


        Molecule[] molFragList = clonedCpd.convertToFrags();


        for (int fragNum = 0; fragNum < molFragList.length; fragNum++) {


            if (molFragList[fragNum].contains(attachPt)) {


                // return the fragment that contains the attachment point in SMILES format


                String smiles = molFragList[fragNum].toFormat("smiles");


                return smiles;


            } // if fragment contains the attachment point


        }


        return null;


    } // getSubstituent(Molecule, MolAtom, int)






What I don't understand is why, if the method is no good, the class compiles. And I also don't understand what is wrong with the code.





We have just converted over to JChem 5.0.0.

ChemAxon 7c2d26e5cf

04-08-2008 12:13:09

I am not an JSP expert but it seems that the servlet container (Tomcat) wrongly transforms the JSP into servlet.


There are two very similar methdos in Molecule API. The first one is defined in the MoleculeGraph class, the second one in the Molecule class.


MoleculeGraph.contains(CGraph)


Molecule.contains(CNode)


The wrong method is evaluated by this line:


Code:
if (molFragList[fragNum].contains(attachPt)) {



I suggest to cast the exact class to the method:


Code:
if (((Molecule)molFragList[fragNum]).contains((CNode)attachPt)) {



Probably, it helps.

User 870ab5b546

04-08-2008 13:35:24

I guess I wasn't clear. The offending method is not in the jsp code, it is in a compiled Java class.





We have now moved to JChem 5.0.7. The same error occurs.





I don't understand what good your suggestion will do. molFragList[fragNum] is already defined as a Molecule, and attachPt is defined as a MolAtom, which automatically makes it a CNode.

User 870ab5b546

04-08-2008 14:16:13

Here's some additional information:





(1) The runtime error is not related to the upgrade from JChem 3 to 5. The same error occurs at this page, which still uses JChem 3.





(2) The page that triggers the error does not call getSubstituent() directly. It calls matchConformers(), which calls matchConformersChair(), which calls getTestSubstituentIndices(), which calls getSubstituent().





(3) The runtime error does not occur when the getSubstituent() method is called from a different page. If I log into ACE and go to a question that uses the same methods, it works just fine. It goes through a few more methods before it reaches matchConformers().





Here is the Java code on the JSP page that triggers the error:





Code:
    String target = request.getParameter("target");


    String query = request.getParameter("query");


    boolean cpdsSame = false;


    boolean searchResult = false;


    boolean searchEnantResult = false;


    if (target != null && query != null) try {


        MolHandler targetMH = new MolHandler(target);


        Molecule targetMol = targetMH.getMolecule();


        MolHandler queryMH = new MolHandler(query);


        Molecule queryMol = queryMH.getMolecule();


        cpdsSame = MolFunctions.matchPreciseJChem(targetMol, queryMol);


        if (cpdsSame) {


            System.out.println("compareConformers.jsp: cpds are same, can compare conformations.");


            searchResult = MolFunctions.matchConformers(target, query);


            System.out.println("compareConformers.jsp: searchResult = " + searchResult);


            if (!searchResult) {


                searchEnantResult = MolFunctions.matchConformers(


                        MolFunctions.getEnantiomer(targetMol).toFormat("mrv"), query);


                System.out.println("compareConformers.jsp: searchEnantResult = "


                        + searchEnantResult);


            }


        } else


            System.out.println("compareConformers.jsp: cpds are different.");


    } catch (MolFormatException e) {;}






Finally, here is debugging output from compareConformers.jsp and getSubstituent():





Code:
2008-08-04 09:52:28 compareConformers.jsp: cpds are same, can compare conformations.


MolFunctions.getSubstituent: clonedCpd:


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18"


          elementType="C C C C C C H H H H H H H H H H H H"


          mrvMap="1 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0"


          x3="-1.8744999618530276 -0.4775999618530271 -0.16339996185302752 -1.205499961853027 -2.6023999618530276 -2.916599961853027 -2.075431795906827 -1.9016396414300696 0.20519808636886055 -0.4644040848540288 -0.22334336573566743 0.768336558480049 -1.0045681277992273 -1.178360282275985 -2.615595838852026 -3.2851980100749154 -2.8566565579703873 -3.8483364821861032"


          y3="-0.6539249892711645 -0.9093249892711643 -0.05562498927116444 -0.2123249892711634 0.04307501072883646 -0.8106249892711634 -1.43638231155643 0.39343726753289865 -0.5882942946291471 -1.9433203670779395 0.9802629775270515 -0.44205504494240205 0.570132333014102 -1.2596872460752264 1.0770703885356119 -0.2779556839131807 -1.8465129560693794 -0.42419493359992577"


          z3="1.4073 0.8864 -0.32209999999999994 -1.4073 -0.8864 0.32210000000000005 2.1390697293998633 1.707958844564326 1.6730550186975512 0.5417560859315061 0.0117306585285738 -0.735184578205886 -2.1390697293998633 -1.707958844564326 -0.5417560859315061 -1.6730550186975512 -0.011730658528573579 0.7351845782058862"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="1" />


        <bond atomRefs2="a1 a6" order="1" />


        <bond atomRefs2="a2 a3" order="1" />


        <bond atomRefs2="a3 a4" order="1" />


        <bond atomRefs2="a4 a5" order="1" />


        <bond atomRefs2="a5 a6" order="1" />


        <bond atomRefs2="a1 a7" order="1" />


        <bond atomRefs2="a1 a8" order="1" />


        <bond atomRefs2="a2 a9" order="1" />


        <bond atomRefs2="a2 a10" order="1" />


        <bond atomRefs2="a3 a11" order="1" />


        <bond atomRefs2="a3 a12" order="1" />


        <bond atomRefs2="a4 a13" order="1" />


        <bond atomRefs2="a4 a14" order="1" />


        <bond atomRefs2="a5 a15" order="1" />


        <bond atomRefs2="a5 a16" order="1" />


        <bond atomRefs2="a6 a17" order="1" />


        <bond atomRefs2="a6 a18" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>





MolFunctions.getSubstituent: manipulated clonedCpd:


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19"


          elementType="C C C C C C H H H H H H H H H H H H C"


          mrvMap="1 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 0"


          mrvPseudo="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ATTACH_PT"


          x3="-1.8744999618530276 -0.4775999618530271 -0.16339996185302752 -1.205499961853027 -2.6023999618530276 -2.916599961853027 -2.075431795906827 -1.9016396414300696 0.20519808636886055 -0.4644040848540288 -0.22334336573566743 0.768336558480049 -1.0045681277992273 -1.178360282275985 -2.615595838852026 -3.2851980100749154 -2.8566565579703873 -3.8483364821861032 0.0"


          y3="-0.6539249892711645 -0.9093249892711643 -0.05562498927116444 -0.2123249892711634 0.04307501072883646 -0.8106249892711634 -1.43638231155643 0.39343726753289865 -0.5882942946291471 -1.9433203670779395 0.9802629775270515 -0.44205504494240205 0.570132333014102 -1.2596872460752264 1.0770703885356119 -0.2779556839131807 -1.8465129560693794 -0.42419493359992577 0.0"


          z3="1.4073 0.8864 -0.32209999999999994 -1.4073 -0.8864 0.32210000000000005 2.1390697293998633 1.707958844564326 1.6730550186975512 0.5417560859315061 0.0117306585285738 -0.735184578205886 -2.1390697293998633 -1.707958844564326 -0.5417560859315061 -1.6730550186975512 -0.011730658528573579 0.7351845782058862 0.0"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="1" />


        <bond atomRefs2="a1 a6" order="1" />


        <bond atomRefs2="a2 a3" order="1" />


        <bond atomRefs2="a3 a4" order="1" />


        <bond atomRefs2="a4 a5" order="1" />


        <bond atomRefs2="a5 a6" order="1" />


        <bond atomRefs2="a1 a8" order="1" />


        <bond atomRefs2="a2 a9" order="1" />


        <bond atomRefs2="a2 a10" order="1" />


        <bond atomRefs2="a3 a11" order="1" />


        <bond atomRefs2="a3 a12" order="1" />


        <bond atomRefs2="a4 a13" order="1" />


        <bond atomRefs2="a4 a14" order="1" />


        <bond atomRefs2="a5 a15" order="1" />


        <bond atomRefs2="a5 a16" order="1" />


        <bond atomRefs2="a6 a17" order="1" />


        <bond atomRefs2="a6 a18" order="1" />


        <bond atomRefs2="a7 a19" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>





MolFunctions.getSubstituent: molFragList[1]:


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17"


          elementType="C C C C C C H H H H H H H H H H H"


          mrvMap="1 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 0"


          x3="-1.8744999618530276 -0.4775999618530271 -0.16339996185302752 -1.205499961853027 -2.6023999618530276 -2.916599961853027 -1.9016396414300696 0.20519808636886055 -0.4644040848540288 -0.22334336573566743 0.768336558480049 -1.0045681277992273 -1.178360282275985 -2.615595838852026 -3.2851980100749154 -2.8566565579703873 -3.8483364821861032"


          y3="-0.6539249892711645 -0.9093249892711643 -0.05562498927116444 -0.2123249892711634 0.04307501072883646 -0.8106249892711634 0.39343726753289865 -0.5882942946291471 -1.9433203670779395 0.9802629775270515 -0.44205504494240205 0.570132333014102 -1.2596872460752264 1.0770703885356119 -0.2779556839131807 -1.8465129560693794 -0.42419493359992577"


          z3="1.4073 0.8864 -0.32209999999999994 -1.4073 -0.8864 0.32210000000000005 1.707958844564326 1.6730550186975512 0.5417560859315061 0.0117306585285738 -0.735184578205886 -2.1390697293998633 -1.707958844564326 -0.5417560859315061 -1.6730550186975512 -0.011730658528573579 0.7351845782058862"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="1" />


        <bond atomRefs2="a1 a6" order="1" />


        <bond atomRefs2="a1 a7" order="1" />


        <bond atomRefs2="a2 a3" order="1" />


        <bond atomRefs2="a2 a8" order="1" />


        <bond atomRefs2="a2 a9" order="1" />


        <bond atomRefs2="a3 a4" order="1" />


        <bond atomRefs2="a3 a10" order="1" />


        <bond atomRefs2="a3 a11" order="1" />


        <bond atomRefs2="a4 a5" order="1" />


        <bond atomRefs2="a4 a12" order="1" />


        <bond atomRefs2="a4 a13" order="1" />


        <bond atomRefs2="a5 a6" order="1" />


        <bond atomRefs2="a5 a14" order="1" />


        <bond atomRefs2="a5 a15" order="1" />


        <bond atomRefs2="a6 a16" order="1" />


        <bond atomRefs2="a6 a17" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>

ChemAxon 7c2d26e5cf

04-08-2008 14:34:58

Probably, I have misunderstood the problem. But I am sure that the error is not in Marvin.


The chemaxon.struc.Molecule.contains(CNode) method exists in the 5.0.7 version of jchem.jar.


It can be a configuration problem in your Tomcat.


My assume was that it may be a compilation bug in Tomcat. But it was only a tipp.


I am not a Tomcat expert but I know that all JSP sources are wrapped into servlet classes that Tomcat generates it automatically when evaluates JSP code.


After take a look at google hints in this subject, the conclusion is that this kind of error message is very often if Tomcat cannot compile JSP or not find some resource that required for running the code.


Please check you Tomcat settings, there may be more jchem.jar or MarvinBeans.jar that can cause this conflict.

User 870ab5b546

04-08-2008 14:44:58

OK, I'll put our programmers on it.

User 870ab5b546

07-08-2008 14:08:45

You were right about the source of the error. Our Java code was compiled with JChem 5.0, but Tomcat was using JChem 3.2.12 to compile the JSP pages. Evidently, that engendered a conflict. We changed Tomcat to point to JChem 5.0, and now all works well.

ChemAxon 7c2d26e5cf

07-08-2008 14:20:42

It is a good news.