1

I'm working on a game in Java and so far so good. Except I'm getting the error below when I click the button calling the "onlineController.setGame(controller.hostOnlineGame)..." method. The method calling the server is working alright as well as setting the window.

I have really tried to find out what it means but I just can't. I would really appreciate some guidance, as to 1. what the error means and 2. how I can fix it!

This is not a duplicate due to the fact that besides the NullPointer the error caused by the lambda expression is no duplicate. I have tried to debug to ensure all my fields are !=null, which they aren't and I'm out of ideas on how else to solve the error.

Button hostToGame = new Button("Start");
    hostToGame.setOnAction(
            (ActionEvent w) -> {
                serverController.startServer();
// this is where the error comes from
                onlineController.setGame(controller.hostOnlineGame(hostText.getText(), onlineBotCombo.getValue(),
                        onlineDiffCombo.getValue(), onlineColorCombo.getValue(), onlinePointsCombo.getValue()));
                window.setScene(gameScene);

            }
    );

The stack trace of the exception that is generated is:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
    at de.btu.swp.catan.client.MainApp.lambda$start$11(MainApp.java:246)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Node.fireEvent(Node.java:8413)
    at javafx.scene.control.Button.fire(Button.java:185)
    at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:417)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    at com.sun.glass.ui.View.notifyMouse(View.java:937)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)

A snippet of the method being called:

public Game hostOnlineGame(String Name, String bot1, String bot2,
  String color, String victoryPoints) {
  ///
}
James_D
  • 201,275
  • 16
  • 291
  • 322
cndolo
  • 27
  • 2
  • 8
  • What is the exception that is thrown? Could you add a full stacktrace to your question? Besides, have you tried to debug this code already? (As it migt be much faster to find the problem that way!) – n247s Jan 22 '17 at 13:10
  • It's unable to determine what kind of error that throws. Please provide fullstack of errors. As suggestion, ccopy paste whole stack to pastebin.com and leave link here – Malakai Jan 22 '17 at 13:11
  • Here is the full stacktrace: [link] (http://pastebin.com/dBHULY5j) And sorry I forgot that: It's throwing a NullPointerException. – cndolo Jan 22 '17 at 13:15
  • @Reborn Please don't encourage people to post links to code or output. The stack trace should be posted in the question itself. – James_D Jan 22 '17 at 16:57
  • @James_D there could be some exclusions, like i had ( see: http://stackoverflow.com/questions/36557102/sts-randomly-crashes-on-ubuntu) it's not like a criminal, if i asked about FULL information. – Malakai Jan 22 '17 at 17:24
  • @Reborn The problem is that if the link goes stale, the question becomes useless to future users. I know there are plenty of examples of it having been done, but that doesn't actually make it a good thing to do. – James_D Jan 22 '17 at 17:26
  • Any ideas on how to solve the problem? – cndolo Jan 22 '17 at 19:15
  • Have you read the post of which this question is marked a duplicate of? That is the solution. – n247s Jan 22 '17 at 21:32

0 Answers0