lucene-pylucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Korosov" <anton.koro...@nersc.no>
Subject Re: real reason for java.lang.NoClassDefFoundError ?
Date Thu, 10 Mar 2011 10:23:59 GMT
Thank you very much, Andi, for the prompt reply!
Can I torture you with questions a bit more?

Now I tried to build it the following way:
python -m jcc.__init__ \
--python testjava \
--build \
--install \
--jar /host/local/beam-4.8/modules/beam-core-4.8.2.jar \
--classpath /host/local/beam-4.8/lib/clibwrapper-jiio-1.2-20090918.jar \
--classpath /host/local/beam-4.8/lib/commons-beanutils-1.7.0.jar \
... + 100 more JARs in classpath.

and it worked perfectly! CPP and Py code was generated, built, and
installed. I even managed to
import testjava
However, when I do
testjava.initVM(testjava.CLASSPATH)
it gives error that looks familiar:
---------------------------------------------------------------------------
JavaError                                 Traceback (most recent call last)

/home/antonk/<ipython console> in <module>()

JavaError: java.lang.NoClassDefFoundError: javax/media/jai/OpImage
    Java stacktrace:
java.lang.NoClassDefFoundError: javax/media/jai/OpImage
Caused by: java.lang.ClassNotFoundException: javax.media.jai.OpImage
	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:321)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)

Does that simply mean that I should find a JAR that contains
javax/media/jai/OpImage and include it as --jar while building?

When I try that
--jar /host/local/beam-4.8/lib/jai_core-1.1.3.jar \
and add more required classpathes required by jai
--classpath /host/local/beam-4.8/jre/lib/alt-rt.jar \
--classpath /host/local/beam-4.8/jre/lib/charsets.jar \
--classpath /host/local/beam-4.8/jre/lib/deploy.jar \
--classpath /host/local/beam-4.8/jre/lib/jce.jar \
--classpath /host/local/beam-4.8/jre/lib/jsse.jar \
--classpath /host/local/beam-4.8/jre/lib/management-agent.jar \
--classpath /host/local/beam-4.8/jre/lib/plugin.jar \
--classpath /host/local/beam-4.8/jre/lib/resources.jar \
--classpath /host/local/beam-4.8/jre/lib/rt.jar \

it again gives error while generating the code by JCC:
While loading com/sun/media/jai/tilecodec/JPEGTileEncoder
Traceback (most recent call last):
  File "/usr/lib/python2.6/runpy.py", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.6/runpy.py", line 34, in _run_code
    exec code in run_globals
  File
"/usr/local/lib/python2.6/dist-packages/JCC-2.7-py2.6-linux-x86_64.egg/jcc/__init__.py",
line 32, in <module>
    import jcc.__main__
  File
"/usr/local/lib/python2.6/dist-packages/JCC-2.7-py2.6-linux-x86_64.egg/jcc/__main__.py",
line 98, in <module>
    cpp.jcc(sys.argv)
  File
"/usr/local/lib/python2.6/dist-packages/JCC-2.7-py2.6-linux-x86_64.egg/jcc/cpp.py",
line 501, in jcc
    cls = findClass(className.replace('.', '/'), iii)
  File
"/usr/local/lib/python2.6/dist-packages/JCC-2.7-py2.6-linux-x86_64.egg/jcc/cpp.py",
line 73, in findClass
    cls = _findClass(className)
jcc.cpp.JavaError: java.lang.IncompatibleClassChangeError: Implementing class
Java stacktrace:
java.lang.IncompatibleClassChangeError: Implementing class
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
	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:321)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)

But here I'm stuck. What means java.lang.IncompatibleClassChangeError? How
should I cope with that problem now? Can you please suggest something?

All the best!
Anton

ps. It's quite useful to write you: I try 3-5 solutions while just
describing the problem ;)
pps. JCC is absolutely fantastic! What I luck is a bit of experience in
Java :(

>
> On Wed, 9 Mar 2011, Anton Korosov wrote:
>
>> I'm trying to use BEAM/Visat software in Python. It is a large project
>> with > 100 JARs. I try to 'convert' these JARs into Python specifying
>> each
>> after --jar option:
>> python -m jcc.__init__ \
>> --python testbeam \
>> --jar /host/local/beam-4.8/modules/beam-landsat-reader-1.2.1.jar \
>> --jar /host/local/beam-4.8/modules/beam-meris-boreal-lakes-1.4.2.jar \
>> --jar /host/local/beam-4.8/modules/beam-meris-case2-core-1.4.2.jar \
>> --jar /host/local/beam-4.8/modules/beam-meris-case2-regional-1.4.2.jar \
>> --jar /host/local/beam-4.8/modules/beam-meris-cloud-1.5.203.jar \
>> --jar /host/local/beam-4.8/modules/beam-meris-eutrophic-lakes-1.4.2.jar
>> \
>> --jar /host/local/beam-4.8/modules/beam-merisl3-reader-1.1.jar \
>> ...
>
> If any of these jar files depend on other jar files not listed with --jar,
> such as lucene's (as you hint below with QueryParser not being found) then
> you must list lucene's jar on --classpath or ensure it's on the CLASSPATH
> env var.
>
> Also, you only need to list --jar files whose public classes you want to
> make accessible from Python. Dependencies can be listed with --classpath
> or
> --include.
> See output of 'python -m jcc.__main__' for details about JCC's command
> line
> flags.
>
> Andi..
>
>>
>> However I immediately got error:
>> While loading com/jidesoft/lucene/c$1
>> Traceback (most recent call last):
>>  File "/usr/lib/python2.6/runpy.py", line 122, in _run_module_as_main
>>    "__main__", fname, loader, pkg_name)
>>  File "/usr/lib/python2.6/runpy.py", line 34, in _run_code
>>    exec code in run_globals
>>  File
>> "/usr/local/lib/python2.6/dist-packages/JCC-2.7-py2.6-linux-x86_64.egg/jcc/__init__.py",
>> line 32, in <module>
>>    import jcc.__main__
>>  File
>> "/usr/local/lib/python2.6/dist-packages/JCC-2.7-py2.6-linux-x86_64.egg/jcc/__main__.py",
>> line 98, in <module>
>>    cpp.jcc(sys.argv)
>>  File
>> "/usr/local/lib/python2.6/dist-packages/JCC-2.7-py2.6-linux-x86_64.egg/jcc/cpp.py",
>> line 501, in jcc
>>    cls = findClass(className.replace('.', '/'), iii)
>>  File
>> "/usr/local/lib/python2.6/dist-packages/JCC-2.7-py2.6-linux-x86_64.egg/jcc/cpp.py",
>> line 73, in findClass
>>    cls = _findClass(className)
>> jcc.cpp.JavaError: java.lang.NoClassDefFoundError:
>> org/apache/lucene/queryParser/QueryParser
>> Java stacktrace:
>> java.lang.NoClassDefFoundError:
>> org/apache/lucene/queryParser/QueryParser
>> 	at java.lang.ClassLoader.defineClass1(Native Method)
>> 	at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
>> 	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:321)
>> 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
>> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
>> Caused by: java.lang.ClassNotFoundException:
>> org.apache.lucene.queryParser.QueryParser
>> 	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:321)
>> 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
>> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
>> 	... 11 more
>>
>> Why is that? Does that mean that the class com/jidesoft/lucene/c$1 has
>> reference to a class org/apache/lucene/queryParser/QueryParser but the
>> latter is not given in any JAR?
>>
>> How can such situation occur if Beam/Visat works perfectly? Could it be
>> that Beam/Visat simply don't call
>> org/apache/lucene/queryParser/QueryParser ?
>>
>> What should I do? Download a JAR with
>> org/apache/lucene/queryParser/QueryParser or rather --exclude
>> com/jidesoft/lucene/c ? Will it influence performance of the Python
>> module?
>>
>> Thank you very much for any ideas/suggestions!
>> Anton
>>
>
>



Mime
View raw message