I have a gRPC server written in Java, that is trying to access Firestore and other services, through a Service Account that has Project Owner roles. The server ran successfully plenty of times, but when I tried to run again, this happened:
Exception in thread "main" java.util.ServiceConfigurationError: io.grpc.NameResolverProvider: Provider io.grpc.grpclb.SecretGrpclbNameResolverProvider$Provider could not be instantiated
at java.util.ServiceLoader.fail(ServiceLoader.java:232)
at java.util.ServiceLoader.access$100(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at io.grpc.ServiceProviders.loadAll(ServiceProviders.java:67)
at io.grpc.NameResolverRegistry.getDefaultRegistry(NameResolverRegistry.java:101)
at io.grpc.internal.AbstractManagedChannelImplBuilder.<init>(AbstractManagedChannelImplBuilder.java:107)
at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.<init>(NettyChannelBuilder.java:136)
at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.<init>(NettyChannelBuilder.java:131)
at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.forAddress(NettyChannelBuilder.java:117)
at io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider.builderForAddress(NettyChannelProvider.java:37)
at io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider.builderForAddress(NettyChannelProvider.java:23)
at io.grpc.ManagedChannelBuilder.forAddress(ManagedChannelBuilder.java:39)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:270)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.access$1500(InstantiatingGrpcChannelProvider.java:71)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider$1.createSingleChannel(InstantiatingGrpcChannelProvider.java:202)
at com.google.api.gax.grpc.ChannelPool.create(ChannelPool.java:72)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:209)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:192)
at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:155)
at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:122)
at com.google.cloud.firestore.spi.v1.GrpcFirestoreRpc.<init>(GrpcFirestoreRpc.java:122)
at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:90)
at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:82)
at com.google.cloud.ServiceOptions.getRpc(ServiceOptions.java:561)
at com.google.cloud.firestore.FirestoreOptions.getFirestoreRpc(FirestoreOptions.java:385)
at com.google.cloud.firestore.FirestoreImpl.<init>(FirestoreImpl.java:67)
at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreFactory.create(FirestoreOptions.java:73)
at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreFactory.create(FirestoreOptions.java:66)
at com.google.cloud.ServiceOptions.getService(ServiceOptions.java:541)
at services.FirestoreServiceActions.<init>(FirestoreServiceActions.java:25)
at CNTextServer.main(CNTextServer.java:47)
Caused by: java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.newInstance(Class.java:412)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
... 30 more
To simplify things and to turnaround some major problems that may happen on IntelliJ Idea,
I've created a much simpler (Maven) project that just has some code to start the server, and it worked fine, the server runs perfectly.
Although, when I add the line that initializes the Firestore service, the same Exceptions are thrown.
I have an environment variable (GOOGLE_APPLICATION_CREDENTIALS) pointing to a key of a service account that has Project Owner roles, just like I've mentioned before. I've also tried the FileInputStream alternative, pointing to the key, with no success.
The code of my simpler (Maven) project is:
private static final int SERVICE_PORT = 8000;
private Firestore firestoreService
public static void main(String[] args) {
try {
System.out.println("--> SETTING UP THE SERVER...");
GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(SERVICE_ACCOUNT_KEY_PATH));
this.firestoreService = FirestoreOptions.newBuilder().setCredentials(credentials).build().getService();
Server service = ServerBuilder
.forPort(SERVICE_PORT)
.addService(new CNTextServer())
.build();
service.start();
System.out.println("--- SERVER STARTED. LISTENING ON PORT " + SERVICE_PORT);
System.out.println("--> PRESS 'ENTER' TO STOP THE SERVER");
Scanner scanner = new Scanner(System.in);
scanner.nextLine();
System.out.println("<-- SERVER SHUTTING DOWN...");
service.shutdown();
} catch (Exception ex) {
System.out.println("### EXCEPTION ON SERVER.MAIN() ###\n" + ex.getMessage());
}
}
The dependencies on the Maven pom.xml file are:
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.28.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.28.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.28.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-firestore</artifactId>
<version>1.34.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.108.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>1.106.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-compute</artifactId>
<version>0.118.0-alpha</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-vision</artifactId>
<version>1.99.3</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-translate</artifactId>
<version>1.94.5</version>
</dependency>
<dependency>
<groupId>leic.cn.li62d-g04</groupId>
<artifactId>CNTextContract</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/../CNTextContract/target/CNTextContract-1.0-SNAPSHOT.jar</systemPath>
</dependency>
</dependencies>
Running mvn dependency:tree we see:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # examples ---
[INFO] com.example:examples:jar:1.0.0
[INFO] +- io.grpc:grpc-netty-shaded:jar:1.28.0:compile
[INFO] | \- io.grpc:grpc-core:jar:1.28.0:compile (version selected from constraint [1.28.0,1.28.0])
[INFO] +- io.grpc:grpc-protobuf:jar:1.28.0:compile
[INFO] | +- io.grpc:grpc-api:jar:1.28.0:compile
[INFO] | +- com.google.protobuf:protobuf-java:jar:3.11.0:compile
[INFO] | +- com.google.guava:guava:jar:28.1-android:compile
[INFO] | +- com.google.api.grpc:proto-google-common-protos:jar:1.17.0:compile
[INFO] | \- io.grpc:grpc-protobuf-lite:jar:1.28.0:compile
[INFO] +- io.grpc:grpc-stub:jar:1.28.0:compile
[INFO] +- com.google.cloud:google-cloud-firestore:jar:1.34.0:compile
[INFO] | +- com.google.cloud:google-cloud-core-grpc:jar:1.93.5:compile
...
[INFO] | +- io.grpc:grpc-context:jar:1.29.0:compile
[INFO] | +- com.google.api:gax:jar:1.56.0:compile
[INFO] | +- com.google.auth:google-auth-library-oauth2-http:jar:0.20.0:compile
[INFO] | +- com.google.errorprone:error_prone_annotations:jar:2.3.4:compile
[INFO] | +- org.codehaus.mojo:animal-sniffer-annotations:jar:1.18:compile
[INFO] | +- com.google.api:gax-grpc:jar:1.56.0:compile
[INFO] | +- io.grpc:grpc-auth:jar:1.29.0:compile
[INFO] | +- io.grpc:grpc-alts:jar:1.29.0:compile
[INFO] | +- io.grpc:grpc-grpclb:jar:1.29.0:compile
The problem is that grpc-core is too old. You can see io.grpc:grpc-core:jar:1.28.0 and io.grpc:grpc-grpclb:jar:1.29.0:compile. grpclb depends on grpc-core 1.29.0. In 1.29.0 GrpclbNameResolver was added that extends DnsNameResolver from grpc-core. But in 1.28.0 DnsNameResolver was final. Downgrades are very likely to cause breakages.
To fix the version problem(s) (there's several), move the io.grpc dependencies to the end bump their versions to 1.29.0.
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-firestore</artifactId>
<version>1.34.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.108.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>1.106.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-compute</artifactId>
<version>0.118.0-alpha</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-vision</artifactId>
<version>1.99.3</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-translate</artifactId>
<version>1.94.5</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.29.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.29.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.29.0</version>
</dependency>
</dependencies>
Maven has poor transitive dependency resolution, and happily downgrades packages without any warning. It is good practice to use maven-enforcer's requireUpperBoundDeps to detect issues like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireUpperBoundDeps/>
</rules>
</configuration>
</execution>
</executions>
</plugin>
With your broken dependencies, it would have noticed the downgrades:
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireUpperBoundDeps failed with message:
Failed while enforcing RequireUpperBoundDeps. The error(s) are [
Require upper bound dependencies error for io.grpc:grpc-netty-shaded:1.28.0 paths to dependency are:
+-com.example:examples:1.0.0
+-io.grpc:grpc-netty-shaded:1.28.0
and
+-com.example:examples:1.0.0
+-com.google.cloud:google-cloud-firestore:1.34.0
+-io.grpc:grpc-netty-shaded:1.29.0
,
Require upper bound dependencies error for io.grpc:grpc-protobuf:1.28.0 paths to dependency are:
+-com.example:examples:1.0.0
+-io.grpc:grpc-protobuf:1.28.0
and
+-com.example:examples:1.0.0
+-com.google.cloud:google-cloud-firestore:1.34.0
+-io.grpc:grpc-protobuf:1.29.0
and
+-com.example:examples:1.0.0
+-com.google.cloud:google-cloud-pubsub:1.106.0
+-io.grpc:grpc-protobuf:1.29.0
...
Related
I've been stuck on this error now for a few days. I've googled the heck out it and tried at least a dozen different proposed solutions in various forms...
My project runs fine, UNTIL I attempt to use a specific library called MonacoFX, which, according to the GitHub page, was developed in Java 13 (I'm using Java 16.0.1 for this project). The documentation for the library is straight forward, you instantiate the library like you do with most libraries, then you simply use it. However, as soon as I attempt to instantiate it, I get this error at runtime:
Exception in thread "JavaFX Application Thread"
java.lang.IllegalAccessError: superclass access check failed:
class com.sun.javafx.sg.prism.web.NGWebView (in unnamed module #0x1937acaf)
cannot access class com.sun.javafx.sg.prism.NGGroup (in module javafx.graphics)
because module javafx.graphics does not export
com.sun.javafx.sg.prism to unnamed module #0x1937acaf
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at eu.mihosoft.monacofx#0.0.7/eu.mihosoft.monacofx.MonacoFX.<init>(MonacoFX.java:49)
at com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.data.GistFile.<init>(GistFile.java:28)
at com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.data.GistObject.process(GistObject.java:113)
at com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.data.GistObject.<init>(GistObject.java:27)
at com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.github.GitHubApi.setGitHub(GitHubApi.java:31)
at com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.ui.LoginWindowController.authenticate(LoginWindowController.java:39)
at com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.ui.LoginWindow.lambda$new$1(LoginWindow.java:57)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8889)
at javafx.controls/javafx.scene.control.Button.fire(Button.java:203)
at javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:208)
at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3856)
at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1851)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2584)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:409)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:299)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:447)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:446)
at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
at javafx.graphics/com.sun.glass.ui.mac.MacView.notifyMouse(MacView.java:127)
It looks like the developer of the library hasn't been active on that GitHub page for quite some time now, though I did create an issue nonetheless.
I've tried the solutions where they say to use the command line argument, which mine looks like this:
--module-path /Library/Java/JavaVirtualMachines/jdk-16.0.1.jdk/Contents/Home/lib
--add-modules javafx.controls,javafx.fxml,javafx.web,javafx.graphics,javafx.media
I've tried using a separate Launcher class:
public class Launcher {
public static void main(String[] args) {
Main.main(args);
}
}
And nothing is working, the error happens at the moment I try to instantiate the library.
So I'm seeking any insight or knowledge that anyone might have on this problem ... OR ... if anyone knows of a good JavaFX library that provides language-aware code style editing, I'd be keenly interested in that.
Here is my POM file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dustinredmond</groupId>
<artifactId>NewGistFX</artifactId>
<version>1.0-SNAPSHOT</version>
<name>NewGistFX</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.7.1</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>16</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>16</version>
</dependency>
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>11.1.0</version>
</dependency>
<dependency>
<groupId>net.synedra</groupId>
<artifactId>validatorfx</artifactId>
<version>0.1.13</version>
<exclusions>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.mylyn.github</groupId>
<artifactId>org.eclipse.egit.github.core</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>com.fifesoft</groupId>
<artifactId>rsyntaxtextarea</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.dustinredmond.fxtrayicon</groupId>
<artifactId>FXTrayIcon</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.133</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.5.31</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.2</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>5.5.3</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>eu.mihosoft.monacofx</groupId>
<artifactId>monacofx</artifactId>
<version>0.0.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.7</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.dustinredmond.newgistfx/com.dustinredmond.newgistfx.Main</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And here is my module-info file:
module com.dustinredmond.newgistfx {
requires javafx.controls;
requires javafx.fxml;
requires org.controlsfx.controls;
requires validatorfx;
requires javafx.graphics;
requires java.prefs;
requires org.apache.commons.codec;
requires github.api;
requires org.apache.commons.io;
requires rsyntaxtextarea;
requires java.desktop;
requires FXTrayIcon;
requires org.eclipse.egit.github.core;
requires okhttp3;
requires eu.mihosoft.monacofx;
exports com.dustinredmond.newgistfx.ui;
opens com.dustinredmond.newgistfx to javafx.base;
opens com.dustinredmond.newgistfx.data to javafx.base;
}
I am grateful for any assistance that anyone can offer.
Thank you
How to debug dependencies
Include the maven dependency plugin in your project.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.0</version>
</plugin>
</plugins>
</build>
Run mvn dependency:tree on your project.
[INFO] --- maven-dependency-plugin:3.2.0:tree (default-cli) # NewGistFX ---
[INFO] com.dustinredmond:NewGistFX:jar:1.0-SNAPSHOT
[INFO] +- org.openjfx:javafx-controls:jar:16:compile
[INFO] | +- org.openjfx:javafx-controls:jar:win:16:compile
[INFO] | \- org.openjfx:javafx-graphics:jar:16:compile
[INFO] | \- org.openjfx:javafx-graphics:jar:win:16:compile
[INFO] +- org.openjfx:javafx-fxml:jar:16:compile
[INFO] | \- org.openjfx:javafx-fxml:jar:win:16:compile
[INFO] +- org.controlsfx:controlsfx:jar:11.1.0:compile
[INFO] +- net.synedra:validatorfx:jar:0.1.13:compile
[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.7.1:test
[INFO] | +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | \- org.junit.platform:junit-platform-commons:jar:1.7.1:test
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.7.1:test
[INFO] | \- org.junit.platform:junit-platform-engine:jar:1.7.1:test
[INFO] +- org.eclipse.mylyn.github:org.eclipse.egit.github.core:jar:2.1.5:compile
[INFO] | \- com.google.code.gson:gson:jar:2.2.2:compile
[INFO] +- com.fifesoft:rsyntaxtextarea:jar:3.1.3:compile
[INFO] +- junit:junit:jar:4.13.1:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- com.dustinredmond.fxtrayicon:FXTrayIcon:jar:3.1.1:compile
[INFO] +- org.kohsuke:github-api:jar:1.133:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.9:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.12.5:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.5:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.5:compile
[INFO] | \- commons-io:commons-io:jar:2.8.0:compile
[INFO] +- com.squareup.okio:okio:jar:2.10.0:compile
[INFO] | +- org.jetbrains.kotlin:kotlin-stdlib:jar:1.4.20:compile
[INFO] | | \- org.jetbrains:annotations:jar:13.0:compile
[INFO] | \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.4.20:compile
[INFO] +- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.5.31:compile
[INFO] | \- org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.5.31:compile
[INFO] +- com.squareup.okhttp3:okhttp:jar:4.9.2:compile
[INFO] +- org.springframework.security:spring-security-crypto:jar:5.5.3:compile
[INFO] +- commons-codec:commons-codec:jar:1.15:compile
[INFO] \- eu.mihosoft.monacofx:monacofx:jar:0.0.7:compile
[INFO] +- org.openjfx:javafx-base:jar:12.0.1:compile
[INFO] | \- org.openjfx:javafx-base:jar:win:12.0.1:compile
[INFO] +- org.openjfx:javafx-web:jar:12.0.1:runtime
[INFO] | \- org.openjfx:javafx-web:jar:win:12.0.1:runtime
[INFO] \- org.openjfx:javafx-media:jar:12.0.1:runtime
[INFO] \- org.openjfx:javafx-media:jar:win:12.0.1:runtime
Issues with your project and how to fix them
Note that your project is using javafx-controls/javafx-graphics 16 and monacofx is depending on javafx-base/javafx-web/javafx-media 12.0.1.
JavaFX does not support mixing JavaFX module versions, so it breaks.
Do not do this.
Fix the versioning in your pom.xml so that all JavaFX modules are the same version.
Also, you are defining a module-info.java file, you need to add the required dependencies to your module-info for this to work. So fix them (see my example below, note it requires javafx.web and eu.mihosoft.monacofx).
Don't do the launcher hack to create a Launcher.java file. JavaFX is not architected to run that way and it is not supported.
If you are going to run from the command line, you need to specify the module path to all of the modules you are using, not just the JDK modules. In fact you don't need the JDK modules added explicitly to the module path, they will be added automatically as they are implicitly part of the jdk image you are working with.
You are using Maven, so all of the required non-jdk dependencies to be placed on the module path are in your Maven repository, you can get them from there. If you use an IDE like Idea and have managed to get the app to run in the IDE (without using the JavaFX maven plugin to run it), then look at the command line the IDE used to run the app, specifically the module path (or -p) option, and copy everything from there and use the same thing when trying to run from the command prompt.
OR, create a proper runtime image (google it) using jlink/jdeps and perhaps jpackage, and use that to execute your app.
MonacoFX doesn't have a module-info.java file, so you won't be able to use jlink to include it until the developer creates a new package with a module-info.java file. You could file a feature request for the project for them to do that if you wish.
And maybe also another feature request for them to not require JavaFX 12 packages as dependencies
For example, in a Maven build those dependencies in the Monaco project could be marked as provided, for instance and the documentation for the Monaco project could note that in order for it work certain JavaFX modules must be on the module path.
Sample application
This is just using the sample app from MonacoFX
package com.example.monacotest;
import eu.mihosoft.monacofx.MonacoFX;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class MonacoTestApp extends Application {
public static void main(String[] args) {
launch(args);
}
#Override
public void start(Stage primaryStage) throws Exception {
// create a new monaco editor node
MonacoFX monacoFX = new MonacoFX();
StackPane root = new StackPane(monacoFX);
// set initial text
monacoFX.getEditor().getDocument().setText(
"""
#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
"""
);
// use a predefined language like 'c'
monacoFX.getEditor().setCurrentLanguage("c");
monacoFX.getEditor().setCurrentTheme("vs-dark");
// the usual scene & stage setup
Scene scene = new Scene(root, 800,600);
primaryStage.setTitle("MonacoFX Demo (running on JDK " + System.getProperty("java.version") + ")");
primaryStage.setScene(scene);
primaryStage.show();
}
}
module-info.java
I only require the stuff to make Monaco work for the test. You can add the rest of the things you need into your project.
You must require javafx.web, or you will get the error shown in your question.
module com.example.monacotest {
requires javafx.web;
requires eu.mihosoft.monacofx;
exports com.example.monacotest;
}
pom.xml
We exclude the JavaFX dependencies of monacofx, and define all of the necessary dependencies for JavaFX directly in our project, with the correct versions.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.monacotest</groupId>
<artifactId>MonacoTestApp</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<javafx.version>17.0.1</javafx.version>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>eu.mihosoft.monacofx</groupId>
<artifactId>monacofx</artifactId>
<version>0.0.7</version>
<exclusions>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Correct dependency tree:
[INFO] --- maven-dependency-plugin:3.2.0:tree (default-cli) # MonacoTestApp ---
[INFO] com.example.monacotest:MonacoTestApp:jar:1.0-SNAPSHOT
[INFO] +- org.openjfx:javafx-web:jar:17.0.1:compile
[INFO] | +- org.openjfx:javafx-web:jar:win:17.0.1:compile
[INFO] | +- org.openjfx:javafx-controls:jar:17.0.1:compile
[INFO] | | +- org.openjfx:javafx-controls:jar:win:17.0.1:compile
[INFO] | | \- org.openjfx:javafx-graphics:jar:17.0.1:compile
[INFO] | | +- org.openjfx:javafx-graphics:jar:win:17.0.1:compile
[INFO] | | \- org.openjfx:javafx-base:jar:17.0.1:compile
[INFO] | | \- org.openjfx:javafx-base:jar:win:17.0.1:compile
[INFO] | \- org.openjfx:javafx-media:jar:17.0.1:compile
[INFO] | \- org.openjfx:javafx-media:jar:win:17.0.1:compile
[INFO] \- eu.mihosoft.monacofx:monacofx:jar:0.0.7:compile
I have a Google App Engine project that I'm building with maven. I added jax-rs to it by adding the following bom to my pom:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bom</artifactId>
<version>0.73.0-alpha</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>2.27</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Also I needed these three dependencies:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<exclusions>
<exclusion><!-- Exclude this repackaged javax.inject. -->
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>javax.inject</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<exclusions>
<exclusion><!-- Exclude this repackaged javax.inject. -->
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>javax.inject</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
</dependency>
As you can see I have excluded some of the repackaged to get rid of some runtime warnings about duplicate classes being found. To be clear, every rest call using the jax-rs api's works fine and I don't see the warnings on google app engine itself, just locally. (full code at https://github.com/Leejjon/blindpool) When running it on the local jetty runtime using 'mvn appengine:run', it still complains about every json related class in the javax.json-1.1.jar and javax.json-api-1.1.jar.
Example
[INFO] GCLOUD: 2018-12-11 22:01:13.495:WARN:oeja.AnnotationParser:main: Unknown asm implementation version, assuming version 393216
[INFO] GCLOUD: 2018-12-11 22:01:13.780:WARN:oeja.AnnotationParser:qtp551734240-15: javax.json.Json scanned from multiple locations: jar:file:///C:/Users/Leejjon/IdeaProjects/Blindpool/backend/target/blindpool-1.0-SNAPSHOT/WEB-INF/lib/javax.json-api-1.1.jar!/javax/json/Json.class, jar:file:///C:/Users/Leejjon/IdeaProjects/Blindpool/backend/target/blindpool-1.0-SNAPSHOT/WEB-INF/lib/javax.json-1.1.jar!/javax/json/Json.class
When I look at my 'mvn dependency:tree' output I can see that my 'jersey-media-json-binding' dependency has both javax.json-1.1 and javax.json-api-1.1 in it. And they have classes that have the same names.
[INFO] +- org.glassfish.jersey.media:jersey-media-json-binding:jar:2.27:compile
[INFO] | +- org.glassfish:javax.json:jar:1.1:compile
[INFO] | +- org.eclipse:yasson:jar:1.0:compile
[INFO] | | +- javax.json:javax.json-api:jar:1.1:compile
[INFO] | | \- javax.enterprise:cdi-api:jar:2.0:compile
[INFO] | | +- javax.el:javax.el-api:jar:3.0.0:compile
[INFO] | | \- javax.interceptor:javax.interceptor-api:jar:1.2:compile
[INFO] | \- javax.json.bind:javax.json.bind-api:jar:1.0:compile
Full dependency tree (https://pastebin.com/JfwzavDX).
I have tried to exclude them but failed to do so in a way that didn't cause me to actually break my web app and get errors like: javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.ExceptionInInitializerError
TLDR: What dependency to I exclude here to get rid of the duplicate location warning thrown by the 'mvn appengine:run' command without breaking the jax-rs application.
Hoping for that jax-rs/maven/jetty/jersey/google app engine god to pass by and point me in the right direction :)
I have a selenium cucumber testng framework using maven. I was hoping to get step descriptions when I run my cucumber tests with testng. It was an old project so I have changed my dependencies from info.cukes to the latest version of io.cucumber. However it seems to be throwing out errors whenever I run the runner test file.
java.lang.NoSuchMethodError: cucumber.runtime.RuntimeOptions.getPluginFormatterNames()Ljava/util/List;
at cucumber.runtime.formatter.Plugins.createPlugins(Plugins.java:64)
at cucumber.runtime.formatter.Plugins.<init>(Plugins.java:37)
at cucumber.api.testng.TestNGCucumberRunner.<init>(TestNGCucumberRunner.java:56)
at cucumber.api.testng.AbstractTestNGCucumberTests.setUpClass(AbstractTestNGCucumberTests.java:16)
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:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:458)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:168)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
I have the following maven dependencies but have no idea if it is a dependency that I am missing to get the test to run? Any Help would be greatly appreciated. As when I have search this issue it seems that it is mostly solved by having the same version dependencies of all the io.cucumber files which I do.
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>4.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.21.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/tag-expressions -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>tag-expressions</artifactId>
<version>1.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-expressions -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-expressions</artifactId>
<version>6.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/messages -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>messages</artifactId>
<version>2.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java8 -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java8</artifactId>
<version>4.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.mkolisnyk/cucumber-report-generator -->
<dependency>
<groupId>com.github.mkolisnyk</groupId>
<artifactId>cucumber-report-generator</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>6.0.14</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/gherkin -->
<!--<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
<scope>provided</scope>
</dependency>-->
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>4.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ru.sbtqa.tag/cucumber-runner -->
<dependency>
<groupId>ru.sbtqa.tag</groupId>
<artifactId>cucumber-runner</artifactId>
<version>1.0.7</version>
</dependency>
Check maven pom.xml cucumber-core cucumber-java cucumber-junit
These files should have the same version. In your example, cucumber-java artifact id has a different version than the rest.
Try changing it.
Find below some snippets to break down the problem
check if there is a transitive dependency to groupid info.cukes
$ mvn dependency:tree | grep 'info.cuke'
[INFO] | +- info.cukes:cucumber-junit:jar:1.2.5:compile
[INFO] | | \- info.cukes:cucumber-core:jar:1.2.5:compile
[INFO] | | +- info.cukes:cucumber-html:jar:0.2.3:compile
[INFO] | | \- info.cukes:cucumber-jvm-deps:jar:1.0.5:compile
[INFO] | +- info.cukes:cucumber-testng:jar:1.2.5:compile
[INFO] | +- info.cukes:cucumber-java:jar:1.2.5:compile
[INFO] | +- info.cukes:gherkin:jar:2.12.2:compile
when checking the full output reveals which of your dependency depends on it
...
[INFO] +- com.github.mkolisnyk:cucumber-report-generator:jar:1.3:compile
...
[INFO] | +- info.cukes:cucumber-junit:jar:1.2.5:compile
...
[INFO] | +- info.cukes:cucumber-testng:jar:1.2.5:compile
...
[INFO] \- ru.sbtqa.tag:cucumber-runner:jar:1.0.7:compile
[INFO] \- ru.sbtqa.tag:cucumber-runner:jar:1.0.7:compile
[INFO] +- ru.yandex.qatools.allure:allure-cucumber-jvm-adaptor:jar:1.6.4:compile
...
[INFO] | +- info.cukes:cucumber-core:jar:1.2.5:compile
...
[INFO] | +- info.cukes:cucumber-java:jar:1.2.5:compile
[INFO] | +- info.cukes:gherkin:jar:2.12.2:compile
...
[INFO] +- info.cukes:cucumber-junit:jar:1.2.5:compile
as there might be an overlapping of classed with the same qualified name, exclude those transient dependencies in the pom.xml
<dependency>
<groupId>com.github.mkolisnyk</groupId>
<artifactId>cucumber-report-generator</artifactId>
<version>1.3</version>
<exclusions>
<exclusion>
<groupId>info.cukes</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
running the test again it throws an exception
java.lang.NoClassDefFoundError: gherkin/IGherkinDialectProvider
as we explicitly define the dependency io.cucumber:gherkin it might be related to the specified <version>, comment it out to see if another version is fetched
<!--<dependency>-->
<!--<groupId>io.cucumber</groupId>-->
<!--<artifactId>gherkin</artifactId>-->
<!--<version>6.0.14</version>-->
<!--</dependency>-->
this reveals that io.cucumber:cucumber-core:jar:4.2.0 depends on version 5.1.0 of io.cucumber:gherkin
$ mvn dependency:tree
...
[INFO] +- io.cucumber:cucumber-core:jar:4.2.0:compile
[INFO] | +- io.cucumber:cucumber-html:jar:0.2.7:compile
[INFO] | +- io.cucumber:gherkin:jar:5.1.0:compile
With those changes at least the TestNG unit test is running.
As the dependencies com.github.mkolisnyk:cucumber-report-generator and ru.sbtqa.tag:cucumber-runner depending on the info.cuke dependencies they might not work correctly anymore. To solve this kind of problem you could:
check for a newer version which might not depend on group id info.cuke
use earlier version of io.cucumber dependencies
use a more finegrained exclusion of the info.cuke dependencies, instead of excluding all artifact ids
a combination of above points
something else, depending on your use case and requirements
Maybe those steps help you to find a solution working for you.
I use geckodriver v0.15.0 (Latest release) and Firefox 52.0.1 (64 bits)
Here is my code :
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
Here is the dependencies for Selenium in my pom (latest version of Selenium) :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>3.3.1</version>
<scope>test</scope>
</dependency>
And the exception at runtime :
Exception in thread "main" java.lang.NoSuchMethodError: org.openqa.selenium.net.PortProber.waitForPortUp(IILjava/util/concurrent/TimeUnit;)V
at org.openqa.selenium.firefox.GeckoDriverService.waitUntilAvailable(GeckoDriverService.java:73)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
If I add this dependency :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.3.1</version>
</dependency>
I have got another exception :
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/Interactive
What dependency is missing? Thank you.
UPDATE
mvn dependency:tree with htmlunit-driver 2.25, selenium-remote-driver 3.3.1, selenium-firefox-driver 3.3.1, selenium-support 3.3.1
[INFO] +- org.seleniumhq.selenium:htmlunit-driver:jar:2.25:compile
[INFO] | +- org.seleniumhq.selenium:selenium-api:jar:2.53.1:compile
[INFO] | \- net.sourceforge.htmlunit:htmlunit:jar:2.21:compile
[INFO] | +- xalan:xalan:jar:2.7.2:compile
[INFO] | | \- xalan:serializer:jar:2.7.2:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] | +- org.apache.httpcomponents:httpmime:jar:4.5.2:compile
[INFO] | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.17:compile
[INFO] | +- net.sourceforge.htmlunit:neko-htmlunit:jar:2.21:compile
[INFO] | | \- xerces:xercesImpl:jar:2.11.0:compile
[INFO] | | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] | +- net.sourceforge.cssparser:cssparser:jar:0.9.18:compile
[INFO] | | \- org.w3c.css:sac:jar:1.3:compile
[INFO] | +- commons-io:commons-io:jar:2.4:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-client:jar:9.4.1.v20170120:compile
[INFO] | +- org.eclipse.jetty:jetty-util:jar:9.4.1.v20170120:compile
[INFO] | +- org.eclipse.jetty:jetty-io:jar:9.4.1.v20170120:compile
[INFO] | +- org.eclipse.jetty:jetty-client:jar:9.4.1.v20170120:compile
[INFO] | | \- org.eclipse.jetty:jetty-http:jar:9.4.1.v20170120:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-common:jar:9.4.1.v20170120:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-api:jar:9.4.1.v20170120:compile
[INFO] +- org.seleniumhq.selenium:selenium-remote-driver:jar:3.3.1:compile
[INFO] | +- cglib:cglib-nodep:jar:3.2.4:compile
[INFO] | +- org.apache.commons:commons-exec:jar:1.3:compile
[INFO] | \- net.java.dev.jna:jna-platform:jar:4.1.0:compile
[INFO] | \- net.java.dev.jna:jna:jar:4.2.2:compile
[INFO] +- org.seleniumhq.selenium:selenium-firefox-driver:jar:3.3.1:compile
[INFO] \- org.seleniumhq.selenium:selenium-support:jar:3.3.1:compile
Update 2
OS: Linux 64 bits
Here is the required dependencies (I cleaned the .m2 directory too) :
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.6</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.3.1</version>
</dependency>
Maybe you have jar versions conflict error. When I had that bug in my application, I found that it was referring the old Selenium jar. To resolve this, I removed the old jar's and rebuild the project with Selenium 3 jars.
Ensure that you have right libraries added to your project.
the command mvn dependency:tree can help you with this.
Note: when you use the test scope it's mean the the dependency is only available for the test compilation and execution phases, So you must put your code in a Test method or remove the scope tag
Hope this helps.
check if you have the selenium-java dependency of the same version as your other dependencies
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.3.1</version>
</dependency>
Add System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir")+"\\geckodriver.exe"); to your code.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class CheckFireFox {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir")+"\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
}
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>StackOverFlow</groupId>
<artifactId>StackOverFlow</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.3.1</version>
</dependency>
</dependencies>
</project>
Console output :
Mar 27, 2017 2:39:01 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Page title is: Google
Update the selenium version
Download the geckodriver and set system path eg "F:\geckodriver-v0.20.1-win64"
Add following code snippet to your existing code
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
Now run the script and it will work for you, hope this helps.
I have a library named my-library which I packaged with Maven and stored on a private Nexus repository. It compiles and gets uploaded to my repo correctly and has the following dependencies specified in its pom.xml file:
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.13</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
I am including this dependency in another project, my-child-project, using the following pom.xml blocks:
<repositories>
<repository>
<id>MyRepo</id>
<name>My Maven Repository</name>
<url>http://localhost:8081/nexus/repo</url>
</repository>
</repositories>
...
<dependencies>
<dependency>
<groupId>com.my.group</groupId>
<artifactId>my-library</artifactId>
<scope>compile</scope>
<version>1.0.0</version>
</dependency>
</dependencies>
When i run mvn clean install in my-child-project, it appears that maven is able to find and download my-library but not the nested dependency on com.google.protobuf unless i include it explicitly in the pom.xml for my-child-project. I can confirm that Maven can see my dependency but not the nested one when running mvn dependency:tree:
...
[INFO] +- org.springframework.data:spring-data-redis:jar:1.7.1.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-keyvalue:jar:1.1.1.RELEASE:compile
[INFO] | \- org.springframework:spring-oxm:jar:4.2.5.RELEASE:compile
[INFO] +- redis.clients:jedis:jar:2.8.1:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- com.my.group:my-library:jar:1.0.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.4.4:compile
...
Is this how a nested library dependency is supposed to work? I thought nested dependencies in other dependencies are automatically resolved and downloaded by Maven in compile scope. I was hoping to only list the nested dependency in my-library and not in my-child-project but it seems that doesn't work.
First, the parent pom.xml should add dependencyManagement tag outside the dependencies tag. This is just to manage the modules dependencies in one place, but not actually import them into your project.
You still have to declare it in your child module's pom. (But you can leave out the version tag, as that will be inherited from the parent pom)
#herokingsley's answer got me to the correct configuration. I was hesitating to try it because the answer seemed to suggest that i need to redeclare the nested dependency in my child. When i finally did try it i purposely did not declare the nested dependency in my-child-project and it still worked like a charm. Here is the code that solved my problem. I changed the code in my-library to the following:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.13</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
The above change was enough as it resulted in the following output when running mvn dependency:tree:
...
[INFO] +- org.springframework.data:spring-data-redis:jar:1.7.1.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-keyvalue:jar:1.1.1.RELEASE:compile
[INFO] | \- org.springframework:spring-oxm:jar:4.2.5.RELEASE:compile
[INFO] +- redis.clients:jedis:jar:2.8.1:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- com.my.group:my-library:jar:1.0.0:compile
[INFO] | \- com.google.protobuf:protobuf-java:jar:3.1.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.4.4:compile
...