EsotericSoftware / kryonet

TCP/UDP client/server library for Java, based on Kryo
BSD 3-Clause "New" or "Revised" License
1.82k stars 419 forks source link

Can't build trunk from source using scar #34

Open ghost opened 10 years ago

ghost commented 10 years ago

From knightof...@gmail.com on May 08, 2013 11:32:43

After getting the following exception when attempting to use host discovery on OS X 10.6.8 (Snow Leopard):

00:31 ERROR: [kryonet] Host discovery failed. java.io.IOException: Invalid argument at java.net.PlainDatagramSocketImpl.send(Native Method) at java.net.DatagramSocket.send(DatagramSocket.java:625) at com.esotericsoftware.kryonet.Client.broadcast(Client.java:412) at com.esotericsoftware.kryonet.Client.discoverHosts(Client.java:455)

I found out that this is supposedly fixed in the kryonet svn trunk (r132), by surrounding the send methods with try / catch blocks. But the latest release 2.20, does not have this fix. So the only option available at this time appears to be checkout out the latest source from the svn trunk and build it myself. I finally figured out that I need to use Scar to build the library from source. So, I checkout the latest kryonet source (136) from the svn trunk, download the latest Scar release, cp scar and scar.jar into the kryonet source folder (directory containing project.yaml), and run ./scar. Here's what I get (highly edited for brevity): Aaron:kryonet Aaron$ ./scar 00:01 INFO: [kryonet] Target: /Users/Aaron/NetBeansProjects/target/kryonet/ 00:01 INFO: [kryonet] Clean 00:01 INFO: [kryonet] Compile /Users/Aaron/NetBeansProjects/kryonet/src/com/esotericsoftware/kryonet/KryoSerialization.java:6: package com.esotericsoftware.kryo does not exist import com.esotericsoftware.kryo.Kryo; ^ /Users/Aaron/NetBeansProjects/kryonet/src/com/esotericsoftware/kryonet/Connection.java:14: package com.esotericsoftware.minlog does not exist import static com.esotericsoftware.minlog.Log.*; ^ /Users/Aaron/NetBeansProjects/kryonet/src/com/esotericsoftware/kryonet/JsonSerialization.java:7: package com.esotericsoftware.jsonbeans does not exist import com.esotericsoftware.jsonbeans.Json; ^ /Users/Aaron/NetBeansProjects/kryonet/src/com/esotericsoftware/kryonet/Connection.java:61: cannot find symbol symbol : method trace(java.lang.String,java.lang.String) location: class com.esotericsoftware.kryonet.Connection if (TRACE) trace("kryonet", this + " TCP had nothing to send."); ^ Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 100 errors Exception in thread "main" java.lang.RuntimeException: Error executing code for project: kryonet at com.esotericsoftware.scar.Build.executeDocument(Build.java:413) at com.esotericsoftware.scar.Build.main(Build.java:433) Caused by: java.lang.RuntimeException: Error executing code: Build.build(project); Build.oneJAR(project); at com.esotericsoftware.scar.Scar.executeCode(Scar.java:1199) at com.esotericsoftware.scar.Build.executeDocument(Build.java:411) ... 1 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.esotericsoftware.scar.Scar.executeCode(Scar.java:1197) ... 2 more Caused by: java.lang.RuntimeException: Error during compilation. Source: 17 files Classpath: /Users/Aaron/NetBeansProjects/kryonet/lib/jsonbeans-0.5.jar, /Users/Aaron/NetBeansProjects/kryonet/lib/asm-4.0.jar, /Users/Aaron/NetBeansProjects/kryonet/lib/reflectasm-1.07.jar, /Users/Aaron/NetBeansProjects/kryonet/lib/minlog-1.2.jar, /Users/Aaron/NetBeansProjects/kryonet/lib/objenesis-1.2.jar, /Users/Aaron/NetBeansProjects/kryonet/lib/kryo-debug-2.20.jar at com.esotericsoftware.scar.Scar.compile(Scar.java:1010) at com.esotericsoftware.scar.Build.compile(Build.java:169) at com.esotericsoftware.scar.Build.build(Build.java:391) at Generated.execute(Generated.java from :10) ... 7 more Obviously it's not finding the libraries in the lib folder, which doesn't make any sense. I read a post on kryonet-users saying that all you (Nate) had to do was go to the kryonet directory and type scar. I tried to add the relevant entries to project.yaml, but I'm getting the same output no matter what I do. Can you please explain how to build kryonet from the latest source, using scar, without these errors? Thank you! Also, when are you going to be releasing the next version of kryonet with this bugfix, rendering this entire process unnecessary?

Original issue: http://code.google.com/p/kryonet/issues/detail?id=33

ghost commented 10 years ago

From knightof...@gmail.com on May 08, 2013 02:38:57

P.S. The host discovery issue was not fixed by System.setProperty ("java.net.preferIPv4Stack" , "true").

ghost commented 10 years ago

From stillf...@gmail.com on May 22, 2013 18:00:34

I got the same error in Ubuntu Linux with JDK 1.6 and JDK 1.7, and in Mac OS X with JDK 1.6. I also tried running Java in 32 bit mode.

Inspecting the class path, it seems fine. minlog is there, as is kryo-debug. Not clear on why they're not loading.

ghost commented 10 years ago

From stillf...@gmail.com on May 22, 2013 18:42:07

That said, there doesn't seem to be anything special about building this app. I compiled the sources into .class files by hand and stuck them all in a jar file and that seems to work fine.

ghost commented 10 years ago

From cont...@esotericsoftware.com on May 23, 2013 03:56:23

Not sure why it won't build for you guys. Try "scar debug", this is what I get: http://pastebin.com/3fFtHaCy Yes, the project is very simple, just class files that get compiled and JARed. You could use Eclipse export JAR.

ghost commented 10 years ago

From cont...@esotericsoftware.com on May 23, 2013 03:57:54

You can also try "scar trace". I'm curious what the classpath it reports looks like.

ghost commented 10 years ago

From knightof...@gmail.com on May 23, 2013 15:15:01

"scar trace" gives the same output I reported above.

ghost commented 10 years ago

From knightof...@gmail.com on May 23, 2013 15:35:26

"scar debug" gives the same output as well.

ghost commented 10 years ago

From knightof...@gmail.com on May 23, 2013 15:44:58

It seems to me that there is some kind of assumption being made regarding the setup / configuration of either environment variables, scar, or svn. Can you please explain step-by-step how you would build kryonet from source on a new machine? I'm sure I'm missing something obvious, but I'm not sure what it is because there's very little information on how to build kryonet from source. Nate makes it sound so simple, "just svn checkout then run scar".

ghost commented 10 years ago

From knightof...@gmail.com on May 23, 2013 16:00:54

Okay, I'll go first. Here's exactly what I'm doing, step-by-step on the command line (assume scar-1.09.zip has been downloaded and unzipped in ~/Downloads/scar-1.09):

http://pastebin.com/qbC9fH3n