Goobi CLI: Class not found exception

Bug #1013622 reported by Henning Gerhardt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Goobi.Production
Fix Released
Medium
Unassigned
1.7
Fix Released
Medium
Unassigned

Bug Description

Running Goobi client creates a Class-Not-Found-Exception:

/usr/bin/java -Xmx256m -jar /home/goobi/config/scripts/goobitest.jar -c closeStep -s 220009
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/cli/ParseException
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.cli.ParseException
 at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class:
org.goobi.production.cli.CommandLineInterface. Program will exit.

Looks like a problem in Java class path loading mechanism or something relevant to class path.

Related branches

Changed in goobi-production:
status: New → Confirmed
Changed in goobi-production:
importance: Undecided → Medium
Revision history for this message
Ralf Claussnitzer (ralf-claussnitzer-deactivatedaccount) wrote :

Nasty class loading issue here. :-/ It appears that the Class-Path manifest value is never used to load resources form inside the jar. See: http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html

"Note: The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file or classes accessible over internet protocols. To load classes in JAR files within a JAR file into the class path, you must write custom code to load those classes. For example, if MyJar.jar contains another JAR file called MyUtils.jar, you cannot use the Class-Path header in MyJar.jar's manifest to load classes in MyUtils.jar into the class path. "

Special class loading has to be implemented to make it work like expected. Until then one has to provide the extracted libraries near the jar.

NOTE: Eclipse "Standalone CLI" builds use a custom mechanism to run those kind of JARed applications.

Revision history for this message
Ralf Claussnitzer (ralf-claussnitzer-deactivatedaccount) wrote :

There is no standard way of loading classes out of nested JAR files. Java JAR mechanism is just not designed for this use case. Custom Class Loaders can help, but a JAR source has to provide random file access, which is only provided by file system streams and memory buffering. Given this there are three options:

1. extract nested JAR files into temporary files (what most standalone-JAR tools do)
2. read nested JAR files to memory using a BufferedStreamReader (hit on performance and memory consumption)
3. extract all includes JAR files and avoid the problem (has license issues)

Changed in goobi-production:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.