skgrange / saqgetr

Import Air Quality Monitoring Data in a Fast and Easy Way
GNU General Public License v3.0
9 stars 3 forks source link

Conflict with Java #9

Closed SverreSolberg closed 11 months ago

SverreSolberg commented 1 year ago

Hi, your package is great for retrieving EEA data but I have encountered a mysterious bug: There seemes to be some sort of Java conflict when using the package. This took me a while to trace down, but now I have identified the place in the code that creates an error. With a simple call like this: allsites <- `get_saq_sites()` and then, later: lons = seq(-39.5,39.5,1) lats = seq(45.5,64.5,1) bg = read_osm(bb(c(min(lons),min(lats),max(lons),max(lats))), type='osm') I get a long error message: **Error in .jcall("java/lang/Class", "Ljava/lang/Class;", "forName", cl, : Unable to start conversion to UTF-16 Error in h(simpleError(msg, call)) : error in evaluating the argument 'Class' in selecting a method for function 'new': class not found Error in .tryJava() : Java classes could not be loaded. Most likely because Java is not set up with your R installation. Here are some trouble shooting tips:

  1. Install Java (for mac consider installing java 1.6 from https://support.apple.com/kb/DL1572?locale=en_US )
  2. Run R CMD javareconf in the terminal. If you are using Mac OS X >= 10.7 you may want to try R CMD javareconf JAVA_CPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers instead.**

If I leave out the call to get_saq_sites there I get no error message,

Earlier, I got a similar error message in other programs, and then managed to solve it ny the recipe given on this web page: [ https://www.geeksforgeeks.org/how-to-set-java-path-in-windows-and-linux/]

I have done the same now, but it seems that just a basic call to the saqgetr package leads to the Java error. So there seem to be some conflicting java stuff in your package. I really hope you find a fix for this as I'm a bit stuck

skgrange commented 1 year ago

Hello, This is quite a strange error and I do not think it is an issue with the saqgetr package. The saqgetr package has no Java dependencies and the function that seems to be erroring (read_osm) is not part of the saqgetr package. This suggests that the issue is located elsewhere. It is possible that a call to get_saq_sites is causing conflicts downstream, but such an issue would most likely be caused by code outside saqgetr.

You seem to have an issue with your system's Java installation which could be throwing errors in certain situations. I would recommend confirming that read_osm or other functions in your script/programme are not raising errors and testing your script/programme on another system that does not have a Java installation that may have been inadvertently corrupted. I hope this gives you a plan to get to the bottom of your issue.

SverreSolberg commented 1 year ago

Hi, many thanks for your reply. You are right that the problem was caused by the combination of saqgetr and the OpenStreetMap library (using the read_osm function. I have now avoided this since I found out that I can skip the call to read_osm. There seems to be Java problems on my system, yes. For example: If I first ran an R prog using read_osm without the saqgetr, it worked fine. Then I ran the code with saqgetr that crashed, and then if I tried the first prog once again that also crashed with the same Java error. These things are difficult to trace down ...

skgrange commented 1 year ago

Yes, if you have intervened with your Java installation, this alone suggests something is not quite right. Why this translates into your R environment is a bit of a mystery though! There is always a reason for these errors, but as you say, they can be tough to track down!