-
Notifications
You must be signed in to change notification settings - Fork 31
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
Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), : java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "<parameter1>" is null #399
Comments
Tried Florida and Miami GTFS. Problem persists. |
Java version: |
@luyuliu , thanks for opening the issue. Could you please share the links where I can download the exact OSM .pbf and GTFS feeds ? |
Thanks for the help! OSM: https://download.geofabrik.de/north-america/us/ohio-latest.osm.pbf |
Hi @luyuliu . Thanks for sharing those links. I could not replicate your error. I was able to build the network and calculate a travel time matrix by transit without any problem. See code below. reprex using the data downloaded from the links you shared
|
I ran Your Java version is:
while I have:
This is a really minor difference, so I don't think this should be the cause of the problem. So I'm suspecting this might be related with that Java version that is being picked by R. Could you please run the code snippets below and share the output you get? 1. checking Java version with rJava
2. checking Java version with rJavaEnv rjava
3. checking Java version with rJavaEnv cmd
4. Windows cmdOn your Windows command line, run:
|
Please find the results below.
where java wouldn't return a location. Don't know why. |
Hmm... The test number 1 is the test that {r5r} runs internally to check the Java version in the user machine. So the result is expected. Good. The result from {rJavaEnv} is a bit strange because it detects the JAVA_HOME, but at the same time it prints the messge |
I reinstalled java with the recommended build and the problem persists. I suspect it has something to do with the rJava library like you said. |
Another minor thing but I want to report it anyway. I am running the instance on a new workstation which has 2 CPU sockets. The R always reports that because the virtualizations setting it cannot fully used all the cores it has. May be irrelevant but want to solve this too later. |
A few comments on the points discussed aboveI am not sure this is a problem with the specific Java version or flavour. I have manually setup this "21.0.4.7-hotspot" version of Java by Microsoft on a Windows server I have access to and compared it to the Amazon Corretto Java activated via
You are probably running
I'm not sure if this issue is specific to this particular flavour of Java from Microsoft. With Amazon Corretto Java I don't get this warning, but that does not of course mean that is is not affected. And I also do not have a system with two sockets. My tests show that the code above for Ohio runs exactly at the same speed for the graph preparation part with either flavour of Java. Though as
Thanks for catching this error. I will work on rJavaEnv to handle slightly different output of command line Java. Though at this point rJavaEnv is only supposed to work with Amazon Corretto.
This must be some edge case with a Java version from Microsoft, where I have not tested the type of output it provides. Because the manual check via === From my side, I may suggest the following troubleshooting attemptVery important. Make sure you run this code in a clean R session and you have NOT yet done library(rJavaEnv)
use_java(21)
# this will silently install Amazon Corretto Java 21 and activate it
# in current R session only. This effect will be reset once you restart R session
options(java.parameters = '-Xmx12G')
library(r5r)
data_path <- '<YOUR_DATA_PATH>'
# build network
r5r_core <- r5r::setup_r5(data_path,
overwrite = TRUE,
verbose = TRUE) |
@luyuliu One other thing I would suggest is to try running on the same machine using the same code as I pasted above, but from a Rocker Docker ( https://rocker-project.org/ ) container, if you have necessary rights to run Docker on your machine. |
Thank you for the extensive analysis @e-kotov . I reinstall R and try to reinstall rJava. But it returns an error saying the function use_java is unavailable.
I will try a docker environment later but I hope to solve this in a non-docker environment since there could be negative implications on the performance. And hassles. I want to have docker as the last resort. |
Oh and IT policies. Our university is strictly enforcing a white list policy, which I do not agree with. I need to consult our IT person before installing anything on this machine. |
@luyuliu sorry, my bad, I meant "rJavaEnv" not "rJava". Fixed the code above. Please make sure to install latest "rJavaEnv". |
Okay, the first solution still won't give a positive result. The .dat file is still nowhere to be found. But, good news is that the second command now can retrieve a valid env. So the suggestion is helpful
Now I think there are some subtle different behaviors, like the size of the p file will be slightly larger. And when rerun the setup_r5 will instantly finish (but still won't output dat file) |
I guess I may need to do a complete reinstallation for R and some packages, since I know some packages may be stored in the personal folder so the normal uninstallation of r may not remove those. I will try that again. |
@e-kotov , thanks so much for your help. While reading the discussion above, it is clear to me that the fact that @luyuliu is able to run the reproducible example with r5r's sample data is actually a good sign that this issue is not casused by the Java version or by possiblity of R not picking up the right Java version. This must be something else. I just remembered one case another user had some time ago. She had a similar issue in that |
Thanks for the suggestion. I changed the work folder to D drive and the problem persists. Hmmm. I am running an administrator account, so this should not be a problem. |
Just to test the write privilege: I tried to output a csv file in R studio command line and the csv file was created successfully points <- read.csv(paste(c(base_data_path , "\od_points.csv"), collapse="")) |
I am going to paste my test code here just in case. ` mode <- c("WALK", "TRANSIT") r5r_core <- setup_r5(data_path = base_data_path) |
Ok. thanks for the feedback. It's still a puzzle to me why I cannot replicate the error you get. Could you try it in another computer? perhaps on your personal laptop? |
Regarding this code here, @luyuliu , two quick suggestions:
|
Okay, I tested on my personal laptop and it went through. I think I am going to do a total clean reinstall of r and rstudio, since I do not install r but the IT does. I think it may messed up some dependency on the library side. I also notice that on the workstation side I never received those warning message: 2024-09-22 11:13:57,077 [main] ERROR c.c.r.s.StreetLayer - Restriction 14333081 has no restriction tag, skipping Which indicates that it may never reach the point to actually construct the network. So weird. |
If there was no write access, p and mapdb would not be created. @rafapereirabr r5r/java-r5rcore/src/org/ipea/r5r/Network/NetworkBuilder.java Lines 68 to 70 in 934c4ac
So this could be the point of failure (for whatever reason), which is still weird given that the example from the tutorial works fine. @luyuliu are you getting the network_settings.json file, or is it also missing? @luyuliu I would not expect a too significant performance hit (especially if you have a lot of cores) if you run it through Docker. |
@luyuliu your i get the same log messages as you do using your data files. Here's a full log for reference. Even with all these warnings, I get the network.dat file. |
Yes, R5 prints lots and lots of Error messages but these shoul really be just warning messages as they do not hinder bulding the graph. So these messages can be ignored in general. That's why the default behavior of |
network_settings.json is also missing. Yeah I think we are seeing the same. I deleted all the libraries in AppData/Local/R and reinstall R. Still have the same issue... See my warning message below. Really lost now. |
For the sake of science i just copied the work folder to C:\Users\lzl0116\AppData\Local\R\win-library\4.4\r5r\test_run. Just hoping it's a privilege issue but looks like no. Still have no dat file created. Hmmm. |
@rafapereirabr here it is, @luyuliu 's log does not have messages on So there must be some problem internally in R5... I guess. @luyuliu I would strongly recommend trying Docker if you can. At least you will be trying using Linux on the same hardware and then we'll be able to rule out the hardware (if that is even possible) incompatibility. @luyuliu your log is incomplete, there is no beginning like this:
I am wondering, how many edges you get when the file is first loaded. When I look at your log, I see:
In my log:
I have many more edges. So I am wondering... What if, @luyuliu your pbf file is just an incomplete/broken download? Can you try to redownload this file (maybe also the gtfs.zip for good measure, though this one is probably ok, as I would expect R5 to fail on broken zip). |
The broken pbf is a valid hypothesis. It is also compatible with the fact that @luyuliu was able to run the code on his personal computer but not on the workstation at Uni. |
FYI (for pbf file I downloaded today on 2024-09-22): tools::md5sum("data/ohio-latest.osm.pbf")
data/ohio-latest.osm.pbf
"0ac122403520e97b4d3cc2285432c160" update: file.size("data/ohio-latest.osm.pbf")
[1] 256250570 |
Okay! I had some progress:
Different, but weird, since this is the one that actually succeeded. Must be OSM fairy doing magic work here.
Thank you for the help! Enjoy your weekend! |
@luyuliu Great to know that it somewhat resolved for you! It does seem like the issue likes in something that osmosis does during the processing... |
Attaching the osmosis code: osmosis --rb ohio-latest.osm.pbf --bounding-box left=-83.138667 right=-82.847642 bottom=39.870147 top=40.117322 --wb columbus.osm.pbf |
And network file for your reference |
Did another run with the Columbus pbf on personal PC. Also failed to generate DAT file. So I guess this is the potential cause. But, this cannot address the issue we had earlier with Ohio and Florida weight. Which operation I did solved that? I honestly am so lost right now lol. Meanwhile, the prompt we had is kinda confusing too. It would be the best if we have a mechanism to report .dat file output failure. Maybe just add a message here like @e-kotov has pointed out? r5r/java-r5rcore/src/org/ipea/r5r/Network/NetworkBuilder.java Lines 68 to 70 in 934c4ac
|
yep, I forgot to suggest that too. Perhaps here: Line 178 in 934c4ac
just before this line it would make sense to add some code that checks if the file was actually created and provide a different message if it wasn't. Possibly, suggesting to the user that the pbf file might be corrupt. |
@luyuliu It seems like it may have a more robust handling of cropping with its different extract strategies, while osmosis does not seem to even describe how it crops the data. I would then assume that osmosis does a very rough crop, right by the bbox boundary, while osmium acts smarter and therefore is less likely to damage the pbf, at least for it to be useful in R5. |
@luyuliu , I would suggest trying our {rosmosis} package. |
But it's just a wrapper around command line utility and if it somehow damages the pbfs, the using it through the package will not make a difference. When I say "damage", I mean that probably in this case the selected bounding box turned out to be a bad choice that produced some invalid geometries in linestrings. However, it seems like osmium's strategies for smarter cropping would probably prevent this. The downside of osmium is that it's not available for Windows, but you can run it through Docker (if you can on your work machine). |
yep, {rosmosis} is a wrapper around command line utility. I was suggesting it just for the sake of convenience :) |
Thanks for the suggestion. I will see what I can do with osmium. Closing the issue now. |
thank you both for the discussion ! |
Sorry for raising the same issue again; I read the same issue posted several months ago, but I am experiencing exactly the same when setting up a new environment here in a new machine.
Using pbf directly downloaded from Geofabrik and an official GTFS files from Columbus. No network file created despite outputting "Finished building network.dat at xxx/network.dat". pbf.mapdb and pbf.mapdb.p files are created though.
I tried both the stable version and the dev version, both giving me the same message. But the test data and code works. No idea how it happened. Attaching environment for reference:
$r5r_package_version
[1] ‘2.0’
$r5_jar_version
[1] "7.1"
$java_version
[1] "21.0.4"
$set_memory
[1] "-Xmx32G"
$session_info
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8
time zone: America/Chicago
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] r5r_2.0 rJava_1.0-11
loaded via a namespace (and not attached):
[1] compiler_4.4.1 backports_1.5.0 tools_4.4.1 data.table_1.16.0 checkmate_2.3.2
The text was updated successfully, but these errors were encountered: