Seite 1 von 1

Jython-Servlet Tomcat: java.lang.NoClassDefFoundError

Verfasst: Dienstag 4. September 2012, 08:50
von dkr
Update: java.lang.NoClassDefFoundError: org/python/core/PyRunnable

Habe via Logging-Konfig. den eigentl. Stack-Trace erhalten: Die Exception ist statt "java.lang.IllegalStateException" (Catalina-Loader) nun:

java.lang.NoClassDefFoundError: org/python/core/PyRunnable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at org.python.core.BytecodeLoader$Loader.loadClassFromBytes(BytecodeLoader.java:119)
at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:37)
at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:67)
at org.python.compiler.LegacyCompiler$LazyLegacyBundle.loadCode(LegacyCompiler.java:43)
at org.python.core.CompilerFacade.compile(CompilerFacade.java:34)
at org.python.core.Py.compile_flags(Py.java:1703)
at org.python.core.Py.compile_flags(Py.java:1708)
at org.python.core.Py.compile_flags(Py.java:1718)
at org.python.core.__builtin__.execfile_flags(__builtin__.java:514)
at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:225)
at org.python.util.PyServlet.createInstance(PyServlet.java:208)
...

Das sieht nun danach aus, als finde der Standard-Java-ClassLoader die Jython "PyRunnable"-Definition nicht. Fehlt mglw. etwas im ClassPath (darin ist nur shared/lib/jython.jar) oder muss die jython.jar an andere Stelle in die ClassLoader-Hierarchie?

PyRunnable ist in jython.jar als Interface definiert und wird insofern anscheinend von der jython-generierten Klasse implementiert. Vermutlich findet der Java-ClassLoader diese Interface-Definition nicht. Aber warum bzw. was kann man dagegen machen?

Schöne Grüße, D.Kruft


Hallo allerseits,
es gelingt mir bisher nicht, die Tomcat-Servlet-Engine i.V. mit Jython zu nutzen.
Im Tracestack erkennbar ist, dass durchaus einiges funktioniert:

WebappClassLoader - Illegal access: this web application instance has been stopped already. Could not load org.python.core.PyRunnable. ...: java.lang.IllegalStateException
- at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1324)
- at java.lang.ClassLoader.loadClass(Unknown Source)
- at java.lang.ClassLoader.loadClass(Unknown Source)
- at org.python.core.BytecodeLoader$Loader.loadClass(BytecodeLoader.java:99)
- at java.lang.ClassLoader.loadClass(Unknown Source)
- at java.lang.ClassLoader.defineClass1(Native Method)
- at java.lang.ClassLoader.defineClassCond(Unknown Source)
- at java.lang.ClassLoader.defineClass(Unknown Source)
- at org.python.core.BytecodeLoader$Loader.loadClassFromBytes(BytecodeLoader.java:119)
- at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:37)
- at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:67)
- at org.python.compiler.LegacyCompiler$LazyLegacyBundle.loadCode(LegacyCompiler.java:43)
- at org.python.core.CompilerFacade.compile(CompilerFacade.java:34)
- at org.python.core.Py.compile_flags(Py.java:1703)
- at org.python.core.Py.compile_flags(Py.java:1708)
- at org.python.core.Py.compile_flags(Py.java:1718)
- at org.python.core.__builtin__.execfile_flags(__builtin__.java:514)
- at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:225)
- at org.python.util.PyServlet.createInstance(PyServlet.java:208)
- at org.python.util.PyServlet.loadServlet(PyServlet.java:188)
- at org.python.util.PyServlet.getServlet(PyServlet.java:178)
- at org.python.util.PyServlet.service(PyServlet.java:155)
- at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
- at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
- at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)

In tomcat-Methode WebappClassLoader.loadClass wird in Zeile 1324 tatsächlich diese IllegalStateException gestartet, wenn !this.started gilt. Das Attribut "started" wiederum wird nur True, wenn WebappClassLoader.start() aufgerufen wurde. Das ist anscheinend nicht passiert, oder es lief bereits wieder ein WebappClassLoader.stop().

Weitere Erkenntnisse habe ich selbst leider noch nicht.

Wenn ich die org.python.core-Calls sehe, execfile_flags - BytecodeLoader.makeClass - BytecodeLoader$Loader.loadClass, dann scheint es mir, dass das Lesen der Pythonquelle und Übersetzen in Javaklasse "PyRunnable" noch funktioniert, diese Klasse aber vom Tomcat WebappClassLoader nicht instantiiert und/oder gestartet werden kann.

Hat dazu jemand eine Idee?

Vielen Dank im Voraus und schöne Grüße,
D.Kruft