java.lang.NullPointerException: Cannot invoke "java.net.URL.getPath()" because "url" is null
Opened this issue · 30 comments
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.net.URL.getPath()" because "url" is null
at HereApi.HereTrafficV7.getToken(HereTrafficV7.java:186)
at HereApi.HereTrafficV7.update(HereTrafficV7.java:262)
at Here2Osm.main(Here2Osm.java:23)
Any idea on how i can fix this?
You likely, have not create the "credentials.properties" file.
Cf.: https://github.com/FraunhoferIVI/openlr/blob/master/SETUP.md#HERE-Api-Key
It is recommended to go through the steps described in SETUP.md before trying to run the script.
I followed all the steps, got the credentials.properties file and I keep getting that error everytime, i put the file in the folder called target, is that correct?
This looks correct to me. Did you run java -jar target\here2osm.jar
from folder C:\Program Files\PostgreSQL\OpenLr\openlr-master
?
Can you also try to run java -jar here2osm.jar
from C:\Program Files\PostgreSQL\OpenLr\openlr-master\target
This fixed the issue, now I need to figure out how to make it work on my side. I think it's because I just enabled the freemium api.
6695 [main] INFO HereApi.ApiRequest - request-URL: https://data.traffic.hereapi.com/v7/flow?locationReferencing=olr&in=bbox:33.835,47.254,33.197,47.262
7182 [main] ERROR HereApi.ApiRequest - GET Request failed
7183 [main] INFO HereApi.ApiRequest - request-URL: https://data.traffic.hereapi.com/v7/incidents?locationReferencing=olr&in=bbox:33.835,47.254,33.197,47.262
7480 [main] ERROR HereApi.ApiRequest - GET Request failed
7594 [main] INFO org.jooq.Constants -
I just made another commit: 80ec067
This should lead to more verbose/specific logging in case of failing GET-Requests.
Can you pull
again, maven install
again and then run java -jar here2osm.jar
again?
Error.txt
This is what I get now, the new commit fixed the other issues, also I recommend adding that you should not tick "Allow access only in this project" on the Here platform, that gave another error after retrying today.
Error.txt This is what I get now, the new commit fixed the other issues, also I recommend adding that you should not tick "Allow access only in this project" on the Here platform, that gave another error after retrying today.
I think the reason for this error is the bounding box that you specify.
If I try to run curl -H "Authorization: Bearer YOUR_TOKEN" "https://data.traffic.hereapi.com/v7/flow?locationReferencing=olr&in=bbox:13.400,52.500,13.405,52.505"
, I am getting a proper reply from the HERE servers:
but when I try to run curl -H "Authorization: Bearer YOUR_TOKEN" "https://data.traffic.hereapi.com/v7/flow?locationReferencing=olr&in=bbox:27.281,47.061,27.411,47.131"
Thus, I would recommend to use a different bounding box. The order of the bounding box is expected to be: long_min, lat_min, long_max, lat_max
I tried with a different bounding box, i checked again to be sure that the order is correct and everything is ok on this side but i keep getting this error:
Exception in thread "main" java.lang.UnsupportedOperationException: JsonNull
at com.google.gson.JsonElement.getAsString(JsonElement.java:179)
at HereApi.FlowJsonParser.parse(FlowJsonParser.java:85)
at HereApi.HereTrafficV7.update(HereTrafficV7.java:323)
at Here2Osm.main(Here2Osm.java:23)
Can you try to run curl -H "Authorization: Bearer YOUR_TOKEN" "https://data.traffic.hereapi.com/v7/flow?locationReferencing=olr&in=bbox:long_min,lat_min,long_max,lat_max"
from the command line and check the result? I am assuming the reason of the error not in the code, but in the result delivered by the here api to it.
do i run it in the target folder or it doesn't matter?
C:\Program Files\PostgreSQL\openlr-master\target>curl -H "Authorization: Bearer YOUR_TOKEN" "https://data.traffic.hereapi.com/v7/flow?locationReferencing=olr&in=bbox:27.280,47.060,27.285,47.065"
curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.
Btw: the coordinates you specify relate to a rather rural region in eastern romania, where HERE might not have any traffic flow data that they can provide. Is this really the region you are interested?
It worked, the coordinates were ok, i reverted to the initial ones, i created a new token and i disabled the antivirus and it worked, the issue was caused because the antivirus was blocking the connection for some reason. Thank you for the help, now I can use it in Qgis!
I got the result, how can i add the information into the database?
since with java -jar here2osm.jar its still not working even though with curl it works just fine
since with java -jar here2osm.jar its still not working even though with curl it works just fine
Can you specify more detailed what is not working? Which error message do you get when running java -jar here2osm.jar
and which result do you get when running via curl
?
It worked, the coordinates were ok, i reverted to the initial ones, i created a new token and i disabled the antivirus and it worked, the issue was caused because the antivirus was blocking the connection for some reason. Thank you for the help, now I can use it in Qgis!
Great to here this. I was not aware that an Antivirus protection could be a problem.
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.length()" because "s" is null
at java.base/java.io.StringReader.(StringReader.java:50)
at HereApi.FlowJsonParser.parse(FlowJsonParser.java:83)
at HereApi.HereTrafficV7.update(HereTrafficV7.java:323)
at Here2Osm.main(Here2Osm.java:23)
I get this from java
curl.txt
and this from curl
The result from the direct curl call seems to be good. For the java part, it would be interesting to have the full log file as well. There must have been an error before the error that you posted.
Are you using the same token for curl and for java?
java error.txt
for java i just ran the command from setup: java -jar here2osm.jar
As you can see in the error.txt:
9289 [main] ERROR HereApi.ApiRequest - GET Request failed. Status code: 403
9291 [main] ERROR HereApi.ApiRequest - Response from server: {"error":"Forbidden","error_description":"These credentials do not authorize access"}
Your credentials do not allow access to the server.
You need to make sure that you use the same token that works for the curl request also for the java request. The credentials.properties
may need to be updated for this. Perhaps you may even need another token from HERE. You can test, if the token works with using curl.
java_new.txt
curl_new.txt
Got new credentials, I guess it worked but the layer is empty when importing in Qgis
java_new.txt curl_new.txt Got new credentials, I guess it worked but the layer is empty when importing in Qgis
At least the Java code now is trying to process a proper response from the HERE API.
Now the program says:
Could not decode olr code: CCkBEAAlJBOcPyGJdQAJBQQEA5IACgUEBIETAP+h/40ACQUEBAMVADAAAA==
This means it cannot map the OpenLR code given from HERE to the data in your database. It is difficult to say, why this happens, without looking at your database. Can you make sure that your database covers the same region that you are querying in the request?
If this is the case and it still does not work, I would recommend to try the Hamburg example that is described in the setup procedure and see, if you get this to work, since we know for sure that for this region, it has been working in the past.
My database is the entire Romania file and I didn't use a clipping box, I used the entire file, maybe that could be an issue?
My database is the entire Romania file and I didn't use a clipping box, I used the entire file, maybe that could be an issue?
Not clipping should not be an issue. However, so far, we only tested with smaller regions, e.g. city of Hamburg (Germany). It would be interesting to know, if the Hamburg example works for you.
I'll try the exemple today or later tomorrow and I'll come back with a reply