I`m getting an error in my Maven mysql project in netbeans when I try and clean build. The error is:
Failed to execute goal org.codehaus.mojo:sql-maven-plugin:1.5:execute (default) on project utopiaDatabase: Driver class not found: com.mysql.jdbc.Driver
I looked around and figured this is probably because my project isn`t finding my mysql-connector-java, but I have it added as a dependency and everything in my POM file looks fine, do you know why it might not be finding it?
pom.xml:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.eeu46f</groupId>
<artifactId>utopiaDatabase</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<profiles>
<profile>
<id>hsql</id>
<dependencies>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.2</version>
<classifier>jdk6debug</classifier>
</dependency>
</dependencies>
<properties>
<jdbc.url>jdbc:hsqldb:mem:testDB</jdbc.url>
<jdbc.username>SA</jdbc.username>
<jdbc.password></jdbc.password>
<jdbc.driver>org.hsqldb.jdbc.JDBCDriver</jdbc.driver>
</properties>
</profile>
<profile>
<id>mysql</id>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<properties>
<jdbc.url>jdbc:mysql:taken out for security</jdbc.url>
<jdbc.username>taken out for security</jdbc.username>
<jdbc.password>taken out for security</jdbc.password>
<jdbc.driver>com.mysql.jdbc.Driver</jdbc.driver>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.2</version>
<classifier>jdk6debug</classifier>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<driver>${jdbc.driver}</driver>
<url>${jdbc.url}</url>
<username>${jdbc.username}</username>
<password>${jdbc.password}</password>
</configuration>
<executions>
<execution>
<phase>generate-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<srcFiles>
<srcFile>src/test/resources/1-destroy.sql</srcFile>
<srcFile>src/test/resources/2-create.sql</srcFile>
<srcFile>src/test/resources/3-insert.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<name>utopiaDatabase</name>
database properties file in src/main/resources:
jdbc.url=${jdbc.url}
jdbc.username=${jdbc.username}
jdbc.password=${jdbc.password}
jdbc.driver=${jdbc.driver}
I have tried adding mysql-connector-java-5.1.6 as a dependency in my maven project manually also. Thanks in advance
If you look at the homepage of the sql-maven-plugin under "Usage" it clearly shows that you have to give your driver as a dependency to the sql-maven-plugin. You only gave it as a dependency of your project.
If your project needs that dependency as well or not is a different story.
Related
I build and package the project with maven for adding external SPI to Keycloak:
https://github.com/dasniko/keycloak-2fa-sms-authenticator
I changed SNS to other API.But KC gives a following problem:
12:50:07,497 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-1) Uncaught server error: java.lang.NoClassDefFoundError: org/json/JSONException
However I added org.json dependecy to my pom.xml while builded jar file.
This is my pom.xml
<?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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dasniko</groupId>
<artifactId>keycloak-2fa-sms-authenticator</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<finalName>${project.groupId}.${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven.shade.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>software.amazon.awssdk:*</include>
<include>org.reactivestreams:reactive-streams</include>
<include>org.json</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-spi</artifactId>
<version>20.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-spi-private</artifactId>
<version>20.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20080701</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-services</artifactId>
<version>20.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.dasniko</groupId>
<artifactId>keycloak-spi-bom</artifactId>
<version>${keycloak.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<maven.compiler.release>11</maven.compiler.release>
<aws.version>2.18.6</aws.version>
<maven.compiler.version>3.10.1</maven.compiler.version>
<maven.shade.version>3.2.4</maven.shade.version>
<keycloak.version>20.0.0</keycloak.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
What can be resolve such an issue ?
I just started to study jrpc.I created a simple proto file in the proto package.
syntax = "proto3";
service HelloWorldService {
rpc hello(HelloRequest) returns (HelloResponse) {}
}
message HelloRequest {
string text = 1;
}
message HelloResponse {
string text = 1;
}
I use maven.In the pom.xml file I have dependencies like this
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>grpc-hello-server</artifactId>
<version>1.0-SNAPSHOT</version>
<name>GRPC</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.48.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.48.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.48.0</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.6.2</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.9.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.24.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Then i click reload all maven projects button and then in maven lifecycle i click package run. And if i understand correctly my protobuf plugin must created classes in target/generated-sources folder. But it's empty. I don't understand why, i cleaned maven, installed and then again used package command.And that didn't help.Please tell me why my files are not being created?
Proto files should be stored at src/main/proto
I am writing a maven plugin using Mojo classes. The plugin requires a dependency called jcifs and included it in the pom.xml of the plugin. I am able build the plugin and it is deployed into my local repository. I can find the jar file and pom.xml in my local repository.
When I use this plugin in another project in my local system, when executing the plugin goal, I am getting an exception saying the class not found. But the class is coming from the jcifs jar and it is included as part of the dependency for my plugin.
I am not able to figure out what I am missing here. Any help is appreciated
Following is the plugin pom.xml
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mayuran19.maven.plugin</groupId>
<artifactId>LocalToRemoteRepo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>localtoremoterepo-maven-plugin</name>
<properties>
<mavenVersion>3.2.1</mavenVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${mavenVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jcifs</groupId>
<artifactId>jcifs</artifactId>
<version>1.3.17</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<id>default-descriptor</id>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Following show is the pom.xml of the project that use this plugin
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mayuran19.maven.plugin</groupId>
<artifactId>LocalToRemoteRepo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>localtoremoterepo-maven-plugin Test</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>4.3.4.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-tree</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jcifs</groupId>
<artifactId>jcifs</artifactId>
<version>1.3.17</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.mayuran19.maven.plugin</groupId>
<artifactId>LocalToRemoteRepo</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<localRepoDir>C:/Users/smayuran.SITBCS/.m2/repository</localRepoDir>
<remoteRepoDir>smb://192.168.9.196/internal</remoteRepoDir>
<username>G3App</username>
<password>P#ssword$1</password>
</configuration>
</plugin>
</plugins>
</build>
Error I am getting is class not found exception from the library jcifs
You can do this way, if you want:
**Step 1:**Download the jar file to you local machine
**Step 2:**Moving you jar to you maven repo:Run as shown bellow
Example:
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-netty</artifactId>
<version>3.10.1</version>
</dependency>
mvn install:install-file -Dfile=C:\Users\username\Desktop\mockserver-netty-3.10.1.jar -DgroupId=org.mock-server -DartifactId=mockserver-netty -Dversion=3.10.1 -Dpackaging=jar
I have a multi module maven project. Please find below the parent POM.
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rohit.patterns</groupId>
<artifactId>design-patterns</artifactId>
<version>1.0.1</version>
<packaging>pom</packaging>
<name>React.js Blank Project (from https://github.com/making/maven-reactjs-blank)</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4j.version>1.7.21</slf4j.version>
<logback.version>1.1.7</logback.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>gulp</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo message="Gulp!" />
<exec executable="gulp">
<arg value="build" />
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes/META-INF/resources</outputDirectory>
<resources>
<resource>
<directory>dest</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<modules>
<module>cache</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
The child POM is as follows.
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.rohit.patterns</groupId>
<artifactId>design-patterns</artifactId>
<version>1.0.1</version>
</parent>
<groupId>com.rohit.patterns</groupId>
<artifactId>cache</artifactId>
<version>1.0.1</version>
<name>cache</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I have declared Logging from slf4j in parent but no maven dependencies for the same is generated in eclipse hence I am unable to use logging in the code. Can anyone let me know what is wrong here.
Using <dependencyManagement> in a parent pom allows to set the usable dependencies by the child modules.
It is a good thing as it centralizes them and specifies one and only one version.
But to use them, child modules have to declare them in the <dependencies> tag of the <build> tag.
You could for example modify the child pom in this way :
<dependencies>
...
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</dependency>
...
</dependencies>
If you consider that these dependencies should be added in any child modules, favor dependencies over dependencyManagement in the parent pom declaration :
<dependencies>
...
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
...
</dependencies>
Now, you don't need to declare any of these in the child modules as these dependencies will be already included.
I would like to automate Firefox using Java through a Selenium WebDriver project.
As I never used Selenium nor Maven before I'm not familiar with how to set up a suitable Maven pom.xml file to create a project, which then can be imported into Eclipse.
On http://docs.seleniumhq.org/docs/03_webdriver.jsp#introducing-webdriver I found the following example for the opera browser:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MySel20Proj</groupId>
<artifactId>MySel20Proj</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.28.0</version>
</dependency>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<version>1.1</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Would you be so kind and show me how to adapt this pom.xml to apply for the Firefox browser, say Firefox 17?
With selenium-java dependency you get all java bindings for all browsers. So, you do not need to change anything in your pom from what you already have. The only thing that would change is your driver initialization code, which is driver = new FirefoxDriver() instead of OperaDriver.
Here's a basic POM taken from https://github.com/Ardesco/selenium-standalone-server-plugin:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>com.lazerycode.selenium</groupId>
<artifactId>maven-template</artifactId>
<version>1.0-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<name>Selenium Maven Template</name>
<description>A Maven Template For Selenium</description>
<url>http://www.lazerycode.com</url>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<selenium.version>2.45.0</selenium.version>
<overwrite.binaries>false</overwrite.binaries>
<browser>firefox</browser>
<threads>1</threads>
<remote>false</remote>
<seleniumGridURL/>
<platform/>
<browserVersion/>
</properties>
<dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.2.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>selenium-tests</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>com.lazerycode.selenium</groupId>
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
<version>1.0.7</version>
<configuration>
<rootStandaloneServerDirectory>${standalone.binary.root.folder}</rootStandaloneServerDirectory>
<downloadedZipFileDirectory>${project.basedir}/src/test/resources/selenium_standalone_zips</downloadedZipFileDirectory>
<customRepositoryMap>${project.basedir}/src/test/resources/RepositoryMap.xml</customRepositoryMap>
<overwriteFilesThatExist>${overwrite.binaries}</overwriteFilesThatExist>
</configuration>
<executions>
<execution>
<goals>
<goal>selenium</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<parallel>methods</parallel>
<threadCount>${threads}</threadCount>
<systemProperties>
<browser>${browser}</browser>
<screenshotDirectory>${project.build.directory}/screenshots</screenshotDirectory>
<remoteDriver>${remote}</remoteDriver>
<gridURL>${seleniumGridURL}</gridURL>
<desiredPlatform>${platform}</desiredPlatform>
<desiredBrowserVersion>${browserVersion}</desiredBrowserVersion>
<!--Set properties passed in by the driver binary downloader-->
<phantomjs.binary.path>${phantomjs.binary.path}</phantomjs.binary.path>
<webdriver.chrome.driver>${webdriver.chrome.driver}</webdriver.chrome.driver>
<webdriver.ie.driver>${webdriver.ie.driver}</webdriver.ie.driver>
<webdriver.opera.driver>${webdriver.opera.driver}</webdriver.opera.driver>
</systemProperties>
<includes>
<include>**/*WebDriver.java</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
This will:
Download all required Selenium libraries
Download the standalone driver binaries (e.g. chromedriver, phantomJS, etc)
Download the PhantomJSdriver libraries
Add TestNG as a test framework
Add in all the Hamcrest matchers for clear test assertions (see https://code.google.com/p/hamcrest/wiki/Tutorial)
The original link will take you to a basic project setup that you can just check out and run if you want more than just a POM.
I know, that Firefox 17 was not supported in 2.28.0, but browsing the Selenium project homepage gave me new insight - latest release is 2.30.0 so update this:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.28.0</version>
</dependency>
To this:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.30.0</version>
</dependency>
Clean, and try again. Hopefully it helps. The general advice here is: Always use the latest version of Selenium
To use only the FirefoxDriver implementation, you don't have to use the selenium-java artifact. Rather, you can just add the dependency on the Firefox artifact. Add the following dependency to your pom.xml:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.0.1</version>
</dependency>