Unable to run the script written to test the Play store app - appium-android

I am new to Appium and want to work on it. As a beginner I am trying to test the Play store application for which I have written the script in eclipse. I am trying to open the app and then click on the text box to write some text. When I am running the script, its only initiating the application and then nothing happens. Please find the code below.
package tests;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
public class AppiumTest {
public static void main(String[]args){
AppiumDriver<MobileElement> driver = null;
//Set the Desired Capabilities
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Vinee");
caps.setCapability("udid", "3204d6dea76f219d");
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "5.1.1");
caps.setCapability("appPackage", "com.android.vending");
caps.setCapability("appActivity", "com.google.android.finsky.activities.MainActivity");
caps.setCapability("noReset", "true");
//Instantiate Appium Driver
try
{
driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"),caps);
}
catch (MalformedURLException e)
{
System.out.println(e.getMessage());
}
//Find Google Play element using ID property and click on it
driver.findElement(By.id("com.android.vending:id/search_box_idle_text")).sendKeys("Calculator");
}
}
The error message I am getting is :
Jul 24, 2018 10:03:12 AM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
at io.appium.java_client.HasSessionDetails.lambda$0(HasSessionDetails.java:49)
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at com.google.common.collect.CollectSpliterators$1.lambda$forEachRemaining$1(CollectSpliterators.java:117)
at java.util.Iterator.forEachRemaining(Unknown Source)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
at com.google.common.collect.CollectSpliterators$1.forEachRemaining(CollectSpliterators.java:117)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.collect(Unknown Source)
at io.appium.java_client.HasSessionDetails.getSessionDetails(HasSessionDetails.java:52)
at io.appium.java_client.HasSessionDetails.getSessionDetail(HasSessionDetails.java:56)
at io.appium.java_client.HasSessionDetails.getPlatformName(HasSessionDetails.java:65)
at io.appium.java_client.internal.JsonToMobileElementConverter.<init>(JsonToMobileElementConverter.java:49)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:89)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:94)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:93)
at tests.AppiumTest.main(AppiumTest.java:32)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 19 more
Please let me know how to proceed here after.

You can add the jar file containing the org/apache/commons/lang3/StringUtils at http://commons.apache.org/proper/commons-lang/download_lang.cgi.
Download the commons-lang3-3.7-src.zip under source and add to the project.

Related

Liquibase error in Quarkus when using with Open telemetry

I am try to use OpenTelemetry with quarkus application.
Before use open telemetry It was working file.
this is my application.properties file
quarkus.datasource.db-kind=postgresql
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/sampledb
quarkus.datasource.password=ddihdh
quarkus.datasource.username=sampledb
quarkus.datasource.reactive.url=vertx-reactive:postgresql://localhost/sampledb
quarkus.liquibase.change-log=db/changeLog.xml
quarkus.liquibase.migrate-at-start=true
quarkus.liquibase.default-schema-name=public
quarkus.application.name=sample-service
quarkus.opentelemetry.enabled=true
quarkus.opentelemetry.tracer.exporter.otlp.endpoint=http://localhost:4317
and this is my LiquibaseRunner file
package .......;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import io.quarkus.runtime.LaunchMode;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import io.quarkus.runtime.StartupEvent;
import io.quarkus.runtime.util.ExceptionUtil;
import liquibase.Contexts;
import liquibase.LabelExpression;
import liquibase.Liquibase;
import liquibase.database.DatabaseConnection;
import liquibase.database.DatabaseFactory;
import liquibase.exception.LiquibaseException;
import liquibase.resource.ClassLoaderResourceAccessor;
import liquibase.resource.ResourceAccessor;
import io.quarkus.logging.Log;
#ApplicationScoped
public class LiquibaseRunner {
#ConfigProperty(name = "quarkus.datasource.jdbc.url")
String datasourceUrl;
#ConfigProperty(name = "quarkus.datasource.username")
String datasourceUsername;
#ConfigProperty(name = "quarkus.datasource.password")
String datasourcePassword;
#ConfigProperty(name = "quarkus.liquibase.change-log")
String changeLogLocation;
public void onApplicationStart(#Observes StartupEvent even) {
LaunchMode mode = io.quarkus.runtime.LaunchMode.current();
if(mode != LaunchMode.TEST) {
this.runMigration();
} else {
Log.info("Skipping DB migrations in TEST mode.");
}
}
public void runMigration() {
Log.info("Migrating DB " + datasourceUrl);
Liquibase liquibase = null;
try {
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor(Thread.currentThread().getContextClassLoader());
DatabaseConnection conn = DatabaseFactory.getInstance().openConnection(datasourceUrl, datasourceUsername, datasourcePassword, null, resourceAccessor);
liquibase = new Liquibase(changeLogLocation, resourceAccessor, conn);
liquibase.update(new Contexts(), new LabelExpression());
} catch (Exception e) {
Log.error("Liquibase Migration Exception: " + ExceptionUtil.generateStackTrace(e));
}
finally {
if(liquibase!=null)
{
try {
liquibase.close();
} catch (LiquibaseException e) {
Log.info(e.getMessage());
}
}
}
}
}
this is working file. But when I try to use with Open telemetry show this error.
application.properties
#quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/sampledb
## with distributed tracing with OpenTelemetry
quarkus.datasource.jdbc.url=jdbc:otel:postgresql://localhost:5432/sampledb
quarkus.datasource.jdbc.driver=io.opentelemetry.instrumentation.jdbc.OpenTelemetryDriver
this is the error
2023-02-17 13:20:29,593 INFO [....inf.dat.LiquibaseRunner] [runMigration] (Quarkus Main Thread) Migrating DB jdbc:otel:postgresql://localhost:5432/sampledb
2023-02-17 13:20:29,595 ERROR [...inf.dat.LiquibaseRunner] [runMigration] (Quarkus Main Thread) Liquibase Migration Exception: liquibase.exception.DatabaseException: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (jdbc:otel:postgresql://localhost:5432/sampledb)
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:217)
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:176)
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:159)
at ....infrastructure.data.LiquibaseRunner.runMigration(LiquibaseRunner.java:49)
at ....infrastructure.data.LiquibaseRunner_Subclass.runMigration$$superforward1(Unknown Source)
at ....infrastructure.data.LiquibaseRunner_Subclass$$function$$2.apply(Unknown Source)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:53)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:40)
at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
at .....infrastructure.data.LiquibaseRunner_Subclass.runMigration(Unknown Source)
at ....infrastructure.data.LiquibaseRunner.onApplicationStart(LiquibaseRunner.java:39)
at .....infrastructure.data.LiquibaseRunner_Subclass.onApplicationStart$$superforward1(Unknown Source)
at .....infrastructure.data.LiquibaseRunner_Subclass$$function$$1.apply(Unknown Source)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:53)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:40)
at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
at ....infrastructure.data.LiquibaseRunner_Subclass.onApplicationStart(Unknown Source)
at ..infrastructure....data.LiquibaseRunner_Observer_onApplicationStart_3e5ff3fa5ec96071cea0c7faf2b64ce71ea7016d.notify(Unknown Source)
at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:323)
at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:305)
at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:73)
at io.quarkus.arc.runtime.ArcRecorder.fireLifecycleEvent(ArcRecorder.java:130)
at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:99)
at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy_0(Unknown Source)
at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy(Unknown Source)
at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
at io.quarkus.runtime.Application.start(Application.java:101)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:108)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
at io.quarkus.runner.GeneratedMain.main(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (jdbc:otel:postgresql://localhost:5432/sampledb)
at liquibase.database.DatabaseFactory.findDriverClass(DatabaseFactory.java:262)
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:200)
How can I fix this. Can some one help me?
You should probably configure 2 different datasources in your application.
Liquibase uses a plain JDBC driver and you seem to want the reactive driver for the application. You should be able to configure multiple datasources (see link for details) in your application.
Reactive for the app:
To Configure the default reactive driver for Postgres (see link) on Quarkus you need to add this extension to maven:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-pg-client</artifactId>
</dependency>
And configure it like in this example in application.properties:
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=sarah
quarkus.datasource.password=connor
quarkus.datasource.reactive.url=postgresql://localhost:5432/quarkus_test
JDBC for Liquibase:
pom.xml:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
Configs including multiple datasource configs for Liquibase:
quarkus.datasource.sampledb.db-kind=postgresql
quarkus.datasource.sampledb.username=sarah
quarkus.datasource.sampledb.password=connor
quarkus.datasource.sampledb.jdbc.url=jdbc:postgresql://localhost:5432/sampledb
quarkus.liquibase.sampledb.schemas=SAMPLEDB_TEST_SCHEMA
quarkus.liquibase.sampledb.change-log=db/sampledb.xml
quarkus.liquibase.sampledb.migrate-at-start=true
This will allow you to configure the OpenTelemetry instrumentation according to the specificities of each datasource.

ScalaFX #sfxml Annotation Problems

I am writing a Scalafx application using FXML for the views with the scalafxml library. I am having a ton of trouble getting the classes to compile when using the #sfxml annotation on controller classes. When using them, I keep getting NoSuchMethodExceptions on my constructors as if I have no default constructor but this is definitely not the case. I have been studying this so much that I can only conclude that the problem must be with the library itself. I have followed any information on it as best I know how.
The controller is for creating a form for the user. Since the "IllegalArgumentException" will be thrown if I try to set the root node's scene twice, I use the root node's id in my constructor for purposes of avoiding the exception.
Any help is much appreciated. Thanks.
My code:
#sfxml
class ToolbarController(private val rootLayout: BorderPane) {
val parent = calcParent
import javafx.application.Platform
def newForm = {
new JFXPanel()
Platform.runLater(new Runnable() {
override def run() {
val dialogStage = new Stage {
scene = new Scene(parent) {
stylesheets = List(getClass.getResource("/scala/css/form.css").toExternalForm)
}
}
dialogStage.show()
}
})
}
def calcParent: Parent = {
val resource = getClass.getResource("scala/form.fxml")
if(rootLayout.scene == null)
FXMLView(resource, NoDependencyResolver)
else rootLayout.getParent
}
}
The FXML:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<BorderPane id="rootLayout"maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="FormController">
<center>...
And my stack trace:
Exception in Application start method
Workaround until RT-13281 is implemented: keep toolkit alive
[error] (run-main-0) java.lang.RuntimeException: Exception in Application start method
java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(LauncherImpl.java:182)
at com.sun.javafx.application.LauncherImpl$$Lambda$11/1268584418.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException:
/Users/patrickslagle/scala/MyApps/PattyCakes/target/scala-2.11/classes/scala/calendar.fxml:7
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2605)
at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:104)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:928)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:967)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2711)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2531)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3218)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3179)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3152)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3128)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3108)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3101)
at Calendar$.delayedEndpoint$Calendar$1(Calendar.scala:15)
at Calendar$delayedInit$body.apply(Calendar.scala:9)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scalafx.application.JFXApp$$anonfun$init$1.apply(JFXApp.scala:297)
at scalafx.application.JFXApp$$anonfun$init$1.apply(JFXApp.scala:297)
at scala.collection.immutable.List.foreach(List.scala:383)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:45)
at scalafx.application.JFXApp$class.init(JFXApp.scala:297)
at Calendar$.init(Calendar.scala:9)
at scalafx.application.AppHelper.start(AppHelper.scala:33)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863)
at com.sun.javafx.application.LauncherImpl$$Lambda$62/2116169040.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl$$Lambda$58/1458556428.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$60/778909025.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$59/1397409682.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Caused by: java.lang.InstantiationException: controller.ToolbarController
at java.lang.Class.newInstance(Class.java:427)
at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:923)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:967)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2711)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2531)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3218)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3179)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3152)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3128)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3108)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3101)
at Calendar$.delayedEndpoint$Calendar$1(Calendar.scala:15)
at Calendar$delayedInit$body.apply(Calendar.scala:9)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scalafx.application.JFXApp$$anonfun$init$1.apply(JFXApp.scala:297)
at scalafx.application.JFXApp$$anonfun$init$1.apply(JFXApp.scala:297)
at scala.collection.immutable.List.foreach(List.scala:383)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:45)
at scalafx.application.JFXApp$class.init(JFXApp.scala:297)
at Calendar$.init(Calendar.scala:9)
at scalafx.application.AppHelper.start(AppHelper.scala:33)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863)
at com.sun.javafx.application.LauncherImpl$$Lambda$62/2116169040.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl$$Lambda$58/1458556428.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$60/778909025.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$59/1397409682.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Caused by: java.lang.NoSuchMethodException: controller.ToolbarController.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:923)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:967)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2711)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2531)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3218)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3179)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3152)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3128)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3108)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3101)
at Calendar$.delayedEndpoint$Calendar$1(Calendar.scala:15)
at Calendar$delayedInit$body.apply(Calendar.scala:9)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scalafx.application.JFXApp$$anonfun$init$1.apply(JFXApp.scala:297)
at scalafx.application.JFXApp$$anonfun$init$1.apply(JFXApp.scala:297)
at scala.collection.immutable.List.foreach(List.scala:383)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:45)
at scalafx.application.JFXApp$class.init(JFXApp.scala:297)
at Calendar$.init(Calendar.scala:9)
at scalafx.application.AppHelper.start(AppHelper.scala:33)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863)
at com.sun.javafx.application.LauncherImpl$$Lambda$62/2116169040.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl$$Lambda$58/1458556428.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$60/778909025.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$59/1397409682.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
[trace] Stack trace suppressed: run last pattycakes/compile:run for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last pattycakes/compile:run for the full output.
[error] (pattycakes/compile:run) Nonzero exit code: 1
[error] Total time: 46 s, completed May 26, 2016 4:18:42 PM
You should not instantiate a class annotated with #fxml directly. This class is modified by the SFXML compiler macro. It is not shown in the code you posted but somewhere you must instantiate ToolbarController to call newForm. Posting Minimal, Complete, and Verifiable example is very important.
Attempting to directly instantiate ToolbarController is the most likely cause of the NoSuchMethodExceptions as ToolbarController constructor is modified by the macro. You need to move methods newForm and calcParent outside of ToolbarController. Only instantiate ToolbarController using FXMLView(resource, ...). You also need to add a reference to ToolbarControllerin the FXML file in the top pane:
<BorderPane ... fx:controller="mypackage.ToolbarController"> ...
With that the FXMLView can instantiate ToolbarController using only reference to the FXML file. For instance, the instantiation could look like this:
import java.io.IOException
import scalafx.Includes._
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.scene.Scene
import scalafxml.core.{NoDependencyResolver, FXMLView}
object MyFXMLDemo extends JFXApp {
val resource = getClass.getResource("/scala/css/form.css")
if (resource == null) {
throw new IOException("Cannot load resource: /scala/css/form.css")
}
val root = FXMLView(resource, NoDependencyResolver)
stage = new PrimaryStage() {
scene = new Scene(root)
}
}
Please take look carefully at the example at https://github.com/vigoo/scalafxml-unit-converter-example.

Groovy program to connect mongo db

I am trying to connect mongodb using Groovy language but i am getting error like this (which is posted below) and i have added necessary jar file.I am using mongodb verion : mongodb-driver-3.2.2.jar .
Please help me to solve this problem
Exception in thread "main" java.lang.NoClassDefFoundError: com/mongodb/operation/OperationExecutor
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getDeclaredConstructors(Unknown Source)
at org.codehaus.groovy.reflection.CachedClass$2$1.run(CachedClass.java:69)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:67)
at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:64)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at org.codehaus.groovy.reflection.CachedClass.getConstructors(CachedClass.java:258)
at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:213)
at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:223)
at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createNormalMetaClass(MetaClassRegistry.java:168)
at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createWithCustomLookup(MetaClassRegistry.java:158)
at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.create(MetaClassRegistry.java:141)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:209)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:241)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:255)
at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:859)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallConstructorSite(CallSiteArray.java:84)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:194)
at com.sample.MongoService.client(MongoService.groovy:14)
at com.sample.MongoService.collection(MongoService.groovy:21)
at com.sample.MongoService$collection.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.sample.MongoDBController.method(MongoDBController.groovy:10)
at com.sample.MongoDBController$method.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at com.sample.GroovyDemoApp.main(GroovyDemoApp.groovy:12)
Caused by: java.lang.ClassNotFoundException: com.mongodb.operation.OperationExecutor
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 35 more
Update :
This is my Groovy code. with this code i am trying to connect Mongodb
// error is in this line . i .e -
// The type com.mongodb.operation.CreateIndexesOperation cannot be resolved.
// It is indirectly referenced from required .class files )
package com.sample
import com.mongodb.*
class MongoService {
private static MongoClient mongoClient
private static host = "localhost" //your host name
private static port = 27017 //your port no.
private static databaseName = "db"
public static MongoClient client() {
if(mongoClient == null){
return new MongoClient(host,port)
}else {
return mongoClient
}
}
public DBCollection collection(collectionName) {
DB db = client().getDB(databaseName)
return db.getCollection(collectionName)
}
}
To use the MongoDB driver you can either use the JAR, or #Grab it from Maven.
Using the JAR
To use the JAR, you need to add it to Groovy's classpath. This is done with the -cp argument:
#!/usr/bin/env groovy -cp /path/to/jar/file
println 'Hello'
Using Maven
You can simply use Groovy's #Grab to take care of the dependency for you:
#Grab('org.mongodb:mongodb-driver:3.2.2')
println 'Hello'
Working example
Here's a working example based on the code you posted:
#Grab('org.mongodb:mongodb-driver:3.2.2')
import com.mongodb.MongoClient
import com.mongodb.DBCollection
import com.mongodb.DB
import com.mongodb.BasicDBObject
class MongoService {
private MongoClient mongoClient
def host = "localhost" //your host name
def port = 27017 //your port no.
def databaseName = 'test'
public MongoClient client() {
mongoClient = mongoClient ?: new MongoClient(host, port)
return mongoClient
}
public DBCollection collection(collectionName) {
DB db = client().getDB(databaseName)
return db.getCollection(collectionName)
}
}
def service = new MongoService(databaseName: 'db')
def foo = service.collection('foo')
def data = [
[firstName: 'Jane', lastName: 'Doe'],
[firstName: 'Elvis', lastName: 'Presley']
].collect { it as BasicDBObject }
foo.insert(data)
foo.find().toArray().each {
println it
}
I've never used MongoDB before, so whether my use case is useful or not is debatable.

Strange exception using Jersey with embedded Jetty

I have created an embedded Jetty application which utilizes Jersey in order to implement several RESTful services. I am using some standard code as described here in Stack Overflow as well as other websites:
public static void main(String[] args)
{
Server server = new Server(8080);
ServletContextHandler ctx = new ServletContextHandler(
ServletContextHandler.SESSIONS);
ctx.setContextPath("/");
ServletHolder holder = ctx.addServlet(
"org.glassfish.jersey.servlet.ServletContainer.class", "/*");
holder.setInitOrder(0);
holder.setInitParameter("jersey.config.server.provider.classnames",
RestfulClass.class.getCanonicalName());
server.setHandler(ctx);
try
{
server.start();
server.join();
}
catch(Exception exe)
{
exe.printStackTrace();
}
}
I've used all the recommended jar files, and several other jar files that the various blogs and sites failed to mention. When running the Jetty application, I get the following exception:
java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86)
at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:95)
<several lines omitted for brevty>
Caused by: javax.servlet.UnavailableException: org.glassfish.jersey.servlet.ServletContainer.class
at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:102)
at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:361)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:874)
... 11 more
It is the "UnavailableException" that I do not understand. The ServletContainer class is actually in one of the Jar files (in jersey-container-servlet-core.jar, to be precise), but for some reason it is identified as "unavailable". This is causing a class that is actually in a referenced Jar file to be "not found"!
Can anyone tell me what is causing this UnavailableException and (more importantly) how I can prevent it from being thrown?
Someone please advise...
ServletHolder holder = ctx.addServlet(
"org.glassfish.jersey.servlet.ServletContainer.class", "/*");
You are using a String for the class name. When doing this, you don't use the .class suffix. That at only when you want to get the actual Class object. You have two options
Remove the .class from the String
ServletHolder holder = ctx.addServlet(
"org.glassfish.jersey.servlet.ServletContainer", "/*");
Remove the "" (double quotes) and just use the Class object1.
ServletHolder holder = ctx.addServlet(
org.glassfish.jersey.servlet.ServletContainer.class, "/*");
1 - See addServlet(Class, String)

com.mysql.jdbc.Driver not found when trying to add SQL features in Jitsi

I'm coding on Jitsi using Eclipse: I have to use JDBC to connect to MySQL database, so I've imported java.sql.* in my MainFrame class and I've included mysql-connector-java-5.1.18.jar into "Java Build Path" -> "Libraries".
When I run the project, I've this error:
IOException in readRegistry: java.io.EOFException
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver not found by [76]
at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at net.java.sip.communicator.impl.gui.main.MainFrame.init(MainFrame.java:301)
at net.java.sip.communicator.impl.gui.main.MainFrame.<init>(MainFrame.java:239)
at net.java.sip.communicator.impl.gui.UIServiceImpl.loadApplicationGui(UIServiceImpl.java:133)
at net.java.sip.communicator.impl.gui.GuiActivator.start(GuiActivator.java:129)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1827)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1744)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1148)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Unknown Source)
I've created another project separated from Jitsi and I've tested my code following the same procedure (including java.sql.*; , adding the library), but the "new" project works fine and I can connect to my database, Jitsi doesn't.
Source:
import java.sql.*;
public class SQLFirstTime {
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/cdcol";
Connection con = DriverManager.getConnection(url,"user", "pass");
// ...
con.close();
} catch(SQLException sqlEx) {
System.out.println("Errore SQL");
sqlEx.printStackTrace();
} catch(ClassNotFoundException cnfEx) {
System.out.println("Class NOT FOUND!");
cnfEx.printStackTrace();
}
}
}
Thanks,
also if i'm using Ant to build the project how can I include the JDBC library?