Mantis Bugtracker

Erweiterte Problemanzeige Zu Notizen wechseln ] einfache Anzeige ] Problem-Historie ] Drucken ]
ID Kategorie Auswirkung Reproduzierbar Meldungsdatum Letzte Aktualisierung
0000019 [Cafesterol] general kleinerer Fehler immer 2008-08-10 13:35 2008-08-11 13:23
Reporter raboof Anzeigestatus öffentlich  
Bearbeitung durch xclerc
Priorität normal Lösung erledigt Rechnertyp
Status erledigt   Betriebssystem
Projektion keine   BS-Version
Aufwand keine Behoben in Version 1.0 Produktversion
  Zielversion Produkt-Build
Zusammenfassung 0000019: Running jars compiled without '-standalone'
Beschreibung When I compile my .ml with '-standalone', it works fine.

Without '-standalone', I assume I should put some jar on the classpath. I am confused, however, which one: most ocaml*.jar jars seem to contain the class, but none appear to work.

It seems http://jijixi.azito.com/cgi-bin/diary/index.rb?date=20080527 [^] had the same error, unfortunately I can't read this language :).
Schritte zur Reproduktion
Zusätzliche Information Exception in thread "main" java.lang.NoClassDefFoundError: fr/x9c/cadmium/kernel/AbstractNativeRunner
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:637)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
Caused by: java.lang.ClassNotFoundException: fr.x9c.cadmium.kernel.AbstractNativeRunner
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
        ... 12 more
Tags Keine Tags zugeordnet.
Angehängte Dateien

- Problem-Beziehungen

-  Notiz
(0000019)
xclerc (Administrator)
2008-08-10 22:42

This is not really a bug, when the "-standalone" switch of the compiler
is not used, one has to give access to "ocamlrun.jar" from the classpath.
The documentation (as shipped with the next version) will be enhanced
to underline this fact.
(0000021)
raboof (Reporter)
2008-08-11 10:44

I figured I needed to put one of the ocaml*.jar's on the classpath, however that does not seem to make the NoClassDefFoundError go away:

arnouten@bird:/tmp$ which ocamljava
/usr/local/bin/ocamljava
arnouten@bird:/tmp$ ocamljava -standalone -o hello.jar hello.ml
arnouten@bird:/tmp$ java -jar hello.jar
Hello world!
arnouten@bird:/tmp$ ocamljava -o hello.jar hello.ml
arnouten@bird:/tmp$ java -cp /usr/local/lib/ocaml/ocamlrun.jar -jar hello.jar
Exception in thread "main" java.lang.NoClassDefFoundError: fr/x9c/cadmium/kernel/AbstractNativeRunner
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:637)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
Caused by: java.lang.ClassNotFoundException: fr.x9c.cadmium.kernel.AbstractNativeRunner
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
        ... 12 more
arnouten@bird:/tmp$ jar tf /usr/local/lib/ocaml/ocamlrun.jar | grep fr/x9c/cadmium/kernel/AbstractNativeRunner
fr/x9c/cadmium/kernel/AbstractNativeRunner$1.class
fr/x9c/cadmium/kernel/AbstractNativeRunner$Application.class
fr/x9c/cadmium/kernel/AbstractNativeRunner$Closure.class
fr/x9c/cadmium/kernel/AbstractNativeRunner$Values.class
fr/x9c/cadmium/kernel/AbstractNativeRunner.class
arnouten@bird:/tmp$
(0000022)
xclerc (Administrator)
2008-08-11 13:23

The problem stems from the command-line switches passed to "java".
Indeed, when the "-jar" switch is used, any "-cp" or "-classpath" is purely
ignored by the JVM without any warning.

The command-line to run the jar file compiled without "-standalone" is thus:
   java -cp /usr/local/lib/ocaml/ocamlrun.jar:/usr/local/lib/ocaml/stdlib.jar:hello.jar pack.cafesterolMain

Two remarks:
  - in my previous note, I forgot to mention that -besides "ocamlrun.jar"- it is also needed to
  put in the classpath the jar files related to the libraries used by the OCaml program
  (in this case, assuming a simple "hello world" program, only stdlib.jar is needed) ;
  - "pack.cafesterolMain" is the name of the Java class acting as the entry point of the compiled
  OCaml program ("cafesterolMain" is hard-wired but "pack" can be changed using the the
  "-java-package" switch of the compiler).

- Problem-Historie
Änderungsdatum Benutzername Feld Änderung
2008-08-10 13:35 raboof Neues Problem
2008-08-10 22:42 xclerc Status neu => erledigt
2008-08-10 22:42 xclerc Behoben in Version => 1.0
2008-08-10 22:42 xclerc Lösung offen => erledigt
2008-08-10 22:42 xclerc Bearbeitung durch => xclerc
2008-08-10 22:42 xclerc Problemnotiz hinzugefügt: 0000019
2008-08-11 10:44 raboof Status erledigt => Rückmeldung
2008-08-11 10:44 raboof Lösung erledigt => wiedereröffnet
2008-08-11 10:44 raboof Problemnotiz hinzugefügt: 0000021
2008-08-11 13:23 xclerc Problemnotiz hinzugefügt: 0000022
2008-08-11 13:23 xclerc Status Rückmeldung => erledigt
2008-08-11 13:23 xclerc Lösung wiedereröffnet => erledigt


Mantis 1.1.7[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker