I'm trying to make tests using TestFX. But when calling this code I get an error.
#ExtendWith(ApplicationExtension.class)
class HelloApplicationTest extends ApplicationTest {
public double x, y;
#Start
#Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("fxml/Home.fxml")));
stage.initStyle(StageStyle.UNDECORATED);
root.setOnMousePressed(event -> {
x = stage.getX() - event.getSceneX();
y = stage.getY() - event.getSceneY();
});
root.setOnMouseDragged(event -> {
stage.setX(event.getSceneX() + x);
stage.setY(event.getSceneY() + y);
});
stage.setScene(new Scene(root, 606, 614));
stage.show();
}
}
Error:
--- Exception in Async Thread ---
java.lang.reflect.InvocationTargetException: null
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:116)
java.base/java.lang.reflect.Method.invoke(Method.java:578)
org.testfx.framework.junit5.ApplicationExtension$AnnotationBasedApplicationFixture.start(ApplicationExtension.java:158)
org.testfx.framework.junit5.ApplicationAdapter.start(ApplicationAdapter.java:37)
org.testfx.toolkit.impl.ApplicationServiceImpl.lambda$start$0(ApplicationServiceImpl.java:49)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
javafx.graphics#20-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:183)
java.base/java.lang.Thread.run(Thread.java:1589)
java.lang.NullPointerException: null
java.base/java.util.Objects.requireNonNull(Objects.java:233)
HelloApplicationTest.start(HelloApplicationTest.java:28)
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
java.base/java.lang.reflect.Method.invoke(Method.java:578)
org.testfx.framework.junit5.ApplicationExtension$AnnotationBasedApplicationFixture.start(ApplicationExtension.java:158)
org.testfx.framework.junit5.ApplicationAdapter.start(ApplicationAdapter.java:37)
org.testfx.toolkit.impl.ApplicationServiceImpl.lambda$start$0(ApplicationServiceImpl.java:49)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
javafx.graphics#20-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:183)
java.base/java.lang.Thread.run(Thread.java:1589)
--- Trace of caller of unhandled exception in Async Thread ---
java.base/java.lang.Thread.getStackTrace(Thread.java:2550)
org.testfx.util.WaitForAsyncUtils$ASyncFXCallable.<init>(WaitForAsyncUtils.java:650)
org.testfx.util.WaitForAsyncUtils.asyncFx(WaitForAsyncUtils.java:258)
org.testfx.toolkit.impl.ApplicationServiceImpl.start(ApplicationServiceImpl.java:48)
org.testfx.toolkit.impl.ToolkitServiceImpl.lambda$setupApplication$6(ToolkitServiceImpl.java:127)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
java.base/java.lang.Thread.run(Thread.java:1589)
--- Exception in Async Thread ---
java.util.concurrent.ExecutionException: java.lang.reflect.InvocationTargetException
java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
org.testfx.util.WaitForAsyncUtils$ASyncFXCallable.get(WaitForAsyncUtils.java:697)
org.testfx.toolkit.impl.ToolkitServiceImpl.lambda$setupApplication$6(ToolkitServiceImpl.java:127)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
java.base/java.lang.Thread.run(Thread.java:1589)
java.lang.reflect.InvocationTargetException: null
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:116)
java.base/java.lang.reflect.Method.invoke(Method.java:578)
org.testfx.framework.junit5.ApplicationExtension$AnnotationBasedApplicationFixture.start(ApplicationExtension.java:158)
org.testfx.framework.junit5.ApplicationAdapter.start(ApplicationAdapter.java:37)
org.testfx.toolkit.impl.ApplicationServiceImpl.lambda$start$0(ApplicationServiceImpl.java:49)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
javafx.graphics#20-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:183)
java.base/java.lang.Thread.run(Thread.java:1589)
java.lang.NullPointerException: null
java.base/java.util.Objects.requireNonNull(Objects.java:233)
HelloApplicationTest.start(HelloApplicationTest.java:28)
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
java.base/java.lang.reflect.Method.invoke(Method.java:578)
org.testfx.framework.junit5.ApplicationExtension$AnnotationBasedApplicationFixture.start(ApplicationExtension.java:158)
org.testfx.framework.junit5.ApplicationAdapter.start(ApplicationAdapter.java:37)
org.testfx.toolkit.impl.ApplicationServiceImpl.lambda$start$0(ApplicationServiceImpl.java:49)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
javafx.graphics#20-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:183)
java.base/java.lang.Thread.run(Thread.java:1589)
--- Trace of caller of unhandled exception in Async Thread ---
java.base/java.lang.Thread.getStackTrace(Thread.java:2550)
org.testfx.util.WaitForAsyncUtils$ASyncFXCallable.<init>(WaitForAsyncUtils.java:650)
org.testfx.util.WaitForAsyncUtils.async(WaitForAsyncUtils.java:193)
org.testfx.toolkit.impl.ToolkitServiceImpl.setupApplication(ToolkitServiceImpl.java:123)
org.testfx.api.FxToolkit.setupApplication(FxToolkit.java:153)
org.testfx.framework.junit5.ApplicationExtension.beforeEach(ApplicationExtension.java:85)
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$2(TestMethodTestDescriptor.java:163)
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:199)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:199)
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:162)
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:129)
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.reflect.InvocationTargetException
at org.testfx.util.WaitForAsyncUtils.waitFor(WaitForAsyncUtils.java:302)
at org.testfx.api.FxToolkit.waitForSetup(FxToolkit.java:245)
at org.testfx.api.FxToolkit.setupApplication(FxToolkit.java:153)
at org.testfx.framework.junit5.ApplicationExtension.beforeEach(ApplicationExtension.java:85)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$2(TestMethodTestDescriptor.java:163)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:199)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:199)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:162)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:129)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.util.concurrent.ExecutionException: java.lang.reflect.InvocationTargetException
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at org.testfx.util.WaitForAsyncUtils$ASyncFXCallable.get(WaitForAsyncUtils.java:697)
at org.testfx.toolkit.impl.ToolkitServiceImpl.lambda$setupApplication$6(ToolkitServiceImpl.java:127)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:116)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.testfx.framework.junit5.ApplicationExtension$AnnotationBasedApplicationFixture.start(ApplicationExtension.java:158)
at org.testfx.framework.junit5.ApplicationAdapter.start(ApplicationAdapter.java:37)
at org.testfx.toolkit.impl.ApplicationServiceImpl.lambda$start$0(ApplicationServiceImpl.java:49)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
at javafx.graphics#20-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:183)
... 1 more
Caused by: java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:233)
at HelloApplicationTest.start(HelloApplicationTest.java:28)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 12 more
As if it couldn't find the Home.fxml file. Here is the hierarchy of the project:
I tried to give a different file path, but I can't find it. Instead of getClass().getResource() I tried HelloApplication.class.getResource() but to no avail.
Related
I noticed while updating my TornadoFX version from 1.7.12 to 1.7.14 that one of my tests broke. Things seemed to go off the rails when a runAsyncWithProgress in the View under test was rejected by a ThreadPoolExecutor with status Terminated. I saw in the release notes for 1.7.13 there was a change "internal thread pools are shut down on app exit". Setting the TornadoFX version to 1.7.13 resulted in the same failure, confirming my suspicion that it was related to the above change.
I wrote a simple app to demonstrate this bug.
// src/main/kotlin/me/carltonwhitehead/AsyncBugApp.kt
class AsyncBugApp : App(MainView::class)
/**
* The main method is needed to support the mvn jfx:run goal.
*/
fun main(args: Array<String>) {
Application.launch(AsyncBugApp::class.java, *args)
}
class MainView : View("Async Bug App") {
val controller: MainController by inject()
override val root = pane {
button("Robot-click to repeat bug") {
id = "bug"
action {
runAsync {
controller.onAction("button clicked")
}
}
}
}
}
class MainController : Controller() {
fun onAction(message: String) {
println(message)
}
}
And the test
// src/test/kotlin/me/carltonwhitehead/AsyncBugAppTest.kt
#RunWith(Parameterized::class)
class AsyncBugAppTest(val rounds: Int) {
companion object {
#JvmStatic
#Parameterized.Parameters
fun data() : Collection<Array<Int>> {
return listOf(arrayOf(1), arrayOf(1))
}
}
lateinit var robot: FxRobot
lateinit var app: App
#RelaxedMockK
lateinit var controller: MainController
#Rule #JvmField
val timeout = Timeout(10, TimeUnit.SECONDS)
#Before
fun before() {
MockKAnnotations.init(this)
FxToolkit.registerPrimaryStage()
app = AsyncBugApp()
app.scope.set(controller)
FxToolkit.setupApplication { app }
robot = FxRobot()
println("rounds = $rounds")
}
#After
fun after() {
FxToolkit.cleanupStages()
FxToolkit.cleanupApplication(app)
}
#Test()
fun itShouldSurviveRunAsyncMultipleTimes() {
val latch = CountDownLatch(rounds)
every { controller.onAction(any()) }.answers { latch.countDown() }
var i = 0
while(i <= rounds) {
robot.clickOn("#bug")
i++
}
latch.await()
verify(exactly = rounds) { controller.onAction(any()) }
}
}
The first time that test executes, it passes. The second time, it hangs, because the runAsync is rejected with the below stack trace.
--- Exception in Async Thread ---
java.util.concurrent.RejectedExecutionException: Task tornadofx.FXTask#a315135 rejected from java.util.concurrent.ThreadPoolExecutor#75bde925[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 2]
java.base/java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2104)
java.base/java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:848)
java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1397)
tornadofx.AsyncKt.task(Async.kt:76)
tornadofx.AsyncKt.task(Async.kt:69)
tornadofx.Component.runAsync(Component.kt:272)
tornadofx.Component.runAsync$default(Component.kt:988)
me.carltonwhitehead.MainView$root$1$1$1.invoke(AsyncBugApp.kt:21)
me.carltonwhitehead.MainView$root$1$1$1.invoke(AsyncBugApp.kt:15)
tornadofx.ControlsKt$action$2.handle(Controls.kt:513)
tornadofx.ControlsKt$action$2.handle(Controls.kt)
javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
javafx.base/javafx.event.Event.fireEvent(Event.java:198)
javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8863)
javafx.controls/javafx.scene.control.Button.fire(Button.java:200)
javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:206)
javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
javafx.base/javafx.event.Event.fireEvent(Event.java:198)
javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3876)
javafx.graphics/javafx.scene.Scene$MouseHandler.access$1300(Scene.java:3604)
javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1874)
javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2613)
javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:397)
javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
java.base/java.security.AccessController.doPrivileged(Native Method)
javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:434)
javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:433)
javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
java.base/java.lang.Thread.run(Thread.java:844)
I suspect I might be doing something wrong with the TestFX/TornadoFX app lifecycle. Each test cycle is creating a new app instance, so I'm confused why the ThreadPoolExecutor would be retained. Any suggestions?
Repo at https://github.com/carltonwhitehead/fx-async-bug-test
We are making a card game named Dominion with client-server, using Java Serialization. We are working also with observer/observable and threads (threads for reading messages on server and client side).
We are highlighting the card with CSS if a player is able to play or buy a card. The highlight is added by the update methode of the interface Observer where a gamecard is being observed. If a specific condition is true, we will add the highlight to the gamecard (class GameCard is implements Observer).
In general it works fine, but there is a card (named Militia) which forces the opponents to discard cards from their hand until they got only 3 cards left. We can play this for several times without exceptions, but suddenly there are several exceptions (after about 7-10 times played the Militia cards). We have no idea why.
What could be the reason of this exceptions? I think it doesn't help if I post the code, I will post the exceptions:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.javafx.text.PrismTextLayout.addTextRun(PrismTextLayout.java:755)
at com.sun.javafx.text.GlyphLayout.addTextRun(GlyphLayout.java:140)
at com.sun.javafx.text.GlyphLayout.breakRuns(GlyphLayout.java:210)
at com.sun.javafx.text.PrismTextLayout.buildRuns(PrismTextLayout.java:770)
at com.sun.javafx.text.PrismTextLayout.layout(PrismTextLayout.java:1021)
at com.sun.javafx.text.PrismTextLayout.ensureLayout(PrismTextLayout.java:223)
at com.sun.javafx.text.PrismTextLayout.getBounds(PrismTextLayout.java:246)
at javafx.scene.text.Text.getLogicalBounds(Text.java:358)
at javafx.scene.text.Text.impl_computeGeomBounds(Text.java:1168)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1596)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.computeLocalBounds(Node.java:3595)
at javafx.scene.Node.updateLocalBounds(Node.java:3625)
at javafx.scene.Node.getLocalBounds(Node.java:3486)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1596)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1596)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1596)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.impl_intersectsBounds(Node.java:5015)
at javafx.scene.layout.Region.impl_pickNodeLocal(Region.java:2931)
at javafx.scene.Node.impl_pickNode(Node.java:4914)
at javafx.scene.Scene$MouseHandler.pickNode(Scene.java:3899)
at javafx.scene.Scene$MouseHandler.access$1600(Scene.java:3485)
at javafx.scene.Scene.pick(Scene.java:1942)
at javafx.scene.Scene.access$6700(Scene.java:159)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3711)
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$353(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$147(WinApplication.java:177)
at java.lang.Thread.run(Unknown Source)
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1591)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.impl_intersectsBounds(Node.java:5015)
at javafx.scene.layout.Region.impl_pickNodeLocal(Region.java:2931)
at javafx.scene.Node.impl_pickNode(Node.java:4914)
at javafx.scene.Scene$MouseHandler.pickNode(Scene.java:3899)
at javafx.scene.Scene$MouseHandler.access$1600(Scene.java:3485)
at javafx.scene.Scene.pick(Scene.java:1942)
at javafx.scene.Scene.access$6700(Scene.java:159)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3711)
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$353(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$147(WinApplication.java:177)
at java.lang.Thread.run(Unknown Source)
Exception in thread "JavaFX Application Thread"
...and if we just mouse hover over the stage, it throws hundreds of times this exception:
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException
Code which could cause the exceptions:
1. in this class we highlight the cards which the opponent has to discard (until he has left 3 cards; see line where croupier.isDiscardModeMilitia....)
public class GameCard extends Button implements Observer {
protected static final boolean MoneyCard = false;
ServiceLocatorClient sl = ServiceLocatorClient.getServiceLocator();
Croupier croupier = Croupier.getCroupier();
Label lbl_cardName;
String text_DE;
boolean holeCard = false;
int costs;
StackSizeInfo stackSizeInfo;
public GameCard(Label cardName, String text_DE) {
super();
this.lbl_cardName = cardName;
this.text_DE=text_DE;
this.assignPicture();
}
public GameCard(){
}
GameCard gc = this;
#Override
public void update(Observable arg0, Object arg1) {
getStyleClass().remove("highlight");
getStyleClass().remove("highlight2");
getStyleClass().remove("highlight3");
//Highlighte alle Karten im Kaufmodus, welche ich mit der aktuelln Buypower und buys kaufen kann
if (croupier.isBuyMode() == true && croupier.getBuyPower() >= this.costs && !this.isHoleCard() && croupier.getBuys() > 0){
this.getStyleClass().add("highlight");
}
//Highlighte alle Geldkarten im Kaufmodus
if (croupier.isBuyMode() == true && this.isHoleCard() && this instanceof MoneyCard){
this.getStyleClass().add("highlight");
}
//Highlighte alle Aktionskarten im Aktionsmodus
if (croupier.isActionMode() == true && this.isHoleCard() && this instanceof ActionCard){
this.getStyleClass().add("highlight");
}
//Highlighte alle HoleCards im Discardmodus (basement)
if (croupier.isDiscardMode() == true && this.isHoleCard()){
this.getStyleClass().add("highlight3");
}
//Highlighte alle HoleCards im TrashModus Kapelle
if (croupier.isTrashModeChapel() == true && this.isHoleCard()){
this.getStyleClass().add("highlight3");
}
//Highlighte alle MoneyCards im TrashModus Mine
if (croupier.isTrashModeMine() == true && this instanceof MoneyCard && this.isHoleCard()){
this.getStyleClass().add("highlight3");
}
//Highlighte alle Karten auf der Hand, welche im Umbaumodus weggeworfen werden können
if (croupier.isTrashModeRebuilding() == true && this.isHoleCard()){
this.getStyleClass().add("highlight3");
}
//Highlighte alle Kupferkarten auf der Hand, die gegen +3Geld weggeworfen werden können (ActionCard Geldverleiher)
if (croupier.isTrashModeMoneylender() == true && this.isHoleCard() && this.getLbl_cardName().getText().equals("copper")){
this.getStyleClass().add("highlight3");
}
//Highlighte alle MoneyCards, welche erworben werden können im Minen-Modus
if (croupier.isModeForMine() == true && this instanceof MoneyCard && !this.isHoleCard() && this.costs <= croupier.getSavedMCValueForMineMode()){
this.getStyleClass().add("highlight");
}
//Highlighte alle Karten zum Kauf, welche erworben werden können im Rebuilding-Modus
if (croupier.isModeForRebuilding() == true && !this.isHoleCard() && this.costs <= croupier.getCardValueForRebuildingMode()){
this.getStyleClass().add("highlight");
}
//Highlighte alle Karten zum Kauf, welche erworben werden können im Rebuilding-Modus
if (croupier.isModeForWorkshop() == true && !this.isHoleCard() && this.costs <= 4){
this.getStyleClass().add("highlight3");
}
//Highlighte alle Moat-Karten wenn ein Angriff gemacht worden ist
if (croupier.isReactionMode() == true && this.isHoleCard() && this.getLbl_cardName().getText().equals("moat")){
this.getStyleClass().add("highlight3");
}
//Highlighte alle Moat-Karten wenn ein Angriff gemacht worden ist
if (croupier.isDiscardModeMilitia() == true && this.isHoleCard()){
this.getStyleClass().add("highlight2");
}
//Highlighte alle Moat-Karten wenn ein Angriff gemacht worden ist
if (croupier.isModeForCurseCard() == true && !this.isHoleCard() && this.getLbl_cardName().getText().equals("curse")){
this.getStyleClass().add("highlight2");
}
//wenn stacksize auf 0, wird highlighting ebenfalls deaktiviert
if (croupier.getStackSize(gc) == 0) {
this.getStyleClass().remove("highlight");
}
//update das STackSize infoLabel auf der Karte
if (this.stackSizeInfo != null){
stackSizeInfo.updateStackSizeInfo();
}
}
public void assignStackSizeInfo(){
stackSizeInfo = new StackSizeInfo(gc,croupier.getStackSize(gc));
}
public void assignPicture(){
if (this.holeCard == false)
this.getStyleClass().addAll("card_mini",lbl_cardName.getText());
else
this.getStyleClass().addAll("card",lbl_cardName.getText()+"_big");
}
public boolean isHoleCard() {
return holeCard;
}
public void setHoleCard(boolean holeCard) {
this.holeCard = holeCard;
}
public Label getLbl_cardName() {
return lbl_cardName;
}
public String getText_DE(){
return this.text_DE;
}
public void setLbl_cardName(Label lbl_cardName) {
this.lbl_cardName = lbl_cardName;
}
}
possible code fragment: here we are updating the GUI. This happens whenever we play a card from the hand. We will remove it first from the LinkedList (HoleCards) in another method and then we call updateGUI
public void updateGUI() {
// Zeichne holeCards Neu
hb_wrapper_holeCards.getChildren().clear();
for (int i = 0; i < croupier.getHoleCards().size(); i++) {
GameCard gc1 = croupier.getHoleCards().get(i);
try{
hb_wrapper_holeCards.getChildren().add(gc1);
gc1.setPrefSize(160, 260);
gc1.setMaxWidth(160);
}catch (NullPointerException e){
//
}
// Zeichne Ablagekarte neu
hb_wrapper_stapel.getChildren().clear();
dummyCardAblagestapel.getStyleClass().clear();
try {
String cssSelector = new String(croupier.getAblagestapel().peekLast().getLbl_cardName().getText()+"_big");
dummyCardAblagestapel.getStyleClass().addAll("card",cssSelector);
hb_wrapper_stapel.getChildren().addAll(dummyCardAblagestapel,nachziehstapel);
} catch(Exception e){
hb_wrapper_stapel.getChildren().addAll(this.dummyCardAblagestapel,nachziehstapel);
}
}
}
note1: I guess it happens in the first fragment where we highlight the cards. After a player has discarded cards until he has only 3 left in the hand, we will remove the highlight. Exactly when he discards his last card, the exception is thrown (but as I said, we can play this for about 7-10 times without exceptions, but suddenly the exceptions are thrown)
note2: I have already tried with Platform.runLater on this 2 code fragments and it didn't help
I am trying to connect an SQLite database (saved in the app folder) to a picker component (accepting strings). The following is the code I used (previously advised):
Database db = null;
Cursor cur = null;
try {
db = Display.getInstance().openOrCreate("FoodAndBeverage.db");
if(selectItem.getText().startsWith("Still Water")) {
cur = db.executeQuery(selectItem.getText());
int columns = cur.getColumnCount();
addItem.removeAll();
if(columns > 0) {
boolean next = cur.next();
if(next) {
ArrayList<String[]> data = new ArrayList<>();
String[] columnNames = new String[columns];
for(int iter = 0 ; iter < columns ; iter++) {
columnNames[iter] = cur.getColumnName(iter);
}
while(next) {
Row currentRow = cur.getRow();
String[] currentRowArray = new String[columns];
for(int iter = 0 ; iter < columns ; iter++) {
currentRowArray[iter] = currentRow.getString(iter);
}
data.add(currentRowArray);
next = cur.next();
}
Object[][] arr = new Object[data.size()][];
data.toArray(arr);
addItem.add(BorderLayout.CENTER, new Table(new DefaultTableModel(columnNames, arr)));
} else {
addItem.add(BorderLayout.CENTER, "Query returned no results");
}
} else {
addItem.add(BorderLayout.CENTER, "Query returned no results");
}
} else {
db.execute(selectItem.getText());
addItem.add(BorderLayout.CENTER, "Query completed successfully");
}
addItem.revalidate();
} catch(IOException err) {
Log.e(err);
addItem.removeAll();
addItem.add(BorderLayout.CENTER, "Error: " + err);
addItem.revalidate();
} finally {
Util.cleanup(db);
Util.cleanup(cur);
}
However, I get the following error messages:
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near ".": syntax error)
[EDT] 0:0:0,0 - Exception: java.io.IOException - [SQLITE_ERROR] SQL error or missing database (near ".": syntax error)
at org.sqlite.DB.newSQLException(DB.java:886)
at org.sqlite.DB.newSQLException(DB.java:897)
at org.sqlite.DB.throwex(DB.java:864)
at org.sqlite.NativeDB.prepare(Native Method)
at org.sqlite.DB.prepare(DB.java:207)
at org.sqlite.PrepStmt.<init>(PrepStmt.java:50)
at org.sqlite.SQLiteConnection.prepareStatement(SQLiteConnection.java:616)
at org.sqlite.SQLiteConnection.prepareStatement(SQLiteConnection.java:606)
at org.sqlite.SQLiteConnection.prepareStatement(SQLiteConnection.java:578)
at com.codename1.impl.javase.SEDatabase.execute(SEDatabase.java:90)
at com.mycompany.myapp.MyApplication.AddItem(MyApplication.java:88)
at com.mycompany.myapp.MyApplication.start(MyApplication.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.codename1.impl.javase.Executor$1$1.run(Executor.java:100)
at com.codename1.ui.Display.processSerialCalls(Display.java:1147)
at com.codename1.ui.Display.mainEDTLoop(Display.java:966)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
java.io.IOException: [SQLITE_ERROR] SQL error or missing database (near ".": syntax error)
at com.codename1.impl.javase.SEDatabase.execute(SEDatabase.java:94)
at com.mycompany.myapp.MyApplication.AddItem(MyApplication.java:88)
at com.mycompany.myapp.MyApplication.start(MyApplication.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.codename1.impl.javase.Executor$1$1.run(Executor.java:100)
at com.codename1.ui.Display.processSerialCalls(Display.java:1147)
at com.codename1.ui.Display.mainEDTLoop(Display.java:966)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.codename1.impl.javase.Executor$1$1.run(Executor.java:100)
at com.codename1.ui.Display.processSerialCalls(Display.java:1147)
at com.codename1.ui.Display.mainEDTLoop(Display.java:966)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
Caused by: java.lang.IllegalStateException: Layout doesn't support adding with arguments: com.codename1.ui.layouts.BoxLayout
at com.codename1.ui.layouts.Layout.addLayoutComponent(Layout.java:64)
at com.codename1.ui.Container.addComponent(Container.java:525)
at com.codename1.ui.Container.add(Container.java:172)
at com.codename1.ui.Container.add(Container.java:201)
at com.mycompany.myapp.MyApplication.AddItem(MyApplication.java:95)
at com.mycompany.myapp.MyApplication.start(MyApplication.java:145)
... 9 more
This may be due to the app not recognising the database. To clarify, where does the database file need to be saved? I have currently saved the file in the app folder.
View of app folder showing where the database file (highlighted) is saved.
That isn't the right place where the database should be stored. If you need the database shipped with your app e.g. this from here:
Some SQLite apps ship with a "ready made" database. We allow you to
replace the DB file by using the code:
String path = Display.getInstance().getDatabasePath(“databaseName”);
You can then use the FileSystemStorage class to write the content of
your DB file into the path. Notice that it must be a valid SQLite
file!
The physical location is under the .cn1 directory in the users home dir. The java.home value for your OS.
I have a JavaFX application which have a scheduledExecutorService who's requesting some datas from a server. these datas are used to fill a ListView and when I click on an element in this list a request for more datas is sent to the server and a MQTT connection is set, but a few seconds later I get a NullPointerException from somwhere I don't understand and I don't even know what object points to Null.
Here is the part where the error comes from :
public class DevicePane extends BorderPane {
private final TcpConnection tcp;
private final MqttConnection mqtt;
private final DeviceListView deviceListView;
private SpecificDevicePane deviceInfoPane;
private String[] topicsArray;
public DevicePane() {
tcp = new TcpConnection();
mqtt = new MqttConnection();
mqtt.connect();
deviceListView = new DeviceListView();
deviceListView.getSelectionModel().selectedIndexProperty().addListener(e -> {
if (topicsArray != null) mqtt.unsubscribeToAll(topicsArray);
AnswerMessage answer = tcp.sendRequest(new RequestMessage(RQST_DEVICE_INFO, deviceListView.getSelectionModel().getSelectedItem().toString()));
topicsArray = new String[answer.getParams().size()];
topicsArray = answer.getParams().toArray(topicsArray);
mqtt.subscribeToAll(topicsArray);
deviceInfoPane = new SpecificDevicePane(answer.getParams(), mqtt, tcp);
ScrollPane scrollPane = new ScrollPane(deviceInfoPane);
this.setCenter(scrollPane);
});
this.setLeft(deviceListView);
// Tâche planifiée afin de récupérer la liste des objets IOT de la DB.
ScheduledExecutorService threadPool = Executors.newScheduledThreadPool(1);
threadPool.scheduleAtFixedRate(() -> {
refreshDeviceList();
}, 0, 5, TimeUnit.SECONDS);
}
And here is the error I get :
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at view.DevicePane.lambda$new$8(DevicePane.java:36)
at view.DevicePane$$Lambda$77/576256602.invalidated(Unknown Source)
at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:349)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
at javafx.beans.property.ReadOnlyIntegerWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:176)
at javafx.beans.property.ReadOnlyIntegerWrapper.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:142)
at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:113)
at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:147)
at javafx.scene.control.SelectionModel.setSelectedIndex(SelectionModel.java:68)
at javafx.scene.control.MultipleSelectionModelBase.clearSelection(MultipleSelectionModelBase.java:665)
at javafx.scene.control.ListView$ListViewBitSetSelectionModel.updateSelection(ListView.java:1306)
at javafx.scene.control.ListView$ListViewBitSetSelectionModel.access$1600(ListView.java:1173)
at javafx.scene.control.ListView$ListViewBitSetSelectionModel$1.onChanged(ListView.java:1246)
at javafx.collections.WeakListChangeListener.onChanged(WeakListChangeListener.java:88)
at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
at javafx.collections.ModifiableObservableListBase.setAll(ModifiableObservableListBase.java:90)
at view.DeviceListView.refreshShownDevice(DeviceListView.java:43)
at view.DeviceListView.setDeviceList(DeviceListView.java:33)
at view.DeviceListView.lambda$setDeviceList$7(DeviceListView.java:36)
at view.DeviceListView$$Lambda$160/2054192134.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1826358374.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/1915503092.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
at com.sun.glass.ui.win.WinApplication$$Lambda$36/1963387170.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Line 36 is this line : AnswerMessage answer = tcp.sendRequest(new RequestMessage(RQST_DEVICE_INFO, deviceListView.getSelectionModel().getSelectedItem().toString()));
I hope someone will be able to help me
I was trying to run a simple Cql3 query with Astyanax and I keep on getting an error.
The aim is to create a simple table via Astyanax using cql3.
public class SomeTest {
private AstyanaxContext<Keyspace> astyanaxContext;
private Keyspace keyspace;
private static String CREATE_TABLE_QUERY = "CREATE TABLE top_items (\n" +
" categoryName varchar,\n" +
" type varchar,\n" +
" baseItemId int,\n" +
" margin float,\n" +
" ds timestamp,\n" +
" PRIMARY KEY (categoryName, ds)\n" +
");";
#Before
public void setUp() {
try {
this.astyanaxContext = new AstyanaxContext.Builder()
.forCluster("ClusterName")
.forKeyspace("new_examples")
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.NONE).setCqlVersion("3.0.0"))
.withConnectionPoolConfiguration(
new ConnectionPoolConfigurationImpl("MyConnectionPool").setMaxConnsPerHost(1).setPort(9160)
.setSeeds("localhost:9160")).withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
this.astyanaxContext.start();
this.keyspace = this.astyanaxContext.getEntity();
// Using simple strategy
keyspace.createKeyspace(ImmutableMap.<String, Object>builder()
.put("strategy_options", ImmutableMap.<String, Object>builder()
.put("replication_factor", "1")
.build())
.put("strategy_class", "SimpleStrategy")
.build()
);
// test the connection
this.keyspace.describeKeyspace();
} catch (Throwable e) {
throw new RuntimeException("Failed to prepare CassandraBolt", e);
}
}
#Test
public void testWrite() throws ConnectionException {
ColumnFamily<String, String> CQL3_CF = ColumnFamily.newColumnFamily(
"Cql3CF",
StringSerializer.get(),
StringSerializer.get());
OperationResult<CqlResult<String, String>> result;
result = keyspace
.prepareQuery(CQL3_CF)
.withCql(CREATE_TABLE_QUERY)
.execute();
}
}
When I run the test I get this stack trace
java.lang.NoSuchMethodError: org.apache.thrift.meta_data.FieldValueMetaData.<init>(BZ)V
at org.apache.cassandra.thrift.Cassandra$execute_cql_query_args.<clinit>(Cassandra.java:32588)
at org.apache.cassandra.thrift.Cassandra$Client.send_execute_cql_query(Cassandra.java:1393)
at org.apache.cassandra.thrift.Cassandra$Client.execute_cql_query(Cassandra.java:1387)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$6$1.internalExecute(ThriftColumnFamilyQueryImpl.java:699)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$6$1.internalExecute(ThriftColumnFamilyQueryImpl.java:696)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:55)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:27)
at com.netflix.astyanax.thrift.ThriftSyncConnectionFactoryImpl$1.execute(ThriftSyncConnectionFactoryImpl.java:136)
at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:69)
at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:248)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$6.execute(ThriftColumnFamilyQueryImpl.java:694)
at storage.cassandra.daos.SomeTest.testWrite(SomeTest.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
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.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
I'm using "com.netflix.astyanax" % "astyanax" % "1.56.18" .
Please help.
It looks like Astyanax is not properly supporting Cassandra 1.2 or 1.2.1 (not even 1.56.24, released 7 days ago...). You may try java-driver instead. It is not yet released but it works fine, as far as I have tested.
https://github.com/datastax/java-driver