Thank you Andi for checking,

I am able to reproduce it again (please see below). My problem is
probably two packages with lucene (I started to play with PyLucene
only recently, and the older code is there doing other work).

The lucene is a PyLucene (lucene 2.9.1) and pyjama contains GATE and
also my own lucene (2.9.1) - so, effectively, I have two lucenes

 - but in the pyjama package, the jcc wrapper was built only for my
own classes (that talk to java-lucene behind the scene)
 - when ClassNotFoundException happens, java is apparently searching
inside pyjama's jars (and the classes are only in lucene's jars)


So that brings me to question like if it is safe to mix python
packages that contain the same java classes? Or not recommended at
all?

Best,

Roman


In [1]: import lucene,pyjama

In [2]: pyjama.initVM(pyjama.CLASSPATH, vmargs='-Dgate.site.config=C:/dev/worksp
ace/newseman/src/merkur/cfg//gate.xml,-Dgate.plugins.home=C:/dev/workspace/newse
man/src/merkur/cfg/ANNIE/plugins,-Dgate.user.config=C:/dev/workspace/newseman/sr
c/merkur/cfg//user.xml,-Dgate.user.session=C:/dev/workspace/newseman/src/merkur/
cfg//gate.session,-Xms32m,-Xmx256m')
Out[2]: <jcc.JCCEnv object at 0x00A4E7B0>

In [3]: lucene.initVM(lucene.CLASSPATH)
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/ana
lysis/ar/ArabicAnalyzer
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.ar.Arabi
cAnalyzer
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
---------------------------------------------------------------------------
JavaError                                 Traceback (most recent call last)

C:\dev\WORKSP~1\newseman\utils\pyjama\build\dist\pyjama\<ipython console> in <mo
dule>()

JavaError: java.lang.NoClassDefFoundError: org/apache/lucene/analysis/ar/ArabicA
nalyzer
    Java stacktrace:
java.lang.NoClassDefFoundError: org/apache/lucene/analysis/ar/ArabicAnalyzer
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.ar.Arabi
cAnalyzer
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)




On Tue, Feb 9, 2010 at 10:25 PM, Andi Vajda <va...@apache.org> wrote:
>
> On Tue, 9 Feb 2010, Roman Chyla wrote:
>
>> I wanted to ask if there was any progress on this issue (extending
>> classpath runtime):
>>
>> http://lists.osafoundation.org/pipermail/pylucene-dev/2008-March/002455.html
>
> Yes, this should work provided you invoke jcc with --shared when building
> your modules.
>
> I just verified this worked by using PyLucene and PyPDFBox together, both
> built with --shared.
> (Note that with a recent JCC, you no longer need to pass the classpath to
> initVM(), the parameter is defaulted to the module's CLASSPATH variable):
>
>    yuzu:vajda> python
>    Python 2.6.2 (r262:71600, Sep 20 2009, 20:40:09)
>    [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
>    Type "help", "copyright", "credits" or "license" for more information.
>    >>> import pdfbox
>    >>> pdfbox.initVM(vmargs='-Djava.awt.headless=true')
>    <jcc.JCCEnv object at 0x1004030d8>
>    >>> import lucene
>    >>> lucene.initVM()
>    <jcc.JCCEnv object at 0x1004034e0>
>    >>> lucene.Document()
>    <Document: Document<>>
>    >>> pdfbox.PDFTextStripper()
>    <PDFTextStripper: org.apache.pdfbox.util.pdftextstrip...@83e96cf>
>    >>>
>
> or in a different order:
>
>    yuzu:vajda> python
>    Python 2.6.2 (r262:71600, Sep 20 2009, 20:40:09)
>    [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
>    Type "help", "copyright", "credits" or "license" for more information.
>    >>> import lucene, pdfbox
>    >>> lucene.initVM(vmargs='-Djava.awt.headless=true')
>    <jcc.JCCEnv object at 0x1004030d8>
>    >>> pdfbox.initVM()
>    <jcc.JCCEnv object at 0x100403150>
>    >>> lucene.Document()
>    <Document: Document<>>
>    >>> pdfbox.PDFTextStripper()
>    <PDFTextStripper: org.apache.pdfbox.util.pdftextstrip...@6548f8c8>
>
> The vmargs='-Djava.awt.headless=true' parameter to the first initVM() is
> required by pdfbox. The first initVM() call starts and initializes the Java
> VM, the second one just updates its classpath and cannot change or set
> vmargs.
>
> Andi..
>

Reply via email to