How to run a jpype job using dumbo

17 views
Skip to first unread message

Chao Peng

unread,
Apr 5, 2013, 9:43:24 AM4/5/13
to dumbo...@googlegroups.com
Hi,

I'm trying to do a mapreduce job with jpype. There is a simple one.

Java class

package com.es.jpypetest.test
public class Test {
public int increment(int  x)
{
return x+1;
}
}

dumbo file
  1 from jpype import *                                                             
  2 from dumbo import *                                                             
  3 import sys                                                                      
  4                                                                                 
  5 def startJvm():                                                                 
  6     classpath = "jpypetest.jar"                                  
  8     startJVM(getDefaultJVMPath(), "-Djava.class.path=%s" % (classpath))                                                                    
 10                                                                                 
 11                                                                                 
 12 class Mapper():                                                                 
 13     def __init__(self):                                                         
 14         startJvm()                                                              
 15         testPkg = JPackage('com').es.jpypetest.test                
 16         Test = testPkg.Test                                          
 17                                                                                 
 18         self.inCre = Test()                                                
 19         self.count = 0                                                          
 20                                                                                 
 21     def __call__(self, key, value):                                             
 22         self.count += 1                                                         
 23         yield self.count, self.inCre.add1(self.count)


and I use both -libjar and -file to add the jpypetest.jar, both of them show the same error
self.inCre = Test()
File "/usr/local/lib/python2.7/dist-packages/jpype/_jpackage.py", line 53, in __call__
raise TypeError, "Package "+self.__name+" is not Callable"
TypeError: Package com.es.jpypetest.test.Test is not Callable

what should I do?

pc 
Reply all
Reply to author
Forward
0 new messages