java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException - java

I am using Firefox 45.0 and Dependency added in pom.xml is
selenium-firefox-driver 2.53.0.
java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
at TestFIles_MDM.Test_Authn.setup(Test_Authn.java:27)
Error is coming for both Firefox and Chrome.
How can I resolve it, it was working last week.

I think you are missing this dependency in pom.xml:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
Check Selenium docs about Maven dependencies.

Voila, It's worked for me.Just updated the selenium-java dependency in pom.xml
<!-- Selenium java-jar dependency -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
Or here is the link to get the updated version-
https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java

Run mvn dependency:tree in your project, and check what is transitively depending on selenium-remote-driver.
In my project, I was correctly depending on selenium-java at 2.53.1, but another test dependency was depending on an older version (2.40.0); that meant my tests were using the 2.40.0 version of selenium-remote-driver at runtime, which causes the java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException error.
If you have transitive dependencies on selenium-remote-driver, you have two options for "fixing" them:
Update the artifact that's depending on the older version to either
Not depend on the artifact at all, or
Use the latest version.
Add an entry in your pom.xml's <dependencyManagement> section for selenium-java to peg the artifact at version 2.53.1.
This will affect the version of selenium-java both in your project and all your nested maven dependencies, too; be aware that those nested artifacts may not work well with the latest version!
It's also worth mentioning that selenium-java version 2.53.0 had a Firefox incompatibility problem; version 2.53.1 allegedly fixes that. See http://seleniumsimplified.com/2016/06/use_selenium_webdriver_jar_locally/ for more details.
Hope this helps :)

This happened with me while trying to update to remote driver to 3.0.1 from 2.53.1. I just reverted it back to 2.53.1 and it went away
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>2.53.1</version>
</dependency>

I ran into this too. I changed to the following and it went away.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>4.0.0-alpha-2</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>6.1.0</version>
<scope>provided</scope>
</dependency>

Related

Getting 'CSS Selector' is not supported for this session issue with appium

I got an 'CSS Selector' error while using driver.findElementById("identifier") in automation scripts with appium using Java1.8 with Maven dependency.
Appium terminal version: v1.15.1
Maven Dependency:
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>5.0.4</version>
</dependency>
The issue got resolved when i update my Maven dependency with latest appium version.
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.0.0</version>
</dependency>
I want to know why this issue happened.
The issue is likely a selenium-java dependency mix. Please remove selenium java from maven if it is part of the dependency. Clear the IDE cache and do a clean build.

How to automatically update selenium version in POM?

Is there a way to automatically get selenium-java version to update to the latest, in the POM file without having to manually change it?
I tried creating a selenium.version variable that can fetch a new update of selenium but my POM refuses to index the variable and it displays in red
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
Any workaround?
Honestly, the best way is to do exactly as you have done, with a property in your pom.xml defining ${selenium.version}, like this:
<properties>
<selenium.version>3.8.1</selenium.version>
</properties>
A core principle of maven is reproducible builds. If you dont provide a concrete version number for your dependency (even a test dependency like selenium), then you risk the build of your project suddenly failing one day (or having some other inconsistency) when a new version of selenium is released.
You're better to define the version as 3.8.1, and if in future you see the need to upgrade (version 3.9.x... version 4.x...), just change the <property> and rebuild.
If multiple projects use selenium you can put the <property> in a parent pom which they all define as a parent.
If you want to automatically update the <version> property of the following dependency :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.8.1</version>
</dependency>
You can use the newVersion parameter within versions:update-property of Versions Maven Plugin as follows :
Versions 1.0 (included) to 2.0 (not included) :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>[1.0,2.0)</version>
</dependency>
Versions 1.0 to 2.0 (both included) :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>[1.0,2.0]</version>
</dependency>
Versions 1.5 and higher :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>[1.5,)</version>
</dependency>
Versions up to 1.0 (included) and 1.2 or higher :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>(,1.0],[1.2,)</version>
</dependency>
Version to be used exactly :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>-DnewVersion=[3.8.0]</version>
</dependency>
If you are using Maven 2, you can use the a version value of LATEST or RELEASE . LATEST refers to the latest released or snapshot version of a particular artifact, the most recently deployed artifact in a particular repository. RELEASE refers to the last non-snapshot release in the repository
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>LATEST</version>
</dependency>
But,Maven 3.x no longer supports usage of these metaversions in the POM. As a result, users will need to replace occurrences of these metaversions with a concrete version as there is a threat of non-reproducible builds imposed by automatic plugin version resolution.
https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes#Maven3.xCompatibilityNotes-AutomaticPluginVersionResolution

Maven Site Plugin with Java9

I have a problem running my CI builds on Travis with Java9 (Oracle JDK 9).
I fails on maven-site-plugin - after removing it everything works smothly.
I tried removing everything else to check for possible dependencies collisions, left out with just this one plugin build still fails. It is just a pom container, still failing with just a simple site plugin (updated to latest version that claimed to be java9 ready).
Here are all of the resources:
failing Travis build
Travis configuration
project POM file
Looking for similar problems on the web I found that usually it's plugin compatibility (all of the plugins ware updated) or different dependencies versions, but I removed all of them and it still fails.
The builds run locally on OpenJDK 9 perfectly fine.
-edit-
After applying hint from #nullpointer :
updated POM
CI error
You should probably wait and update to using version 3.7 of site plugin as mentioned here.
Seems like you are encountering something similar to #MSITE-796
Quoting further from the same link:-
The release will need a little bit more time due to pending
SNAPSHOT-dependencies which need to be released first. So either have
a little bit more patience or add doxia-sitetools 1.7.5 as a dependency
to the maven-site-plugin in your own project.
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-sitetools</artifactId>
<version>1.7.5</version>
</dependency>
-edit-
As doxia-sitetools is just a pom container project one needs to update all of it's modules directly:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.6</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-decoration-model</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-skin-model</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-integration-tools</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-site-renderer</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-doc-renderer</artifactId>
<version>1.7.5</version>
</dependency>
</dependencies>
</plugin>

Unable to get Groovy version from GroovySystem, trying InvokerHelper

we are using groovy on a java + maven project and getting below error during the build:
INFO] Unable to get Groovy version from GroovySystem, trying InvokerHelper.
[ERROR] Your Groovy version (1.1-rc-1) doesn't support compilation. The minimum version of Groovy required is 1.5.0. Skipping compiling.
My pom.xml have this dependency:
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.12</version>
<scope>compile</scope>
</dependency>
Any idea?
try this, it works for me:
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.5.7</version>
<type>pom</type>
</dependency>
I faced the same problem. in my case, groovy-all.jar was corrupted. if it is so you can do followings
remove
$USER_FOLDER\.m2\repository\org\codehaus\groovy\groovy-all
then
Right click on the project click Maven->Update Project
as shown below image.

Maven - Unable to resolve dependency conflict b/w google-vision beta & aws-sdk sub-components

I'm trying to use google-vision to fetch text from an image (uploaded to AWS S3) and store it in AWS Dynamo DB. I'm encountering dependency conflicts on jackson-core as both google-api and aws-java-sdk are using two different versions.
Dependency Hierarchy
google-api-client: 1.22.0 uses jackson-core: 2.1.3
google-cloud-vision: 0.22.0-beta uses jackson-core: 2.1.3
aws-java-sdk: 1.11.106 uses jackson-core: 2.6.6
I tried "exclusions" and added explicit dependency in pom.xml to use jackson-core: 2.6.6. Google-vision api works fine with that change. However, AmazonDynamoDBClientBuilder fails with below error:
Exception in thread "main" java.lang.IllegalAccessError: tried to access method com.amazonaws.AmazonWebServiceClient.<init>(Lcom/amazonaws/client/AwsSyncClientParams;)V from class com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder.build(AmazonDynamoDBClientBuilder.java:60)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder.build(AmazonDynamoDBClientBuilder.java:26)
at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
at com.oneglint.ImageProcessing.AddItem.main(AddItem.java:133)
Following error is displayed when there was version conflict
Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:537)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:448)
at com.amazonaws.partitions.PartitionsLoader.<clinit>(PartitionsLoader.java:51)
at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:64)
at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:52)
at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:105)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:239)
at com.oneglint.ImageProcessing.AddItem.main(AddItem.java:132)
What am I missing here? Thanks for the help..
BTW, I'm using example code from github to achieve this. Here are the links:
DynamoDB example: https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/java/example_code/dynamodb
Google Vision DetectText example: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/vision/cloud-client/src/main/java/com/example/vision/Detect.java
Additional Details
Both the examples are working fine if executed as independent projects. The problem occurs ONLY when both PutItem (AWS) & Detect (google-vision) classes are brought together in a single project, with appropriate code changes.
You can only have one version of jackson-core in your project. The easiest way to fix a version is to use <dependencyManagement> to set a version.
Your main problem is that jackson-core: 2.6.6 is not compatible with AmazonDynamoDBClientBuilder. The usual strategy is to try all versions from 2.1.3 to 2.6.6 until one of them works. If not, you can try to find versions of your amazon and google jars that require the same Jackson-core-version. In any case, this stupid and boring try-and-error.
If you do not come to any working solution, you can try to shade classes with maven-shade-plugin (I have not tried this, probably difficult) or you need to change your project in a way that not both dependencies are required.
After a lot of trial and error approach, the issue is finally solved.
It appears that I added multiple versions of aws-java-sdk jars during the process and an opennlp jar was associated with the project for some other module.
I had removed conflicting versions of aws-java-sdk and unnecessary libraries. Also, removed the exclusions and retained only the dependency addition in <dependencymanagement> for jackson-core.
Dependencies in my final pom listed below:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.11.106</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.6</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-vision</artifactId>
<version>v1-rev358-1.22.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.22.0</version>
<exclusions>
<exclusion> <!-- exclude an old version of Guava -->
<groupId>com.google.guava</groupId>
<artifactId>guava-jdk5</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-vision</artifactId>
<version>0.22.0-beta</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
</dependency>
</dependencies>
Hope this helps others..

Categories