Sunyifan / java-gearman-service

Automatically exported from code.google.com/p/java-gearman-service
0 stars 0 forks source link

NullPointerException #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Look into why this NullPointerException is occurring:

Ref: https://groups.google.com/forum/?fromgroups=#!topic/gearman/ZfkIYis_FbI

----------------------------------------------------

Hello everybody,

I'm new to gearman and try to implement a simple client perl. The worker will 
also be written in Perl. Because compiling the gearmand unter Red Hat 5.6 is a 
real pain, I want to use the Java-Implementation.
The java-service runs. I can connect a client, I can see the announced function 
of the worker, but when the client should start a task, I get the following 
NullPointerException:

 ERROR gearman - failed to execute packet: SUBMIT_JOB
java.lang.NullPointerException
        at org.gearman.impl.server.local.JobAbstract.getNextJobHandle(Unknown Source)
        at org.gearman.impl.server.local.JobAbstract.<init>(Unknown Source)
        at org.gearman.impl.server.local.Function$InnerJob.<init>(Unknown Source)
        at org.gearman.impl.server.local.Function.createJob(Unknown Source)
        at org.gearman.impl.server.local.Interpreter.submit_job(Unknown Source)
        at org.gearman.impl.server.local.Interpreter.execute(Unknown Source)
        at org.gearman.impl.server.local.GearmanServerLocal.onPacketReceived(Unknown Source)
        at org.gearman.impl.core.GearmanConnectionManager$SocketHandlerImpl$Connection.onDecode(Unknown Source)
        at org.gearman.impl.core.StandardCodec.body(Unknown Source)
        at org.gearman.impl.core.StandardCodec.decode(Unknown Source)
        at org.gearman.impl.core.GearmanConnectionManager$SocketHandlerImpl.onRead(Unknown Source)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
        at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
        at sun.nio.ch.UnixAsynchronousSocketChannelImpl.implRead(UnixAsynchronousSocketChannelImpl.java:553)
        at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:272)
        at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
        at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
        at sun.nio.ch.Invoker.invokeDirect(Invoker.java:145)
        at sun.nio.ch.UnixAsynchronousSocketChannelImpl.implRead(UnixAsynchronousSocketChannelImpl.java:553)
        at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:272)
        at sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:293)
        at java.nio.channels.AsynchronousSocketChannel.read(AsynchronousSocketChannel.java:407)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at org.gearman.impl.reactor.SocketImpl.completed(Unknown Source)
        at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
        at sun.nio.ch.Invoker$2.run(Invoker.java:206)
        at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

My client-code looks like this (original sample from CPAN for testing):

use strict;
use lib "/opt/gearman/lib";
use Gearman::Client;
use Storable qw( freeze );

my $client = Gearman::Client->new;
$client->job_servers('xxx.xxx.xxx.xxx:4730');
#my $result_ref = $client->do_task("mer_v13_u1", "BLAA");
#print $$result_ref."\n";

  my $tasks = $client->new_task_set;
    my $handle = $tasks->add_task(sum => freeze([ 3, 5 ]), {
        on_complete => sub { print ${ $_[0] }, "\n" }
});
$tasks->wait;

And here is my worker:

use strict;
use Cwd;
use lib "/opt/gearman/lib";
use Gearman::Worker;
use Config::INI::Simple;

my $path_separator = "/";
my $ini_file = "/opt/gearman/config.ini";

my $conf = new Config::INI::Simple;
$conf->read($ini_file);

print "JOB_SERVERS: ".$$conf{'GENERAL'}{'JOB_SERVERS'}."\n";
print "CSI_DIR: ".$$conf{'GENERAL'}{'CSI_DIR'}."\n";
print "ENV_COUNT: ".$$conf{'GENERAL'}{'ENV_COUNT'}."\n\n\n";

for(my $i=1;$i <= $$conf{'GENERAL'}{'ENV_COUNT'};$i++){
        print "Umgebung Nr. ".$i."\n";
        print "Mandant: ".$$conf{'ENV'.$i}{'CUSTOMER'}."\n";
        print "Basis-Verzeichnis: ".$$conf{'ENV'.$i}{'BASE_DIR'}."\n";
        print "Cef-File: ".$$conf{'ENV'.$i}{'CEF_FILE'}."\n\n";
}

my $worker = Gearman::Worker->new;
$worker->job_servers($$conf{'GENERAL'}{'JOB_SERVERS'});
$worker->register_function(mer_v13_u1 => sub { print "YEAAAHH!!!";});
$worker->work while 1;

I tried both, sending the task to the worker and calling the job on the worker. 
Everything I try leads to the Exception above.

Here my versions:
JAVA: JDK 1.7u7
Java-Gearman-Service 0.6.5
Perl-Libraries for Client and Worker: 1.11

Does someone have a clue, what goes wrong?

Original issue reported on code.google.com by isaiah.v...@gmail.com on 20 Sep 2012 at 4:52

GoogleCodeExporter commented 9 years ago
Perl communication is working correctly under windows. I'm going to setup a 
linux environment to see if I can reproduce the issue there.

Original comment by isaiah.v...@gmail.com on 22 Sep 2012 at 4:54

GoogleCodeExporter commented 9 years ago
I'm closing the issue. A change was made based on the stack trace, but because 
I cannot reproduce the issue or get a hold of the original poster, the fix 
cannot be verified.

This issue may be re-opened in the future.

Original comment by isaiah.v...@gmail.com on 28 Sep 2012 at 3:16