Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8.9] OkHttp crushing the client?


Bets
 Share

Recommended Posts

Hello there!

 

I tried loading JSON data to my mod using OkHttpClient. for some reason when the client loads it just crushes itself. I checked what is causing this and this line was the problematic one (99% certain).

public static OkHttpClient APIClient = new OkHttpClient();

 

Do you guys know why is this happening? and maybe how can I fix this? thanks!

Link to comment
Share on other sites

What do you mean by "crush"? Is the client crashing? Is it freezing?

 

Post the code where you use the client. If it's crashing, post the crash report as well.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

10 minutes ago, Choonster said:

What do you mean by "crush"? Is the client crashing? Is it freezing?

 

Post the code where you use the client. If it's crashing, post the crash report as well.

 

By crashing I mean this, and the only like that is causing this is the line I sent up there, for sure.

 

report:

Caused by: java.lang.NoClassDefFoundError: okio/BufferedSource
    at okhttp3.internal.Util.<clinit>(Util.java:48)
    at okhttp3.OkHttpClient.<clinit>(OkHttpClient.java:122)
    at me.mods.testingForge.this.that.<clinit>(that.java:14)
    at me.mods.testingForge.mainClass.preInit(mainClass.java:14)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:560)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
    at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
    at com.google.common.eventbus.EventBus.post(EventBus.java:275)
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211)
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
    at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
    at com.google.common.eventbus.EventBus.post(EventBus.java:275)
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:556)
    ... 16 more
Caused by: java.lang.ClassNotFoundException: okio.BufferedSource
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 47 more
Caused by: java.lang.NullPointerException
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182)
    ... 49 more

 

Screenshot_1.png

Link to comment
Share on other sites

5 minutes ago, Bets said:

Caused by: java.lang.NoClassDefFoundError: okio/BufferedSource

 

OkHttp depends on Okio, which you don't have.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

2 hours ago, diesieben07 said:

May I suggest a more practical solution? Minecraft already depends on Apache's HttpClient, there is no need to ship your own library for it.

 
 

Yeah well I am not familiar with it very much so I'll use this one for now.

 

Oh and for some reason when I run the Client it's not loading the JSON for me, but when I run the class but it's own it does.

Do I need to somehow add the functions of the class to the mod? by

Quote

@EventManager

 

Maybe?

Link to comment
Share on other sites

53 minutes ago, diesieben07 said:

I am not sure what you mean, please show your code.

 
 

Well inside a second class file I have I use a public static void function - for some reason, it just won't run when I run the Client. It does run only when I run the class file alone.

public static void main(String[] args) {
   System.out.println("Is this working?");
}

 

Edited by Bets
Link to comment
Share on other sites

2 minutes ago, Bets said:

Well inside a second class file I have I use a public static void function - for some reason, it just won't run when I run the Client. It does run only when I run the class file alone.


public static void main(String[] args) {
   System.out.println("Is this working?");
}

 

Uh yeah. Because that's a Main function, as in the first method that the JVM invokes, except that the main class that the JVM is invoking is GradleStart, calling Main(args) there.  Which means YOUR method is not called.  Just because it's public and static doesn't mean it gets invoked.

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

2 minutes ago, Draco18s said:

Uh yeah. Because that's a Main function, as in the first method that the JVM invokes, except that the main class that the JVM is invoking is GradleStart, calling Main(args) there.  Which means YOUR method is not called.  Just because it's public and static doesn't mean it gets invoked.

 

 

So I need to invoke it from the main class? if so how can I do that :P

Link to comment
Share on other sites

How about you not make a Java Main method and use the Forge init events?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

3 minutes ago, Draco18s said:

How about you not make a Java Main method and use the Forge init events?

 

Well, I'm a little new to Forge so I'm not sure how exactly to do that! but I have an FMLPreInitializationEvent in my main class, is that it? it's registering an event_bus to the other class I have there.

Link to comment
Share on other sites

4 minutes ago, diesieben07 said:

Ehm... what?

 

How can I basically make the function work xD because I have one that has a @SubscribeEvent above it. and it works. So should I just do the same to this one or there's something else there?

Link to comment
Share on other sites

Just now, diesieben07 said:

I don't know what you mean by "work" and I don't know what you want to achieve. I linked you the documentation about loading stages, that is how your mod "starts up".

 
 

By work I mean make the function run. because currently it's just sitting there and doing nothing.

 

I did make an other function that works in the same class, this is the working one:

@SubscribeEvent
public void onRenderText(RenderGameOverlayEvent.Text e) {
//RENDER SCREEN TEXT HERE
}

 

So how can I make the second one to work like this too? I changed the name of the function before from main to something else, but how can I get Forge to recognize it and run it.

Link to comment
Share on other sites

You mean, register an event handler?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

11 hours ago, diesieben07 said:

When do you want it to run, is the question.

 

Probably everytime you join a specific server.

 

8 hours ago, Draco18s said:

You mean, register an event handler?

 

Will that make it run when you join a specific server like I said before? (or even work at all? I just need to check if it loads the JSON when you use the Client) O.o

Link to comment
Share on other sites

1 minute ago, diesieben07 said:

Probably? Well, to detect when you join a server you can use ClientConnectedToServerEvent on the client or PlayerLoggedInEvent on the server. It depends on what you want to achieve which one to choose.

 

Oh! this makes sense lol, will definitely try that! :P

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.