Error message I do not understand R renjin - java

I asked for a solution before, but apparently could not be helped as renjin is rather experimental still...but maybe someone could please translate the error message I get into plain English?
Maybe I can then determine if I can reasonable hope to solve this problem in a reasonable time or if I should rather abandon renjin.
Here is the message:
Exception in thread "AWT-EventQueue-0" org.renjin.eval.EvalException: object 'C_hclust' not found
Here is the code:
private void cluster() {
try {
this.engine.eval("dis<-dist(myMatrix, \"binary\")");
} catch (ScriptException ex) {System.out.println(1);
Logger.getLogger(RWorker.class.getName()).log(Level.SEVERE, null, ex);
}
try {
this.engine.eval("clus<-hclust(dis)");
} catch (ScriptException ex) {System.out.println(3);
Logger.getLogger(RWorker.class.getName()).log(Level.SEVERE, null, ex);
}
try {
this.engine.eval("plot(clus)");
} catch (ScriptException ex) {System.out.println(4);
Logger.getLogger(RWorker.class.getName()).log(Level.SEVERE, null, ex);
}
}
I did not get any of the prints, however.

C_hclust is a function from the stats package written in C but not yet included in Renjin. We are slowly integrating the C/Fortran code from the GNU R stats package as we test and expand our C/Fortran translator.
We're always looking for contributors so this might be a good mini project if you want to get involved - you can take a stab at copying the relevant sources int packages/stats/src/main/c and see if it compiles with out error.
Otherwise completing the functionality of the stats package is a priority and you can look for it in the near future!

I wrote a letter to their mailing list - turns out it is really a bug on their part which will hopefully be fixed soon.

Related

Calling C++ From JMS with JNI

I'm trying to call Sleuth Kit C++ Framework through its JNI wrapper from a JMS MessageListener. But I'm getting this error
java.lang.UnsatisfiedLinkError: /tmp/libtsk_jni.so: libtsk.so.10: cannot open shared object file: No such file or directory
I tried coping the libtsk_jni.so to /tmp but no difference.
But I can do this in a Java console application. What could be the error?
public void onMessage(Message message) {
try {
String imagePath = "uploads/Cfreds001A001.dd";
try{
SleuthkitCase sk = SleuthkitCase.newCase(imagePath + ".db");
} catch (TskCoreException ex) {
}
} catch (JMSException ex) {
Logger.getLogger(WorkerBean.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
Logger.getLogger(WorkerBean.class.getName()).log(Level.SEVERE, null, ex);
}
Attempting to use native methods from code running in a Java EE container is not allowed by the standard and may cause undefined behavior. See the JavaWorld article from August 2000 "Programming restrictions on EJB", still true today as far as I know.
Depending on your Java EE container, you may in fact be able to get this to work. It may help to put the libtsk_jni.so in the system library directory or to edit the server's start script to set the LD_LIBRARY_PATH environment variable.

I can't solve my <identifier> expected error, and dont know why

Ok, so im super, extra, brand new to java coding, but im slowly getting all the terms. But the real issue is this error. I'm trying to do a little coding snippet that, when started, will open a batch file (i'm much more experienced with them). I searched very much for answers, but nothing solved it, so i had o post about my specific situation.
This is said code:
public class Startbat {
public static void main(String[] args){
try {
Runtime.getRuntime().exec("cmd /c start hello.bat");
}
catch (IOException) {
System.out.println ("Something is wrong here...");
}
}
}
and when i try to javac it, i get this:
C:\Users\Owner>javac -g "C:\Users\Owner\Desktop\codes\codes\Startbat.java"
C:\Users\Owner\Desktop\codes\codes\Startbat.java:6: error: <identifier> expected
catch (IOException) {
^
1 error
I have found that the error I get is about the catch line/block not being in a method, when I have definitely made sure that it IS within the main.
I had a few error with the exception there, but i guess i solved it. i don't know what the exception would have been ((meaning how would that IOException occur from the runtime.exec stuff) meaning does that mean it won't start the batch file if it does get to work?).
Any help would be appreciated, even if its just "This is impossible to do"
You need to specify a variable for the exception, so you can use it later, for example...
catch (IOException exp) {
You should also consider printing the exception, at least to the console if not some kind of logger...
catch (IOException exp) {
ex.printStackTrace();
//...
This will make it easier to track down potential problems if/when they occur.
As a side note, you really should use ProcessBuilder instead of Runtime.exec, apart from anything else, it provides better management of the output streams and agruments that contain spaces...

How do I extract a stacktrace from threads in Eclipse?

I'm very confused with handling errors on runnables passed to a threadpool.
I am doing everything by the book (literally, I'm adhering to Goetz' "Concurrency in Practice") and I'm not capturing any errors that Eclipse is showing me, and I'm getting weird NoClassDefFoundErrors even though my buildpath looks fine.
I tried killing my local repo and recloning it to get a fresh project build, but still getting the error. And none of my try-catches or System.out.println's are working either. Is there any way Eclipse can give me a better view of the error? Or a way to actually get the error handler's to work?
//ThreadPool and runnable that is failing, even with error captures
MyPriorityThreadPool.execute(new RunWithPriority(priority) {
Throwable thrown = null;
#Override
public void run() {
try {
batch.buildData();
} catch (Exception e) {
thrown = e;
}
finally {
if (thrown != null) {
thrown.printStackTrace();
}
}
}
});
}
I'm not quite sure what you're trying to accomplish, but the reason you're not catching the NoClassDefFoundError in your code is that you're catching Exception instead of Throwable or Error. Exception is more specific than Error and not what NoClassDefFoundError inherits from, so NoClassDefFoundError isn't caught by your catch expression.

#throws in Scala does not allow calling Java to catch correct exception type

I have some Scala code like this:
class Callee {
#throws(classOf[MyCheckedException])
def doStuff() {
}
}
Calling it from Java like so:
public class Caller {
public static void main(String[] args) {
// this won't compile; the Java compiler complains that the catch block is unreachable
// however without the catch block, it complains "unhandled exception MyCheckedException"
try {
new Callee().doStuff();
}
catch (MyCheckedException e) {
}
}
}
Removing the catch block results in an error from the Java compiler saying 'unhandled exception type MyCheckedException'. Adding the catch block for MyCheckedException results in the compiler complaining about the catch block being unreachable, because the exception is never thrown.
If I catch Exception and do an instanceOf, I can trap the correct exception coming out of doStuff, but I thought the #throws annotation was supposed to generate the right bytecode for the proper catch block to work. Am I wrong, or is there a bug here?
For the record, this is with Scala 2.9.2 and Java 1.6.
Edit: It compiles fine invoking javac/scalac using sbt from the command line. The error is only apparent during compile-as-you-type in Eclipse, which suggests the bug is in either the Eclipse Java Compiler or some part of the IDE. Can others reproduce it this way? I am using Eclipse 3.7.2
I can reproduce this on Helios with 2.9.1. It is a bug in the presentation compiler, and you should raise it as a bug on http://www.assembla.com/spaces/scala-ide/tickets.
For future reference, this issue has been fixed (https://github.com/scala-ide/scala-ide/commit/055a81cd3fe792e4327668791888c30cf04793f5). The fix is already available with both Scala IDE 2.0.x and Helium nightlies.
Furthermore, it will be included in the next Scala IDE 2.0.2 maintenace release.
(sorry for the additional noise, but I realized that having an answer was more visible than a simple comment)

Having issues decompiling *any* class with Jode

I've been staring at this issue for hours now. Any help is appreciated.
I wrote code that uses the Jode decompiler from the "embedded jode jar file". I want to use this version because it is under the Lesser GNU Public License.
Decompiler d = new Decompiler();
try {
FileWriter fw = new FileWriter("c:\\jode.txt");
d.setClassPath("C:\\mycode");
ProgressListener p = new ProgressListener() {
public void updateProgress(double arg0, String arg1) {
System.out.println("inside of progress listener with arg0 = " +arg0+ " and arg1 = " +arg1);
}
};
d.decompile("Test.class" , fw, p);
} catch (Exception ex) {
ex.printStackTrace();
}
and I always get :
Exception in thread "main" java.lang.NoClassDefFoundError: Test.class
at jode.bytecode.ClassInfo.loadInfo(ClassInfo.java:620)
at jode.decompiler.ClassAnalyzer.<init>(ClassAnalyzer.java:86)
at jode.decompiler.ClassAnalyzer.<init>(ClassAnalyzer.java:123)
at jode.decompiler.Decompiler.decompile(Decompiler.java:191)
at testdecompiler.Main.main(Main.java:45)
If I use
jode.decompiler.Main.decompile(...)
things work - but I can't use this class file because it resides in the jode.jar that is only GPL.
I was able to reproduce the problem with all of the different binary versions of jode that are available from their web site. When I built a new version of jode using the mainline from svn, it worked fine. I also saw an entry in one of the jode forums where a user was complaining about the NoClassDefFound problem. His case sounded slightly different, but the jode developer suggested that he use the mainline from svn instead of the prebuild binary.
d.setClassPath("C:\\mycode");
This classpath looks awfully short to me.
This is a guess, as i don't fancy myself with decompiling classes, but i think that u should use
d.decompile("Test" , fw, p);
instead of what u are using now. This could be similar to
Class.forName("ClassName")
without the "class" suffix.
Update: My original assumption was wrong, and to bad, the original exception/ message is thrown away, as far a i can see. The code where JODE fails looks like this:
try {
DataInputStream input = new DataInputStream
(new BufferedInputStream
(classpath.getFile(name.replace('.', '/') + ".class")));
read(input, howMuch);
} catch (IOException ex) {
String message = ex.getMessage();
if ((howMuch & ~(FIELDS|METHODS|HIERARCHY
|INNERCLASSES|OUTERCLASSES)) != 0) {
throw new NoClassDefFoundError(name);
}
Since an IOException has to be thrown to get the NoClassDefFound, check anything regarding your IO subsytsem, e.g. the file.encoding. I guess you should patch JODE to get the detailed error message or debug to this point.

Categories

Resources