How to compile and run

265 views
Skip to first unread message

Tony Pham

unread,
Jan 15, 2014, 9:35:05 PM1/15/14
to jets...@googlegroups.com
Hi,

I would like to try Jetserver. However, I have some problems as followings:

1) Test failed
When test jetserver, both directly from eclipse or from command line (I run mvn clean install, then mvn test in MacOS) all failed:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building jetserver 0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jetserver ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jetserver ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 6 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ jetserver ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 125 source files to /Users/nguyenpham/Documents/workspace/java-game-server-master/jetserver/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jetserver ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/nguyenpham/Documents/workspace/java-game-server-master/jetserver/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ jetserver ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 12 source files to /Users/nguyenpham/Documents/workspace/java-game-server-master/jetserver/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ jetserver ---
[INFO] Surefire report directory: /Users/nguyenpham/Documents/workspace/java-game-server-master/jetserver/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.menacheri.jetserver.app.impl.PlayerSessionTest
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 21.362 sec <<< FAILURE!
eventHandlingPerformance(org.menacheri.jetserver.app.impl.PlayerSessionTest)  Time elapsed: 21.337 sec  <<< FAILURE!
java.lang.AssertionError: 
at org.junit.Assert.fail(Assert.java:91)
at org.junit.Assert.assertTrue(Assert.java:43)
at org.junit.Assert.assertTrue(Assert.java:54)
at org.menacheri.jetserver.app.impl.PlayerSessionTest.eventHandlingPerformance(PlayerSessionTest.java:92)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
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 org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Running org.menacheri.jetserver.AppTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.616 sec
Running org.menacheri.jetserver.JetlangEventDispatcherTest
Took  10.419 seconds to send 5000000 int eventsinvoked onNetworkMessage
invoked onNetworkMessage
invoked onNetworkMessage
invoked onNetworkMessage
invoked onNetworkMessage
invoked onNetworkMessage
invoked onDisconnect
log4j:WARN No appenders could be found for logger (org.menacheri.jetserver.event.impl.DefaultSessionEventHandler).
log4j:WARN Please initialize the log4j system properly.
invoked onDisconnect
invoked onDisconnect
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.813 sec
Running org.menacheri.jetserver.protocols.impl.AMF3ProtocolTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.057 sec
Running org.menacheri.jetserver.protocols.impl.AMF3StringProtocolTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.022 sec
Running org.menacheri.jetserver.protocols.impl.MessageBufferProtocolTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.103 sec

Results :

Failed tests:   eventHandlingPerformance(org.menacheri.jetserver.app.impl.PlayerSessionTest)

Tests run: 14, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.942s
[INFO] Finished at: Thu Jan 16 13:24:46 EST 2014
[INFO] Final Memory: 12M/505M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project jetserver: There are test failures.

2) How to run server (and then any client/example)?

I found the jar file jetserver-0.1.jar in the subfolder binaries of jetserver but don't know how to run it. I have tried java -cp ./jetserver-0.1.jar -Dlog4j.configuration=GameServerLog4j.properties org.menacheri.GameServer but got exception "Exception in thread "main" java.lang.NoClassDefFoundError: org/menacheri/GameServer".

I have checked and can't find class GameServer.

Please help. Many thanks!

Abraham Menacherry

unread,
Jan 16, 2014, 9:59:25 AM1/16/14
to jets...@googlegroups.com
Hi Tony,

Thanks for your interest in jet server. I think you might be using an older version of binary. The latest binaries are available in maven central itself. Just search for "nadron" you can either download or use it the same way example-games project is using it via its pom.xml

To run from eclipse(Note, i have not tried it on mac) you need to go to example-games project (use the netty4 branch) since that is the latest branch and execute the io.nadron.GameServer. This is the main class, please ensure that you pass -Dlog4j.configuration=GameServerLog4j.properties in the vm parameters of eclipse to ensure it runs properly.

Now you should have the server running. For running the java client (note there is java client, flash client and web socket client) of the Zombie game, please use the ZombieNadClient file. You should now see the logs of zombie and human population going up and down.

For websocket and a more detailed explanation please see the following post http://nerdronix.blogspot.com/2013/06/creating-multiplayer-game-using-html-5.html on my blog.

Thanks,
Abraham

Tony Pham

unread,
Jan 16, 2014, 8:30:43 PM1/16/14
to jets...@googlegroups.com
Thanks a lot Menacherry for creating JetServer and very fast responding :)

I see the reason I cannot compile the example is maven dependency. The code requires jetserver.jar and jetclient.jar which are not available on both com.github.menacher and org.menacheri. After adding nadron dependancy into the pom file, I have found nadron-0.5.jar on the repository of maven but the code still has errors and I don't know how to change code to use that.

For a quick try, I have copied both jetserver-0.1.jar and jetclient-0.1.jar which I found from banaries folder of jetserver/jetclient into a folder then add them as jar libraries into project example-games. Now I can run both server and client as normal java application and can read info from GameServer.log as you mentioned above. 

Question:
- How can I create and use nadron.jar instead of jetserver/jetclient? It looks like all code will create and use jet server/client but not nadron. It is the best if you update all code

I always highly appreciate your works and helps.


Tony Pham

unread,
Jan 17, 2014, 1:31:16 AM1/17/14
to jets...@googlegroups.com
Sorry, that is my mistake. I have downloaded and tried the old version JetServer.

After downloading nadron, I can run maven test for nadron succesfully.

However, when starting server of example-games (run as normal Java application from eclipse), it stops immediately and bellow is the content of GameServer.log about permission. My computer (MacBookPro) has no firewall.

Can you advice me how to fix that problem? Many thanks


2014-01-17 16:50:52,209 [NettyTCPServer:54][ERROR]:TCP Server start error {}, going to shut down
java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:124)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:102)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:478)
at io.netty.channel.DefaultChannelPipeline$HeadHandler.bind(DefaultChannelPipeline.java:1000)
at io.netty.channel.DefaultChannelHandlerContext.invokeBind(DefaultChannelHandlerContext.java:456)
at io.netty.channel.DefaultChannelHandlerContext.bind(DefaultChannelHandlerContext.java:441)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:842)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:193)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:330)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:348)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Thread.java:695)
2014-01-17 16:50:52,215 [AbstractNettyServer:51][DEBUG]:In stopServer method of class: io.nadron.server.netty.NettyTCPServer
2014-01-17 16:50:52,222 [GameServer:41][ERROR]:Unable to start servers cleanly: {}
java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:124)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:102)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:478)
at io.netty.channel.DefaultChannelPipeline$HeadHandler.bind(DefaultChannelPipeline.java:1000)
at io.netty.channel.DefaultChannelHandlerContext.invokeBind(DefaultChannelHandlerContext.java:456)
at io.netty.channel.DefaultChannelHandlerContext.bind(DefaultChannelHandlerContext.java:441)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:842)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:193)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:330)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:348)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Thread.java:695)
2014-01-17 16:50:55,434 [AbstractNettyServer:51][DEBUG]:In stopServer method of class: io.nadron.server.netty.NettyTCPServer
2014-01-17 16:50:55,436 [AbstractNettyServer:51][DEBUG]:In stopServer method of class: io.nadron.server.netty.NettyUDPServer
2014-01-17 16:50:55,449 [AbstractNettyServer:51][DEBUG]:In stopServer method of class: io.nadron.server.netty.NettyTCPServer

Abraham Menacherry

unread,
Jan 17, 2014, 2:42:28 PM1/17/14
to jets...@googlegroups.com
Hi Tony,

I have not executed it on a Mac book pro, but from your exception it looks like mac is stopping you from acccessing a port. Since the stack trace is saying TCP server my guess would be that it is related to the flash policy server starting at port 843(I have read that some systems will prevent access to ports below certain number).

This is what you can try.
In the GameServer.java instead of using servers.start() method with no arguments, use the following overloaded method -> public void startServers(int tcpPort, int flashPort, int udpPort)
e.g. servers.start(18090,0,18090). By passing 0 to the flash port, it will not get started.

Thanks,
Abraham.

Tony Pham

unread,
Jan 18, 2014, 12:07:16 AM1/18/14
to jets...@googlegroups.com
Thanks Abraham,

After fixing server code as your suggestion, I can start server without crashing.

However, when running the client (run as a Java application from eclipse) it seems to be stuck somewhere (no crash, no terminated but no information). The file GameServer.log of server is created but totally empty.

I have a look inside the client code (file ZombieClient) and see it uses the port 18090 already (so I don't need to change to match the server right?)

I put some print commands into few place and see that the problem may be caused by udpLocalAddress is not set (value still null).
I tried to fix it as the following:


final InetSocketAddress udpLocalAddress = zomHandler.connectLocal();


However, ChannelFutureListener failed with message:

java.nio.channels.ClosedChannelException


I don't know how to continue. Please helps,

Thanks again,


Abraham Menacherry

unread,
Jan 18, 2014, 3:29:44 PM1/18/14
to jets...@googlegroups.com
Tony,

To check if this is related to udp on a mac book pro. Could you try to run the websocket example? websocket is over tcp. So that might provide a clue.
Use the following blog post for reference -> http://nerdronix.blogspot.com/2013/06/creating-multiplayer-game-using-html-5.html Please go to the "Execution" section to see how to execute on the browser.

Thanks,
Abraham.

Tony Pham

unread,
Jan 19, 2014, 12:03:14 AM1/19/14
to jets...@googlegroups.com
Hi Abraham,

I have run that game directly from my local computer. I run the server first, then go to folder nadclient-js/test and open the file LDGame.html by two browsers Chrome and Safari. I can see that game in both browsers and can play well few games to vs each other. GameServer.log content after the first game is attached following.

Thanks again for your helps.


2014-01-19 15:51:51,704 [WebSocketLoginHandler:60][TRACE]:From websocket: {"type":8,"source":["user","pass","LDGameRoom"],"timeStamp":1390107111574}
2014-01-19 15:51:51,783 [WebSocketLoginHandler:65][TRACE]:Login attempt from /0:0:0:0:0:0:0:1%0:65179
2014-01-19 15:51:51,809 [WebSocketLoginHandler:184][TRACE]:Sending GAME_ROOM_JOIN_SUCCESS to channel [id: 0x3532496f, /0:0:0:0:0:0:0:1%0:65179 => /0:0:0:0:0:0:0:1%0:18090]
2014-01-19 15:51:51,810 [WebSocketLoginHandler:212][TRACE]:Sending GAME_ROOM_JOIN_SUCCESS to channel [id: 0x3532496f, /0:0:0:0:0:0:0:1%0:65179 => /0:0:0:0:0:0:0:1%0:18090] completed
2014-01-19 15:51:51,811 [GameRoomSession:180][TRACE]:Protocol to be applied is: io.nadron.protocols.impl.WebSocketProtocol
2014-01-19 15:51:51,812 [WebSocketProtocol:61][TRACE]:Going to apply WEB_SOCKET_PROTOCOL on session: PlayerSession [id=DefaultSession504player=io.nadron.app.impl.DefaultPlayer@1f, parentGameRoom=io.nadron.example.lostdecade.LDRoom@ec9f86ad, protocol=null, isShuttingDown=false]
2014-01-19 15:51:51,813 [GameRoomSession:339][TRACE]:Added Network handler to EventDispatcher of GameRoom io.nadron.example.lostdecade.LDRoom@ec9f86ad, for session: PlayerSession [id=DefaultSession504player=io.nadron.app.impl.DefaultPlayer@1f, parentGameRoom=io.nadron.example.lostdecade.LDRoom@ec9f86ad, protocol=null, isShuttingDown=false]
2014-01-19 15:52:20,182 [WebSocketLoginHandler:60][TRACE]:From websocket: {"type":8,"source":["user","pass","LDGameRoom"],"timeStamp":1390107140163}
2014-01-19 15:52:20,182 [WebSocketLoginHandler:65][TRACE]:Login attempt from /0:0:0:0:0:0:0:1%0:65182
2014-01-19 15:52:20,183 [WebSocketLoginHandler:184][TRACE]:Sending GAME_ROOM_JOIN_SUCCESS to channel [id: 0xa15140ef, /0:0:0:0:0:0:0:1%0:65182 => /0:0:0:0:0:0:0:1%0:18090]
2014-01-19 15:52:20,183 [WebSocketLoginHandler:212][TRACE]:Sending GAME_ROOM_JOIN_SUCCESS to channel [id: 0xa15140ef, /0:0:0:0:0:0:0:1%0:65182 => /0:0:0:0:0:0:0:1%0:18090] completed
2014-01-19 15:52:20,183 [GameRoomSession:180][TRACE]:Protocol to be applied is: io.nadron.protocols.impl.WebSocketProtocol
2014-01-19 15:52:20,184 [WebSocketProtocol:61][TRACE]:Going to apply WEB_SOCKET_PROTOCOL on session: PlayerSession [id=DefaultSession506player=io.nadron.app.impl.DefaultPlayer@1f, parentGameRoom=io.nadron.example.lostdecade.LDRoom@ec9f86ad, protocol=null, isShuttingDown=false]
2014-01-19 15:52:20,184 [GameRoomSession:339][TRACE]:Added Network handler to EventDispatcher of GameRoom io.nadron.example.lostdecade.LDRoom@ec9f86ad, for session: PlayerSession [id=DefaultSession506player=io.nadron.app.impl.DefaultPlayer@1f, parentGameRoom=io.nadron.example.lostdecade.LDRoom@ec9f86ad, protocol=null, isShuttingDown=false]

Tony Pham

unread,
Jan 19, 2014, 6:49:02 AM1/19/14
to jets...@googlegroups.com
I am still new to your code. Just did some tries as the followings just in hope you have some more clues:


I worry about variant InetSocketAddress udpLocalAddress = null; in the main procedure of ZombieClient.java. Thus I have tried to modify:

1) InetSocketAddress udpLocalAddress = zomHandler.connectLocal();

(move that line inside public void operationComplete(ChannelFuture future) )

Client crashed with exception java.nio.channels.ClosedChannelException

(I can see that exception message only after add try-catch into main function.


2) InetSocketAddress udpLocalAddress = defHandler.connectLocal();

No crash nor exception. However GameServer.log still empty


I am stuck again :(

Reply all
Reply to author
Forward
0 new messages