Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac only: Matlab cannot find Rdsamp java class #106

Open
dwuab opened this issue Jun 30, 2015 · 14 comments
Open

Mac only: Matlab cannot find Rdsamp java class #106

dwuab opened this issue Jun 30, 2015 · 14 comments
Assignees

Comments

@dwuab
Copy link

dwuab commented Jun 30, 2015

Mac OS X 10.10.3, wfdb-toolbox version: 0-9-10 and onward, MATLAB 2015a. This will not happen on Linux.
here is an output from wfdbdemo:

>> wfdbdemo
Reading samples ECG signal from MIT-BIH Arrhythmia Database
Warning: Downloaded WFDB cache file:
/Users/wudegang/wfdb-app-toolbox/database/mitdb/100.dat 
> In wfdbdownload (line 93)
  In rdsamp (line 111)
  In wfdbdemo (line 12) 
Warning: Downloaded WFDB cache file:
/Users/wudegang/wfdb-app-toolbox/database/mitdb/100.atr 
> In wfdbdownload (line 93)
  In rdsamp (line 111)
  In wfdbdemo (line 12) 
Warning: Downloaded WFDB cache file:
/Users/wudegang/wfdb-app-toolbox/database/mitdb/100.hea 
> In wfdbdownload (line 93)
  In rdsamp (line 111)
  In wfdbdemo (line 12) 
Error using javaObject
No class org.physionet.wfdb.jni.Rdsamp can be located on the Java class
path

Error in rdsamp (line 114)
    javaWfdbRdsamp=javaObject('org.physionet.wfdb.jni.Rdsamp');

Error in wfdbdemo (line 12)
[ecg,Fs,tm]=rdsamp('mitdb/100',1,N);
@dwuab dwuab changed the title mac: Matlab cannot find Rdsamp java class Mac only: Matlab cannot find Rdsamp java class Jun 30, 2015
@ikarosilva
Copy link
Owner

I think this is related to the RDSAMP JNI version only (which was optimized for speed). As a temporary solution, try not using the JNI RDSAMP by running instead:

[ecg,Fs,tm]=rdsamp('mitdb/100',1,N,x);

Where x can be any value besides the default ==0.

@ikarosilva ikarosilva self-assigned this Jul 16, 2015
@dwuab
Copy link
Author

dwuab commented Jul 16, 2015

@ikarosilva using

x=1;
[ecg,Fs,tm]=rdsamp('mitdb/100',1,N,x);

still gives the same error message:

Error using javaObject
No class org.physionet.wfdb.jni.Rdsamp can be located on the Java class path

Error in rdsamp (line 114)
    javaWfdbRdsamp=javaObject('org.physionet.wfdb.jni.Rdsamp');

Error in wfdbdemo (line 14)
[ecg,Fs,tm]=rdsamp('mitdb/100',1,N,x);

@ghost
Copy link

ghost commented Oct 15, 2015

Got the same error!

wfdbdemo
Reading samples ECG signal from MIT-BIH Arrhythmia Database
Error using javaObject
No class org.physionet.wfdb.jni.Rdsamp can be located on the Java class path

Error in rdsamp (line 114)
javaWfdbRdsamp=javaObject('org.physionet.wfdb.jni.Rdsamp');

Error in wfdbdemo (line 12)
[ecg,Fs,tm]=rdsamp('mitdb/100',1,N);

@sami10007
Copy link

How to do you set up your environment?

I can reproduce your problem if I initiate wrongly the environment. I do not know how you can restart your system without reinstallation.

My output is the same error messages as you have. My system OS X 10.11.4 and wfdb 0-9-10. This fact proposes me that if you have any mistakes in the initiation of the system such an output will result. I opened a new ticket #121 where I try to restore the system such that I can run more tests to reproduce your case.

@dwuab
Copy link
Author

dwuab commented Apr 27, 2016

@sami10007 Now I'm using OS X 10.11.4 as well. What I did and what I do is changing the current directory to~/Documents/MATLAB/wfdb-app-toolbox-0-9-10/mcode and running wfdbdemo.

@sami10007
Copy link

sami10007 commented Apr 28, 2016

I deleted path/mcode directory and initiated the system again, but still, I get the error. I run wfdbdemo and get

Reading samples ECG signal from MIT-BIH Arrhythmia Database
Error using javaObject
No class org.physionet.wfdb.jni.Rdsamp can be located on the Java class path

Error in rdsamp (line 114)
    javaWfdbRdsamp=javaObject('org.physionet.wfdb.jni.Rdsamp');

Error in wfdbdemo (line 12)
[ecg,Fs,tm]=rdsamp('mitdb/100',1,N);

I extended the case to the ticket #123 where I try to restore the system without changing the directory.
Did you change the directory in restoring your system?

@cx1111
Copy link
Collaborator

cx1111 commented Jul 1, 2016

I also got the error. I did manage to stop it but I still don't exactly understand what is going on. Backstory: A while ago, I first installed the stable release from physionet: https://physionet.org/physiotools/matlab/wfdb-app-matlab/

Running wfdbdemo I got:

Reading samples ECG signal from MIT-BIH Arrhythmia Database
Command exited with non-zero status!!
Error using rdsamp (line 178)
Java exception occurred:
java.lang.NullPointerException
    at
        org.physionet.wfdb.Wfdbexec.execToDoubleArray(Unknown
        Source)

Error in wfdbdemo (line 12)
[tm,ecg]=rdsamp('mitdb/100',1,N);

Running javaclasspath I get at the end:

DYNAMIC JAVA PATH

    /home/cx1111/Downloads/stable/wfdb-app-toolbox-0-9-9/mcode/wfdb-app-JVM7-0-9-9.jar

So it's not complaining about java objects or java class paths. I solved this by replacing the precompiled wfdb libraries in the mcode/nativelibs/linux/lib64 directory with ones I freshly compiled on my system from the wfdb software package:

cd mcode/nativelibs/linux/lib64/
rm *
cp /usr/local/lib/libwfdb* . 

Now wfdbdemo worked. The problem was that the compiled libraries distributed with the package were not suitable for my OS version.

Now I tried to install the latest github version:

git clone git@github.com:ikarosilva/wfdb-app-toolbox.git
cd wfdb-app-toolbox/mcode/

Running from matlab: wfdbdemo

Reading samples ECG signal from MIT-BIH Arrhythmia Database
Warning: Downloaded WFDB cache file:
/home/cx1111/Downloads/wfdb-app-toolbox/database/mitdb/100.dat 
> In wfdbdownload (line 93)
  In rdsamp (line 111)
  In wfdbdemo (line 12) 
Warning: Downloaded WFDB cache file:
/home/cx1111/Downloads/wfdb-app-toolbox/database/mitdb/100.atr 
> In wfdbdownload (line 93)
  In rdsamp (line 111)
  In wfdbdemo (line 12) 
Warning: Downloaded WFDB cache file:
/home/cx1111/Downloads/wfdb-app-toolbox/database/mitdb/100.hea 
> In wfdbdownload (line 93)
  In rdsamp (line 111)
  In wfdbdemo (line 12) 
Error using javaObject
No class org.physionet.wfdb.jni.Rdsamp can be located on the Java class path

Error in rdsamp (line 114)
    javaWfdbRdsamp=javaObject('org.physionet.wfdb.jni.Rdsamp');

Error in wfdbdemo (line 12)
[ecg,Fs,tm]=rdsamp('mitdb/100',1,N);

javaclasspath

DYNAMIC JAVA PATH

    /home/cx1111/Downloads/wfdb-app-toolbox/mcode/wfdb-app-JVM7-0-9-10.jar

So it is complaining about not finding the Rdsamp java class, but the dynamic java path has been set. I restart matlab and run wfdbdemo again:

Reading samples ECG signal from MIT-BIH Arrhythmia Database
Error using javaObject
No class org.physionet.wfdb.jni.Rdsamp can be located on the Java class path

Error in rdsamp (line 114)
    javaWfdbRdsamp=javaObject('org.physionet.wfdb.jni.Rdsamp');

Error in wfdbdemo (line 12)
[ecg,Fs,tm]=rdsamp('mitdb/100',1,N);

Still complaining about the java class. Once again I replace the precompiled libraries with the ones working on my system:

cd nativelibs/linux/lib64/
rm libwfdb*
cp /usr/local/lib/libwfdb* .

And now wfdbdemo works without complaints. So I don't really understand how replacing the libraries solved everything. I understand in my first case where at least it already got to running the compiled rdsamp and just failed to return a value to the java wrapper, so it was likely that the library file was faulty.
But this time, the complaint comes before the rdsamp binary could be called. Does the JAR file have some errors in its class names or something? I don't know Java so I can't really investigate this now. Let me know if this helps anyone and if you manage to solve this.

@dwuab
Copy link
Author

dwuab commented Jul 2, 2016

@cx1111 Intriguing! Actually I encountered the same problem described on CentOS (so it is not a Mac only problem any more) and I don't have root privilege on that machine. I did essentially the same thing as you described (I have no root privilege so I cannot install like you did), and it works!

However, wfdb software does not compile on Mac 10.11.5 (compilation error), so I cannot try the same thing on my Mac.

@dwuab
Copy link
Author

dwuab commented Jul 2, 2016

@cx1111 I managed to compile wfdb software on Mac with --without-netfiles flag (libcurl causes the compilation to fail on Mac), and then I copied /usr/local/lib/libwfdb* to nativelibs/macosx/bin. Does not work.

@phyrwork
Copy link

@cx1111 @samuelandjw Same here. Compiled 10.5.24 on macOS 10.12.3. Works fine without --without-netfiles (Xcode CLI tools installed for libs). Copied files from <build_dir>/{bin,lib} across to nativelibs/macosx/bin, no effect - still broken with same error.

@ikarosilva
Copy link
Owner

Hey Guys,

You actually don't need the org.physionet.wfdb.jni.Rdsamp. That's an unstable class that I was working on to make RDSAMP much faster (order of magnitudes) by implementing it on the Java Native Interface instead of going through MATLAB/JAVA/System Processes. I got the class to work with Linux and some Mac, but was having trouble compiling on Windows, so its unstable ( we can remove from the branch code).

Quick Fix:
If you want to have your code working right now modifu the following code in RDSAMP from:

if(isempty(javaWfdbRdsamp) && (rawUnits ==0))
javaWfdbRdsamp=javaObject('org.physionet.wfdb.jni.Rdsamp');
end

To the following:
if(isempty(javaWfdbRdsamp) && (rawUnits ==0))
warning("Option not available")
end

You may want to update the help on the function as well.

@phyrwork
Copy link

phyrwork commented May 15, 2017

@ikarosilva Brilliant, thanks. Just to add for others' reference:

warning() will complain if you pass it a string ("...") instead of a char array ('...'). I also set the default rawUnits = 1 to avoid needing to pass in all the arguments.

Would be nice if these changes could be added to master until JNI is stable - or documented.

@remolaz
Copy link

remolaz commented Nov 29, 2017

@ikarosilva Replacing

if(isempty(javaWfdbRdsamp) && (rawUnits ==0))
javaWfdbRdsamp=javaObject('org.physionet.wfdb.jni.Rdsamp');
end

To the following:
if(isempty(javaWfdbRdsamp) && (rawUnits ==0))
warning('Option not available')
end

I get this error then:
Struct contents reference from a non-struct array object.
Error in rdsamp (line 197)
data=double(conv_matrix(javaWfdbRdsamp.exec(wfdb_argument)));
Error in wfdbdemo (line 12)
[ecg,Fs,tm]=rdsamp('mitdb/100',1,N);

How can I solve this?
Thanks in advance for your help!

@hassanaqeelkhan
Copy link

I am having a similar issue while trying to install WFDB for MATLAB on Ubuntu 16.04. I think this problem arises due to the MakeFile in the mcode/nativelibs folder. This Makefile runs partially and succesfully downloads curl and the file 'ecgpuwave-1.3.3.tar.gz' and 'wfdb-10.5.25pre1.tar.gz'. However, it exits at line 338 of Makefile and prints an error (snapshot given below). I seems that it cannot find locate librdsampjni header file.

I did try the Quickfix suggested by ikarosilva and changed the javaWfdbRdsamp=javaObject('org.physionet.wfdb.jni.Rdsamp'); line to
warning("Option not available"). However, I still get an error (identical to that posted by remolaz). As a result the wfdbdemo still doesn't work for me.

Here are some of the messages i get before the make terminates

checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for java... java
checking for javah... no
checking for ... no
checking jni.h usability... no
checking jni.h presence... no
checking for jni.h... no
configure: error: JNI header files not found.
Makefile:338: recipe for target '/home/hak/Documents/MATLAB/WFDB/wfdb-app-toolbox-0-10-0/mcode/nativelibs/custom/build/librdsampjni.isconfig' failed
make: *** [/home/hak/Documents/MATLAB/WFDB/wfdb-app-toolbox-0-10-0/mcode/nativelibs/custom/build/librdsampjni.isconfig] Error 1

Any help will be highly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants