null pointer exception when using ElementalanalyserPlugin

User fc702a6c20

30-04-2008 10:30:29

Hi,





I am trying to use the ElementalanalyserPlugin in my Java program so that I can get the exact mass and formula from a molecule, but I keep getting a null pointer exception when initialising the plugin. I also tried using the ElementalAnalyser class with the same problem.





the exception is as follows





java.lang.NullPointerException: in is nullat java.util.zip.ZipInputStream.<init>(ZipInputStream.java:55)


at chemaxon.struc.PeriodicSystem.a(Unknown Source)


at chemaxon.struc.PeriodicSystem.<clinit>(Unknown Source)


at chemaxon.calculations.ElementalAnalyser.<clinit>(Unknown Source)


at chemaxon.marvin.calculations.ElementalAnalyserPlugin.<init>(Unknown Source)





java.lang.ExceptionInInitializerError


at chemaxon.marvin.calculations.ElementalAnalyserPlugin.<init>(Unknown Source)





Caused by: java.lang.NullPointerException


at chemaxon.struc.PeriodicSystem.getElementCount(Unknown Source)


at chemaxon.calculations.ElementalAnalyser.<clinit>(Unknown Source)


... 55 more





The code is taken from your API - code examples :





ElementalAnalyserPlugin plugin = new ElementalAnalyserPlugin(); - exception thrown here





// set plugin parameters


Properties params = new Properties();


params.put("precision", "3");


plugin.setParameters(params);





// set target molecule





String molasString = metSummaryBean.getMol();


Molecule mol = MolImporter.importMol(molasString);


plugin.setMolecule(mol);





// run the calculation


plugin.run();





// get results


double exactMass = plugin.getExactMass();


String formula = plugin.getFormula();


// do something with the results ...


metSummaryBean.setMolecularWeight(exactMass);


metSummaryBean.setFormula(formula);





also tried :





ElementalAnalyser elemanal = new ElementalAnalyser(); - exception thrown here


Molecule mol = MolImporter.importMol(molasString);


elemanal.setMolecule(mol);


double exactMass = elemanal.exactMass();


metSummaryBean.setMolecularWeight(exactMass);


String formula = elemanal.formula();


metSummaryBean.setFormula(formula);





my question is - am I missing some important properties file, and if so where should this or these files be placed? I thought that perhaps it needed the elements.zip file and have copied the chemaxon folder into the base directory where my application is run from - in this case a WAR but this did not help.





Any suggestions would be greatly appreciated





Regards,


smb

User fc702a6c20

30-04-2008 11:45:28

Hi,





Sorry I forgot to mention that I also tried using the mol.getFormat() and mol.getExactMass() methods which threw the same exception





Regards,


smb

ChemAxon d76e6e95eb

05-05-2008 14:31:21

It seems, that the PeriodicSystem class (a static) cannot load the periodic system data from its external file.





If you are using the MarvinBeans.jar, it must contain two files called elements.zip and isotopes.zip. Do you have elements.zip file in that jar?





(The PeriodicSystem is a static class loading before other instance classes)

User fc702a6c20

06-05-2008 09:38:14

Thank you,





you have helped me to resolve the issue





Kind Regards,





smb