GenerateDatasetsXml.sh error

161 views
Skip to first unread message

Emanuele Lombardi

unread,
Feb 24, 2016, 7:27:00 AM2/24/16
to ERDDAP

Dear ERDDAPpers,

I'm trying to generate the XML of my netcdf file and I get the following error. I'm not good at all with java so I don't know what to do.
I tried setting CLASSPATH but it didn't work. I also enlarged the RAM given to java, but nothing changed.

The error log complains about the file  /srv/tomcat/content/erddap/setup.xml
but it is OK and ERDDAP is succesfully running with it. I attach it, anyway.
Can you help me, please?

many thanks for any help,
regards,
Emanuele


sh -v ./GenerateDatasetsXml.sh
#!/bin/bash
# This is the Unix/Linux shell script to run GenerateDatasetsXml.
# See http://coastwatch.pfeg.noaa.gov/erddap/download/setupDatasetsXml.html#Tools

cp1="./classes:../../../lib/servlet-api.jar:lib/activation.jar:lib/axis.jar"
cp2=":lib/cassandra-driver-core.jar:lib/netty-all.jar:lib/guava.jar:lib/metrics-core.jar:lib/lz4.jar:lib/snappy-java.jar"
cp3=":lib/commons-compress.jar:lib/commons-discovery.jar:lib/itext-1.3.1.jar"
cp4=":lib/jaxrpc.jar:lib/joda-time.jar:lib/joid.jar:lib/lucene-core.jar"
cp5=":lib/mail.jar:lib/netcdfAll-latest.jar:lib/postgresql.jdbc.jar"
cp6=":lib/saaj.jar:lib/tsik.jar:lib/wsdl4j.jar"
cp7=":lib/aws-java-sdk.jar:lib/commons-codec.jar:lib/commons-logging.jar"
cp8=":lib/fluent-hc.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/httpcore.jar"
cp9=":lib/httpmime.jar:lib/jna.jar:lib/jna-platform.jar:lib/jackson-annotations.jar"
cp10=":lib/jackson-core.jar:lib/jackson-databind.jar"
cp0="$cp1$cp2$cp3$cp4$cp5$cp6$cp7$cp8$cp9$cp10"

java -cp $cp0 -Xms4000M -Xmx4000M gov.noaa.pfel.erddap.GenerateDatasetsXml $1 $2 $3 $4 $5 $6 $7 $8 $9

////**** ERD Low Level Startup
localTime=2016-02-24T13:14:09
Java 1.8.0_60 (64 bit, Oracle Corporation) on Linux (3.12.48-52.27-default).
Memory: currently using      80 MB (high water mark =      80 MB) (Xmx ~= 3833 MB)
ERROR during ERD Low Level Startup:
ERROR while reading /srv/tomcat/content/erddap/setup.xml
java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
 at gov.noaa.pfel.erddap.util.EDStatic.<clinit>(EDStatic.java:1247)
 at gov.noaa.pfel.erddap.GenerateDatasetsXml.<clinit>(GenerateDatasetsXml.java:42)
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet
 ... 14 more


Exception in thread "main" java.lang.ExceptionInInitializerError
        at gov.noaa.pfel.erddap.GenerateDatasetsXml.<clinit>(GenerateDatasetsXml.java:42)
Caused by: java.lang.RuntimeException: ERROR during ERD Low Level Startup:
ERROR while reading /srv/tomcat/content/erddap/setup.xml
java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
 at gov.noaa.pfel.erddap.util.EDStatic.<clinit>(EDStatic.java:1247)
 at gov.noaa.pfel.erddap.GenerateDatasetsXml.<clinit>(GenerateDatasetsXml.java:42)
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet
 ... 14 more


        at gov.noaa.pfel.erddap.util.EDStatic.<clinit>(EDStatic.java:2483)
        ... 1 more
setup.xml

Bob Simons

unread,
Feb 24, 2016, 11:15:38 AM2/24/16
to ERDDAP
Thanks for providing the full error message.

The problem is that Java is not finding a .class file called javax/servlet/http/HttpServlet.class.
Normally, ERDDAP is installed in Tomcat and Tomcat provides that class.
The cp1 line in the GenerateDatasetsXml.sh script has a reference to 
./classes:../../../lib/servlet-api.jar
which is where the servlet-api.jar normally is located when ERDDAP is installed in Tomcat.
The HttpServlet.class file is in that .jar file (.jars are a special type of .zip file).

Perhaps you just installed ERDDAP without installing Tomcat.
Perhaps you are using an application server other than Tomcat.

To fix this problem, make sure ERDDAP is fully installed (using Tomcat or some other application server) and that you have successfully run it.
If the problem still exists, then change the reference on the cp1 line so that it points to the actual location of the servlet-api.jar file.

I hope that helps. If not, please let me know what you tried and what the error message was (as you have done here).




Emanuele Lombardi

unread,
Feb 25, 2016, 3:15:49 AM2/25/16
to ERDDAP
Thank you Bob.
Your answer let me solve the problem.

The problem was that webapps and content are soft links under tomcat,
thus

cd /srv/tomcat/webapps/erddap/WEB-INF
ls ../../../lib
ls: cannot access ../../../lib/: No such file or directory

BUT if I do
cd ../../../lib
ls
annotations-api.jar       jasper.jar          tomcat-i18n-ja.jar
catalina-ant.jar          jsp-api.jar         tomcat-jdbc.jar
catalina-ha.jar           sedoo.jar           tomcat-jni.jar
catalina-storeconfig.jar  servlet-api.jar     tomcat-util-scan.jar
catalina-tribes.jar       tomcat-api.jar      tomcat-util.jar
catalina.jar              tomcat-coyote.jar   tomcat-websocket.jar
ecj-4.4.2.jar             tomcat-dbcp.jar     websocket-api.jar
el-api.jar                tomcat-i18n-es.jar
jasper-el.jar             tomcat-i18n-fr.jar

Thus I replaced in GenerateDatasetXML.sh
../../../lib/servlet-api.jar   with the full path
/srv/tomcat/lib/servlet-api.jar

Thanks again,
Emanuele

Bob Simons

unread,
May 17, 2016, 12:23:55 PM5/17/16
to ERDDAP
The newly available ERDDAP v1.72 solves this problem: ERDDAP now follows symbolic (soft) links when looking for files on Linux (*nix) computers as one would expect. ERDDAP still does not follow symbolic links on Windows computers.

paloma.d...@gmail.com

unread,
Feb 7, 2019, 5:19:16 AM2/7/19
to ERDDAP
For your info - this old post saved .. maybe not my life but still, many of my hairs. 
In my case, the problem arose from the fact that the installation of tomcat made a distinction between CATALINA_BASE and CATALINA_HOME (not my idea!). 

CATALINA_HOME=/usr/share/tomcat8
CATALINA_BASE=/var/lib/tomcat8

So, GenerateDatasetsXML.sh is in 

         /var/lib/tomcat8/webapps/erddap/WEB-IN  (or $CATALINA_BASE/webapps/erddap/WEB-INF)

while the jar files are in

         /usr/share/tomcat8/lib                                   (or $CATALINA_HOME/lib)

So the relative path ../../../lib did not work. The replacement by a hard path suggested by Emmanuele did the trick. 

Cheers
Paloma
Reply all
Reply to author
Forward
0 new messages