0

I try to get information via Scala from this website: https://hypixel-api.inventivetalent.org/api/skyblock/bosstimer/magma/estimatedSpawn

I tried with a few methods but mostly the only respons I get is java.security.AccessControlException: access denied stuff.

It would be helpful if someone could give me a good library for json and could tell me how to get the json from this website.

Complete Exception:

Exception in thread "Thread-19" java.security.AccessControlException: access denied ("java.net.SocketPermission" "hypixel-api.inventivetalent.org:443" "connect,resolve")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
    at java.security.AccessController.checkPermission(AccessController.java:886)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.SecurityManager.checkConnect(SecurityManager.java:1051)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:541)
    at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
    at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1570)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
    at java.net.URLConnection.getContent(URLConnection.java:739)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getContent(HttpsURLConnectionImpl.java:448)
    at java.net.URL.getContent(URL.java:1071)
    at CastBotPlugin.foo$1(CastBotPlugin.scala:196)
    at CastBotPlugin.$anonfun$magmaBoss$1(CastBotPlugin.scala:203)
    at java.lang.Thread.run(Thread.java:748)
MelanX
  • 51
  • 1
  • 6

1 Answers1

1

This is not related to Scala but to the Java security policy, this could happen if you are running your app in a controlled environment, if you control the environment, you can likely update the policy.

We could give you more detailed help if you post the complete exception.

Related question: java.security.AccessControlException: Access denied (java.io.FilePermission

AlexITC
  • 1,054
  • 1
  • 10
  • 21
  • Thank you for this answer! I added the complete exception. I will read the related question now :) – MelanX Aug 24 '19 at 15:20
  • As you see, your problem is not about getting the JSON from a URL but dealing with the security manager, are you getting this locally or while deploying to a server? – AlexITC Aug 24 '19 at 15:53
  • I would say locally. I use ChatOverflow as framework and write a plugin where I need to get the json from this url. But yes, the security manager doesn't let me in :( – MelanX Aug 24 '19 at 15:58
  • Unless you set up the security manager which I think it is unlikely, it may be related to the JDK version you are using, please post that one and your operating system details. – AlexITC Aug 24 '19 at 16:11
  • I use JDK 1.8.0_221 on Windows 10 Pro 64bit and was coding in IntelliJ Community 2019.2 – MelanX Aug 24 '19 at 16:14
  • Try what's on this thread: https://stackoverflow.com/questions/37483618/how-to-solve-java-security-accesscontrolexception – AlexITC Aug 24 '19 at 16:50
  • I did and restarted the computer but it didn’t work like expected – MelanX Aug 24 '19 at 18:46
  • Sadly, I can't reproduce your issue to help you better, I would try downloading a different JDK version and removing the current one. – AlexITC Aug 25 '19 at 01:05