There is no compilation error, but the moment I try to build it using maven it throws the following error and fails the build
I'm using Java 11 Open JDK
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project notification-functionapp: Compilation failure
[ERROR] MailSender.java:[112,37] cannot access javax.activation.DataSource
[ERROR] class file for javax.activation.DataSource not found
At 112 line of MailSender.java this following line of code is there
final Multipart multipart = new MimeMultipart("alternative");
javax.activation seems to be not present inherently in Java 11 Open JDK, so if you encounter this error please add the following dependency in you pom.xml or build.gradle
Maven
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
Gradle
compile 'com.sun.activation:javax.activation:1.2.0'
I am trying to schedule my project on Maven. It uses Apache POI. Project works fine on my Laptop but it fails to compile Maven on Jenkins that is on a remote machine in our office. The error I face is:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile** (default-testCompile) on project GunAV-test-automation: Compilation failure: Compilation failure:
[ERROR] /C:/Program Files (x86)/Jenkins/workspace/Mytest/-42/src/test/java/utilities/ReadExcel.java:[11,37] **package org.apache.poi.xssf.usermodel does not exist**
[ERROR] /C:/Program Files (x86)/Jenkins/workspace/Mytest/-42/src/test/java/utilities/ReadExcel.java:[12,37] package org.apache.poi.xssf.usermodel does not exist**
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
How could I fix this issue?
To fix a compilation error
package org.apache.poi.xssf.usermodel does not exist
you should add a poi-ooxml maven dependency:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
This dependency contains org.apache.poi.xssf.usermodel package.
In my maven plugin Mojo Java file, I am importing interface BuildPluginManager using following line:
import org.apache.maven.plugin.BuildPluginManager;
This line gives following error:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/username/git/path/to/plugin/my-maven-plugin/src/main/java/com/company/product/repo/my_maven_plugin/ExecutorExampleMojo.java:[25,31] cannot find symbol
symbol: class BuildPluginManager
location: package org.apache.maven.plugin
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
Also, eclipse shows this error in the beginning of the file:
The type org.apache.maven.plugin.BuildPluginManager cannot be resolved. It is indirectly referenced from required .class files
From what I understand, it means that the dependency jar/war that has this interface BuildPluginManager is not there in the POM file. My question is, which dependency do I need to pull in to use this interface? How do I find that dependency?
You need to include dependency on org.apache.maven:maven-core:
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.2.5</version>
</dependency>
You can find this out by searching the Maven Central Repository, By Classname.
Just put org.apache.maven.plugin.BuildPluginManager into the Classname input field.
I'm trying to build a new Ambari view (Ambari is an open source project by Apache) that will allow users to manage their OneFS cluster at the same time they're managing Hadoop. I'm pretty new to Maven so I'm hoping this problem is trivially easy to fix (it seems like it would be but so far I haven't been able to figure it out).
I have the following imports defined in a .java file:
package org.apache.ambari.view;
import java.lang.Integer; // Provides several methods for converting an int to a String and a String to an int.
import java.io.IOException; // Signals that an I/O exception of some sort has occurred.
import java.net.UnknownHostException; // Thrown to indicate that the IP address of a host could not be determined.
import java.net.URL; // Uniform Resource Locator - a pointer to a "resource" on the World Wide Web.
import java.net.Socket; // An endpoint for communication between two machines.
import java.util.ArrayList; // Resizable-array implementation of the List interface.
import org.apache.commons.codec.binary.Base64; // Provides Base64 encoding and decoding as defined by RFC 2045.
import org.apache.http.HttpEntity; // An entity that can be sent or received with an HTTP message.
import org.apache.http.util.EntityUtils; // Static helpers for dealing with HttpEntitys.
import org.apache.http.message.BasicNameValuePair; // NameValuePair dictionary type.
import org.apache.http.impl.client.CloseableHttpClient; // Base implementation of HttpClient that also implements Closeable.
import org.apache.http.impl.client.HttpClients; // Factory methods for CloseableHttpClient instances.
import org.apache.http.client.methods.CloseableHttpResponse;// Extended version of the HttpResponse interface that also extends Closeable.
import org.apache.http.client.entity.UrlEncodedFormEntity; // An entity composed of a list of url-encoded pairs for sending HTTP POST requests.
import org.apache.http.client.methods.HttpPost; // An HTTP POST class as defined by section 9.5 of RFC2616
public class Papi {
private String m_clustername;
private String m_username;
private String m_password;
private String m_url;
private String m_sessionurl;
private String m_ipaddress;
private int m_timeout;
private int m_responsecode;
public Papi(String clustername, String username, String password, int port) {
Socket socket;
try {
socket = new Socket(clustername, port);
m_ipaddress = socket.getInetAddress().getHostAddress();
socket.close();
} catch(UnknownHostException e) {
System.out.println("ERROR 1: Failed to open session (UnknownHostException)");
} catch(IOException e) {
System.out.println("ERROR 1: Failed to open session (IOException)");
}
m_url = "https://" + m_ipaddress + ":" + Integer.toString(port);
m_sessionurl = m_url + "/platform" + "/1?describe&list&all";
m_username = username;
m_password = password;
m_responsecode = 0;
}
public int GetResponseCode() {
return m_responsecode;
}
public String GetSessionURL() {
return m_sessionurl;
}
// Makes an https POST request to OneFS.
public String DoPost() throws Exception {
String response;
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(m_sessionurl);
ArrayList <BasicNameValuePair> basicNameValuePair = new ArrayList <BasicNameValuePair>();
basicNameValuePair.add(new BasicNameValuePair("username", m_username));
basicNameValuePair.add(new BasicNameValuePair("password", m_password));
httpPost.setEntity(new UrlEncodedFormEntity(basicNameValuePair));
CloseableHttpResponse reply = httpclient.execute(httpPost);
try {
System.out.println(reply.getStatusLine());
HttpEntity entity = reply.getEntity();
// Parse response body and return as a string.
response = EntityUtils.toString(entity);
System.out.println(response);
// Dispose entity contents.
EntityUtils.consume(entity);
return response;
} finally {
reply.close();
return null;
}
return null;
}
}
However, when I try to build the program using mvn clean package I get the following errors:
root#Martell-AMBARI:/home/tmunson/ambari/ambari-views/examples/onefs-view# mvn clean package
Picked up _JAVA_OPTIONS: -Xmx2048m -XX:MaxPermSize=512m -Djava.awt.headless=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Isilon OneFS View 2.1.3
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # onefs-view ---
[INFO] Deleting /home/tmunson/ambari/ambari-views/examples/onefs-view/target
[INFO] Deleting /home/tmunson/ambari/ambari-views/examples/onefs-view (includes = [**/*.pyc], excludes = [])
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:regex-property (parse-package-version) # onefs-view ---
[INFO] No match to regex '^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)((\.|-).*)?' found in '2.1.3'. The initial value '2.1.3' is left as-is...
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:regex-property (parse-package-release) # onefs-view ---
[INFO] No match to regex '^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)((\.|-)(([0-9]+)|(SNAPSHOT)|(techwin)).*)?' found in '2.1.3'. The initial value '2.1.3' is left as-is...
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # onefs-view ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) # onefs-view ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/tmunson/ambari/ambari-views/examples/onefs-view/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[28,39] package org.apache.commons.codec.binary does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[30,28] package org.apache.http.util does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[31,31] package org.apache.http.message does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[32,35] package org.apache.http.impl.client does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[33,38] package org.apache.http.client.methods does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[34,35] package org.apache.http.impl.client does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[35,23] package org.apache.http does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[37,37] package org.apache.http.client.entity does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[38,38] package org.apache.http.client.methods does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[39,35] package org.apache.http.impl.client does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[41,1] package org.json does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[86,17] cannot find symbol
symbol: class CloseableHttpClient
location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[86,50] cannot find symbol
symbol: variable HttpClients
location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[87,17] cannot find symbol
symbol: class HttpPost
location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[87,41] cannot find symbol
symbol: class HttpPost
location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[89,28] cannot find symbol
symbol: class BasicNameValuePair
location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[89,84] cannot find symbol
symbol: class BasicNameValuePair
location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[90,44] cannot find symbol
symbol: class BasicNameValuePair
location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[91,44] cannot find symbol
symbol: class BasicNameValuePair
location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[93,40] cannot find symbol
symbol: class UrlEncodedFormEntity
location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[94,17] cannot find symbol
symbol: class CloseableHttpResponse
location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[98,21] cannot find symbol
symbol: class HttpEntity
location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[101,32] cannot find symbol
symbol: variable EntityUtils
location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[104,21] cannot find symbol
symbol: variable EntityUtils
location: class org.apache.ambari.view.Papi
[INFO] 24 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.002s
[INFO] Finished at: Mon Nov 09 01:06:46 PST 2015
[INFO] Final Memory: 14M/240M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project onefs-view: Compilation failure: Compilation failure:
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[28,39] package org.apache.commons.codec.binary does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[30,28] package org.apache.http.util does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[31,31] package org.apache.http.message does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[32,35] package org.apache.http.impl.client does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[33,38] package org.apache.http.client.methods does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[34,35] package org.apache.http.impl.client does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[35,23] package org.apache.http does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[37,37] package org.apache.http.client.entity does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[38,38] package org.apache.http.client.methods does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[39,35] package org.apache.http.impl.client does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[41,1] package org.json does not exist
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[86,17] cannot find symbol
[ERROR] symbol: class CloseableHttpClient
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[86,50] cannot find symbol
[ERROR] symbol: variable HttpClients
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[87,17] cannot find symbol
[ERROR] symbol: class HttpPost
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[87,41] cannot find symbol
[ERROR] symbol: class HttpPost
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[89,28] cannot find symbol
[ERROR] symbol: class BasicNameValuePair
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[89,84] cannot find symbol
[ERROR] symbol: class BasicNameValuePair
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[90,44] cannot find symbol
[ERROR] symbol: class BasicNameValuePair
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[91,44] cannot find symbol
[ERROR] symbol: class BasicNameValuePair
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[93,40] cannot find symbol
[ERROR] symbol: class UrlEncodedFormEntity
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[94,17] cannot find symbol
[ERROR] symbol: class CloseableHttpResponse
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[98,21] cannot find symbol
[ERROR] symbol: class HttpEntity
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[101,32] cannot find symbol
[ERROR] symbol: variable EntityUtils
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] /home/tmunson/ambari/ambari-views/examples/onefs-view/src/main/java/org/apache/ambari/view/isilon/Papi.java:[104,21] cannot find symbol
[ERROR] symbol: variable EntityUtils
[ERROR] location: class org.apache.ambari.view.Papi
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I thought I had included all the necessary dependencies in my pom.xml file for the view, but apparently this is not the correct way to do it:
<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">
<parent>
<groupId>org.apache.ambari</groupId>
<artifactId>ambari-view-examples</artifactId>
<version>2.1.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>onefs-view</artifactId>
<packaging>jar</packaging>
<name>Isilon OneFS View</name>
<version>2.1.3</version>
<url>http://maven.apache.org</url>
<properties>
<ambari.dir>${project.parent.parent.parent.basedir}</ambari.dir>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.ambari</groupId>
<artifactId>ambari-views</artifactId>
<version>[1.7.0.0,)</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.3</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.0.1</version>
<executions>
<execution>
<phase>none</phase>
<goals>
<goal>rpm</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
So my questions are as follows:
1) Why won't Maven recognize the dependencies I've specified in my pom.xml file?
2) How would I go about making it recognize those dependencies? I'm kinda wondering if I just have the dependencies listed in the wrong place or something, but my understanding of how Maven works is that it will find the dependencies that you've specified in the pom.xml file and then download them and include them in your build. Since I'm including the dependencies but it's not recognizing them, I must be doing that wrong, but I have no clue what the right way to do it would be.
Thanks in advance for any help you all can offer!
If you define dependencies within the dependencyManagement section (like you did), those dependencies are not added to the project. They are only configured, so that POMs, which have this POM as parent, don't need to specify the version for a dependency (the dependency version becomes managed by the parent).
So in your case to resolve the problem, just remove the <dependencyManagement> and </dependencyManagement> tags.
I added the following dependency list in pom.xml for my Rest assured project with maven:
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
Now I am trying to run following sample code:
import static com.jayway.restassured.RestAssured.*;
import static com.jayway.restassured.matcher.RestAssuredMatchers.*;
import static org.hamcrest.Matchers.*;
import java.util.*;
import org.testng.Assert;
import org.testng.annotations.*;
public class TestNGTest1 {
private Collection collection;
#Test
public void testGetSingleUserProgrammatic() {
Response res = get("/service/single-user");
assertEquals(200, res.getStatusCode());
String json = res.asString();
JsonPath jp = new JsonPath(json);
assertEquals("test#hascode.com", jp.get("email"));
assertEquals("Tim", jp.get("firstName"));
assertEquals("Testerman", jp.get("lastName"));
assertEquals("1", jp.get("id"));
}
}
But this is throwing error while doing mvn test
Error is:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project GBAppAuomation: Compilation failure: Compilation failure:
[ERROR] /home/jay/temp/GB_MVN_Proj/GBAppAuomation/src/test/java/com/glassbeam/app/TestNGTest1.java:[50,2] error: cannot find symbol
[ERROR] class TestNGTest1
[ERROR] /home/jay/temp/GB_MVN_Proj/GBAppAuomation/src/test/java/com/glassbeam/app/TestNGTest1.java:[53,2] error: cannot find symbol
Corresponding symbols are get etc, which rest assured uses.
As asked here is complete error message::
Here is the complete error message:: **
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # GBAppAuomation ---
[INFO] Compiling 1 source file to /home/jay/temp/GB_MVN_Proj/GBAppAuomation/target/test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/jay/temp/GB_MVN_Proj/GBAppAuomation/src/test/java/com/glassbeam/app/TestNGTest1.java:[50,1] error: cannot find symbol
[ERROR] class TestNGTest1
/home/jay/temp/GB_MVN_Proj/GBAppAuomation/src/test/java/com/glassbeam/app/TestNGTest1.java:[50,17] error: cannot find symbol
[ERROR] class TestNGTest1
/home/jay/temp/GB_MVN_Proj/GBAppAuomation/src/test/java/com/glassbeam/app/TestNGTest1.java:[53,2] error: cannot find symbol
[ERROR] class TestNGTest1
/home/jay/temp/GB_MVN_Proj/GBAppAuomation/src/test/java/com/glassbeam/app/TestNGTest1.java:[53,20] error: cannot find symbol
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.384s
[INFO] Finished at: Sat Jan 04 15:26:57 IST 2014
[INFO] Final Memory: 16M/202M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project GBAppAuomation: Compilation failure: Compilation failure:
[ERROR] /home/jay/temp/GB_MVN_Proj/GBAppAuomation/src/test/java/com/glassbeam/app/TestNGTest1.java:[50,1] error: cannot find symbol
[ERROR] class TestNGTest1
[ERROR] /home/jay/temp/GB_MVN_Proj/GBAppAuomation/src/test/java/com/glassbeam/app/TestNGTest1.java:[50,17] error: cannot find symbol
[ERROR] class TestNGTest1
[ERROR] /home/jay/temp/GB_MVN_Proj/GBAppAuomation/src/test/java/com/glassbeam/app/TestNGTest1.java:[53,2] error: cannot find symbol
[ERROR] class TestNGTest1
[ERROR] /home/jay/temp/GB_MVN_Proj/GBAppAuomation/src/test/java/com/glassbeam/app/TestNGTest1.java:[53,20] error: cannot find symbol
The problem seems to be related with dependencies.
Were there any compilation errors in the IDE?
Because the interface Response from the line below (probably line 50 from the error)
Response res = get("/service/single-user");
belongs to package com.jayway.restassured.response, whereas the only imports in the class related to restassured are
import static com.jayway.restassured.RestAssured.*;
import static com.jayway.restassured.matcher.RestAssuredMatchers.*;
And the JsonPath class from (probably line 53 from the error)
JsonPath jp = new JsonPath(json);
belongs to package com.jayway.jsonpath and also not imported.
This package should be also included into the POM as a dependency:
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>0.9.1</version>
</dependency>
Please pay attention to the groupId. There are two of them available. The one you need for the Restassured jars is: io.rest-assured.
Currently, this is the latest version :
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.0.3</version>
<scope>test</scope>
</dependency>
If a newer version becomes available, all you need to do is to change the version number in the dependency from 3.0.3 to the new one.
For your information, there is no longer a need to add a standalone JsonPath dependency as it is now fully embedded in the rest-assured artifact as given as above