kreetrapper has asked for the wisdom of the Perl Monks concerning the following question:

Dear fellow monks,

I have a strange problem with a program where I use Inline::Java. I just reopened it in Padre after some months of not touching it and suddenly I get strange errors like the following:

$ perl -c lari.pl lari.pl syntax OK (in cleanup) In method DESTROY of class main::org::apache::log4j:: +Logger: Can't find object 0 for thread IJST-#0 at /home/alex/perl5/li +b/perl5/x86_64-linux-gnu-thread-multi/Inline/Java/Object.pm line 357 +at lari.pl line 0 ... (in cleanup) Unknown Java object reference main::org::apache::log4 +j::Logger=HASH(0x17d88c0) at lari.pl line 0

I get similar errors for some other jars / Java classes. The weird thing now is that the exact same program is still running fine on the server, while I can't get it running on my machine. I looked at both the server and my computer and these are the stats for them

server:
- perl, v5.10.0 built for x86_64-linux-thread-multi
- Inline::Java version 0.53
- JAVA
- java version "1.6.0_21"
- Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
- Java HotSpot(TM) 64-Bit Server VM (build 17.0-b16, mixed mode)

my machine:
- perl 5, version 12, subversion 4 (v5.12.4) built for x86_64-linux-gnu-thread-multi (with 45 registered patches, see perl -V for more detail)
- Inline::Java version 0.53
- JAVA
- java version "1.6.0_30"
- Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
- Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)

Both times I use the same jars containing the relevant Java code.

This is the relevant part of my code, where I call Inline::Java

# set the java classpath (it is assumed that the jars are in the same +folder as this script) BEGIN { $ENV{CLASSPATH} .= ":.:lari_typecheck.jar:log4j-1.2.14.jar:postgre +sql8jdbc3.jar"; } # use Inline::Java and tell it to study the classes that will be used use Inline Java => 'STUDY', STUDY => ['lari_typecheck.ArchiveObject', 'org.apache.log4j.Logger', ], AUTOSTUDY => 1;

I have no idea what is going on here. I really hope one of you can help me figuring this out.

greetings Alex

Replies are listed 'Best First'.
Re: Inline::Java stopped working
by tobyink (Canon) on Feb 01, 2012 at 13:37 UTC

    An obvious thing to check would be that Inline::Java (which is partly XS code) is compiled against the same version of Java you have installed on your system. If you have upgraded Java after the last time you installed/upgraded Inline::Java, then this might be the problem.

    If you download the Inline-Java tarball from CPAN, and untar it, does the test suite pass? (Use "prove" at the command line - don't use "make test".)

      Yes, the suite does pass. All tests successful.
Re: Inline::Java stopped working
by kreetrapper (Scribe) on Feb 03, 2012 at 07:20 UTC

    I just wanted to report that this seems to be a problem with my Perl (module) setup. I created a new user account on my machine. This means it uses the same Perl and the same Java. As this new user I installed Inline::Java via CPAN and local::lib and the code worked.

    Thanks for your help.

    Alex

Re: Inline::Java stopped working
by Anonymous Monk on Feb 02, 2012 at 04:43 UTC

    I have no idea what is going on here. I really hope one of you can help me figuring this out.

    use absolute paths and turn on logging

Re: Inline::Java stopped working
by shafik (Initiate) on May 09, 2012 at 20:21 UTC

    I was seeing the same message when attempting to use Inline::Java within a thread with a shared JVM i.e. SHARED_JVM => 1. The program actually worked fine, it was generating the warning either after a threads::join() or if using threads::detach() at the end of program. The solution ended up being an explicit call to Inline::Java::done() at the end of each thread. Each thread had to also start with a call to Inline::Java::reconnect_JVM().

      I am having the same issues. I can't figure out where to place the Inline::Java::done() call. Can someone provide some guidance on this? Here is my Perl script.
      package MY::PACKAGE; # Add the Jar file path to the CLASSPATH environment variable BEGIN { $ENV{CLASSPATH} .= ":/drive1/myjavaclass.jar"; } # Called the Java class(es) that will be used by Perl # The DIRECTORY variable should have a location where contents can be + write to use Inline ( Java => 'STUDY', STUDY => ['MyJavaClass'], AUTOSTUDY => 1, DIRECTORY => '/drive1/' ); # Used to make the PM file available in a CGI environment my $q = new CGI(); # Define the new method establishing a connection to the Java class c +onstructor sub new { my $class = shift; my $obj = MY::PACKAGE::MyJavaClass->new(); return $obj; } 1;
        Nowhere, the code you posted doesn't use threads