JAVA renjin function not found - java

org.renjin.eval.EvalException: lubridate could not be found at
org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:83) at
org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:63)
...
I think the function lubridate is not implemented in renjin?
How can i know what functions are implemented?

Lubridate is actually an R package, not a function from R itself. You would need to include the jar for the lubridate package on your classpath.
Unfortunately, it appears that Renjin is not yet able to run this package: see http://packages.renjin.org/packages/lubridate.html for latest status of this and other packages.
Check back in a week or so for the next release candidate, we're fixing a lot of these problems.

Related

Jpype import cannot find module in jar

I have received the task, at work, to find a way to use some methods from an existent jar file in a Python project. I have very limited experience in Python, but I have worked with that specific jar file before (it is part of a project we are working on). I am not allowed to modify much of both projects, and they are required to be as independent as possible.
I have researched multiple ways to include the jar methods in Python. So far, I have tried Jython (which I cannot use because the Python project uses PyQt among other libraries, which force the use of CPython, if my understanding is correct), Pyjnius and JPype. JPype seems the most promising, but I cannot get it working either. I have pasted the my code below, slightly censored because I don't know how much I am allowed to share.
from jpype import *
import jpype.imports
try:
jpype.addClassPath("jars/sdk.jar") #the relative path to the jar file
jpype.startJVM(convertStrings=False)
java.lang.System.out.println(jpype.getClassPath()) #printing the classpath to check, the path is correctly pointing to the sdk.jar file
java.lang.System.out.println("Hello world") #just to check if jpype is installed correctly, works
jpype.imports.registerDomain("a")
from a.b.c.d.e.f.g.h import SomeClass #fails here
except OSError as err:
print(err) # ToDo: Remove print when done
pass
The error I am getting is that the module a.b.c.d.e.f.g.h.SomeClass could not be found. I have tried different ways to give the path (absolute path, relative path, place the jar in different places in the project and outside of it), but that doesn't seem to be the problem, as the path printed is the correct absolute path to the jar file.
Also, the jar is used in other (Java) projects and it works. It is created using maven package (using IntelliJ, if it is relevant, and the same Java version as the one used by the JPype JVM). In the Java projects, the import would be:
import a.b.c.d.e.f.g.h.SomeClass;
I have copied this and just transformed the syntax into Python.
I have also tried to create the class with JObject (which I probably didn't do right anyway) and also tried the older syntax (to my understanding) with JPackage. For the JPackage way, I am getting the exception that the package a.b.c.d.e.f.g.h.SomeClass.someMethod is not Callable, which to my understanding is an equivalent exception to the one I'm getting using jpype imports. I have already gone through all the questions I could find here with similar problems, but none of those solutions have helped me.
Can anyone suggest some possible solution? Or can anyone see what I'm doing wrong? Suggestions of other possibilities to replace JPype are also welcomed. If there is any clarification needed, I will edit the question.
The only thing that seems likely if the jar is on the classpath and failed to import would be for there to be some missing dependency. You have two other ways to try loading the class which may provide additional diagnostics.
jpype.JClass("a.b.c.d.e.f.g.h.SomeClass")
and
jpype.JClass("java.lang.Class").forName("a.b.c.d.e.f.g.h.SomeClass")
The first is manually loading a class by full class specification. It is mechanically what is happening under the import. The second is calling for Java to load the class (bypassing all of JPype). It returns a java.lang.Class which can be passed to JClass to make a wrapper.
Common failures include missing a jar or native library, attempting to start JPype from within a module and having the wrong relative path, error in initialization of the class due to missing resource. JPype is just calling JNI calls, so if everything is fine on Java end it should work. Given that you checked the java.class.path System variable, it has to be something to do with class resources.
The JPype user manual has an alternatives section if you would like to try to find another package. Most of the alternatives with the exception of PyJnius appear to be unmaintained.

How do I instantiate a class from this JAR file using rJava?

I was working on a text-analysis project in R and needed a stemmer. I found a JAR-file of a java compilation of a snowball stemmer. Documentation:
http://lucene.apache.org/core/3_0_3/api/contrib-snowball/
Download link (bottom link):
http://www.java2s.com/Code/JarDownload/snowball/
Now, as far as I could tell, this R code should make a new stemmer object:
library(rJava)
.jinit("D:\\myUser\\Documents\\snowball.jar")
stemmer <- .jnew("org.tartarus.snowball.ext.EnglishStemmer")
However the final line of code gives the following error:
Error in .jnew("org.tartarus.snowball.ext.EnglishStemmer") :
java.lang.ClassNotFoundException
After spending quite a lot of time on this (among others, reading the following post for help: https://darrenjw.wordpress.com/2011/01/01/calling-java-code-from-r/), I got stuck because I am not sure what the exact problem is. As far as I can tell, it could be in order of likelyhood:
1. a mistake in my code
2. an issues with dependancies
3. the JAR file is corrupted somehow
Can anyone give me some pointers on where the problem might lie?
Edit: answered, see comments. The class names in this specific jar-file are lowercase.

Hadoop NoSuchMethodError

Does anyone have any idea why something that used to work before all of a sudden started giving this error? please help
java.lang.NoSuchMethodError: org.apache.hadoop.mapred.Counters.findCounter(Ljava/lang/Enum;)Lorg/apache/hadoop/mapreduce/Counter;
at edu.umn.cs.spatialHadoop.operations.Sampler.sampleMapReduceWithRatio(Sampler.java:214)
at edu.umn.cs.spatialHadoop.operations.Sampler.sample(Sampler.java:543)
at edu.umn.cs.spatialHadoop.operations.Repartition.packInRectangles(Repartition.java:494)
at edu.umn.cs.spatialHadoop.operations.Repartition.packInRectangles(Repartition.java:463)
at edu.umn.cs.spatialHadoop.operations.Repartition.repartitionLocal(Repartition.java:590)
This has been working earlier but suddenly started giving this error. I am using hadoop version 1.2.1
Counter class is included in hadoop-mapreduce-client-core.jar. You must have downgraded it somehow.
If you are using a build tool (maven, gradle...), check your dependencies and make sure they haven't changed. In case of doubt, just apply the latest version.
Else, go to your hadoop-mapreduce-client-core.jar and either check if the method is inside or just get a newer version to replace it in your project.
from org/apache/hadoop/mapreduce/Counter I guess that the hadoop-mapreduce-client-core.jar is missing
This is because of latest compiled class and dependent jar available in the application are of different version. For example: Let Class A compiled with dependent jar X in place then later same Class A compiled in different environment withe dependent jar X1 which consist new method called Y in that. now the class will be compiled because new method Y is available in jar X1 when the same Class A is used in the environment with jar X in place then it leads to the NoSuchMethod Exception when trying to load the class in the class memory. Classloader does the verification of the dependent classes before loading the class in the class memory before invoking real exceution.
Everything were available all jar files and all. After an exhausting work thinking of whats wrong, i decided to reload everything afresh (i.e reload the hadoop files). Thanks to you guys for helping :)

NoClassDefFoundError when code moved from R2007a to R2013a

I am working on moving code from R2007a to R2013a. I am getting a java.lang.NoClassDefFoundError during my run in R2013a which does not appear in R2007a. It occurs when I call.
feval('get',fname,jevent);
Where fname is a product.ProxyField object for an Object Filter and jevent is a product.format.java.internal.JavaEvent.
The class is in a jar file on the path and is being accessed by another class in the same jar file. The stack trace does not leave the realm of the product if that helps.
I do not have access to the original code for the jar file. I do have access to code derived from that original code and both classes are in the same package. I'm guessing this has something to do with differences in the java version but I'm not sure what to do since I don't have the original code to recompile.
Unfortunately I can't provide actual source or full detail but a google search only yielded results for MATLAB startup issues. Any thoughts?
Seems like the difference between R2007a and R2013a is that the first uses 1.5 jre and second uses 1.6 jre. It would be easier to help you if you provided the stack trace showing the exception. Sometimes classes get moved around in between jvm versions, so having the actual missing classes would help in determining if the missing class is a class that was just moved around to a different package. You could take the missing class, google it adding the same exception message as you put above and seeing who else ran into similar issues.

JNI lib crash, with a change in a .c file which is not included in the Makefile

We are facing an unusual problem, our JNI lib crashes at load time.
we use CentOS 5.4/G++ and VS2005 for development.
scenario:
we are currently working on an enhancement in our product and wanted to pass the new information back to the Java server code using JNI.
our C/C++ code works fine and we have tested it by running for around 6 hours or so in our dev environment. we have updated two result structure(which were already present) with one long value each to pass on the result of our new enhancement.
when we updated the JNI code to pass on the result to Java code, we found that Java server is crashing while loading JNI, we did debugging and found that JNI lib crashes, even, when we do not have our changes in JNI lib code base.
in our further debugging we found that, JNI Makefile includes a .c file(aa.c), which has a couple of our changes for the new enhancement; we started with commenting our changes in this aa.c file one by one and found that the crash happens only when we have BBB.cpp::method1() call(which we have added, as part of our new enhancement).
The unusual part is, this .c file(aa.c) is not needed in the JNI lib and we do not have any methods of aa.c called from JNI lib;
Now we have removed aa.c from the JNI Makefile and compile just fine, but still crashes when we have BBB.cpp::method1() call, if we remove this method1() call then it works fine.
we are not sure, why/how it is linking to a file which is not included, in the Makefile and crashing.
this is the error log we see
AgentServer#0 started: OK
12750 [Connection#Cnx:#0.0.1026:0 - Session#c0s1] ERROR com.xx.xxx.xxxx - Unable to load JNI BBBController Library
java.lang.UnsatisfiedLinkError: /opt/XXXXX/lib/libjnixxx.so: Can't load IA 32-bit .so on a IA 32-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
Please suggest, any idea's would be appreciated.
Thanks in advance,
Aqura
I'd suggest you try turning on debugging in ld.so.1 when you start your application up and see if that gives you any clues. See LD_DEBUG in http://linux.die.net/man/8/ld-linux
finally, we are able to solve this issue.
We were seeing this issue because the Makefile we used to build the JNI lib had a lot of .o files which were not needed by the build.
one of the file happened to be the one, we were modifying, but other dependent files were not included in the Makefile and this was causing the crash at load time as it was not able to resolve the references.
to find and fix the issue, we created a simple Java class which just loads the libjni.so, this gave us undefined references to method, which we searched and started fixing the ones not needed.
I know this was a crude method and it will take some time to find and fix the original issue.
This worked for us, so I thought I would share this with others.
Aqura

Categories

Resources