JGCRI / gcam-core

GCAM -- The Global Change Analysis Model
http://jgcri.github.io/gcam-doc/
Other
263 stars 159 forks source link

SEVERE ERROR:Failed to find Java class XMLDBDriver to write to the XML database. #329

Open MincingWords opened 11 months ago

MincingWords commented 11 months ago

This is gcam 7.0 on Gentoo Linux. I've gotten gcam.exe to build with Java enabled. /opt/gcam is my GCAM installation and at this point, once it builds, I copy the whole thing to a directory under my regular-user home directory ~/aug_gcam so that I can cd to exe underneath that directory so I can run GCAM from there.

The environment variables I set for both building and running look like this:

export GCAM=/opt/gcam
export CXX=g++
export BOOST_INCLUDE=/usr/include/boost/
export BOOST_LIB=/usr/lib64
export JARS_LIB='/opt/openjdk-bin-17.0.6_p10/lib/*:/opt/gcam/exe/*'
export JAVA_INCLUDE=/etc/java-config-2/current-system-vm/include
export JAVA_LIB=/etc/java-config-2/current-system-vm/lib/server
export EIGEN_INCLUDE=/usr/include/eigen3
export TBB_INCLUDE=/usr/include/tbb
export TBB_LIB=/usr/lib64/

Now, given the above, no matter what I do with the CLASSPATH variable, this is what happens:

~/aug_gcam/exe $ ./gcam.exe -C configuration_ref.xml 
.
.
.
Configuration file:  configuration_ref.xml
Parsing input files...
SEVERE ERROR:Failed to find Java class XMLDBDriver to write to the XML database.

What's driving me nuts is that XMLDBDriver.jar is sitting right there in .../exe. To be sure, I can do this:

~/aug_gcam/exe $ jar tvf XMLDBDriver.jar 
     0 Tue Jun 01 16:51:44 EDT 2021 META-INF/
    66 Tue Jun 01 16:51:44 EDT 2021 META-INF/MANIFEST.MF
  2544 Tue Jun 01 16:51:44 EDT 2021 FilterOutput.class
  1962 Tue Jun 01 16:51:44 EDT 2021 RunQueries.class
   575 Tue Jun 01 16:51:44 EDT 2021 WildcardExpandingClassLoader$1.class
  3112 Tue Jun 01 16:51:44 EDT 2021 WildcardExpandingClassLoader.class
  5263 Tue Jun 01 16:51:44 EDT 2021 WriteLocalBaseXDB.class
  6032 Tue Jun 01 16:51:44 EDT 2021 XMLDBDriver.class

and I can do this:

export CLASSPATH=/home/<me>/aug_gcam/exe/XMLDBDriver.jar

But still the same thing happens. I feel like nothing is paying attention to CLASSPATH at all because it'll say the exact same thing if I do this:

export CLASSPATH=""

What gives??

pralitp commented 11 months ago

Sorry, the confusion is from bad error messaging on our part. The error should read something like "Failed to find Java class XMLDBDriver and/or required third party libraries to write to the XML database."

In particular the JARS_LIB was meant to find the third party Java .jar libraries that are required for writing to XML DB (as well as some more advanced features) such as the BaseX.jar.

The documentation is likely not clear enough here but you will want to check section 2.3.5 and the note about the jars in 4.1.

MincingWords commented 11 months ago

See, there's a problem there because the Linux distribution with source has no .../libs/jars. The files that are in .../libs/jars in the pre-built Windows distribution (which I've gotten to work) are

BaseX-9.5.2.jar
commons-discovery-0.5.jar
jcommon-1.0.0-rc1.jar
jfreechart-1.0.0-pre2.jar
joost-0.9.1.jar
jopt-simple-4.9.jar
poi-3.0-alpha1.jar
poi-contrib-3.0-alpha1.jar
poi-scratchpad-3.0-alpha1.jar

Now, by comparison, in the Linux distribution, either by having been there from the beginning or because I copied them there from other builds, I have these jar files in .../exe:

BaseX106.jar
BaseX950.jar
commons-discovery-0.5.jar
CSVToXML.jar
jcommon-1.0.0-rc1.jar
jfreechart-1.0.0-pre2.jar
joost-0.9.1.jar
jopt-simple-4.9.jar
ModelInterface.jar
poi-3.0-alpha1.jar
poi-contrib-3.0-alpha1.jar
poi-scratchpad-3.0-alpha1.jar
XMLDBDriver.jar

So if you're saying that the error I'm getting is because of JARS_LIB not picking up all it needs, well, JARS_LIB was already pointing at a carbon copy of .../exe. I even added the .../libs/jars from my working Windows distribution and it didn't make any difference:

 ~/aug_gcam/exe $ echo $JARS_LIB
/opt/openjdk-bin-17.0.6_p10/lib/*:/opt/gcam/exe/*:/home/<me>/my_gcam/gcam_7.0_internal_distribution/libs/jars/*

My run log file, for what it's worth, does contain this:

Internal exceptions (1 events):
Event: 0.015 Thread 0x00007f45355d4f00 Exception <a 'java/lang/NoClassDefFoundError'{0x00000000ff03dc58}: joptsimple/OptionException> (0x00000000ff03dc58)
thrown [src/hotspot/share/classfile/systemDictionary.cpp, line 245]

But without more fulsome error or log messages I'm running out of ideas.