Maven Dependency jar for BuildPluginManager - java

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.

Related

class file for javax.activation.DataSource not found

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'

Incorrect results in mvn dependency:analyze

I've been searching for a tool, which is able to show you unused dependecies. I soon stumbled over the maven command mvn dependency:analyze. The problem with this is, that it often detects "unused" dependencies which let the build fail if missing.
Here is an example from an optimized Project:
$ mvn dependency:analyze
[INFO] Building LogfileTool 0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-dependency-plugin:2.8:analyze (default-cli) > test-compile # LogfileTool >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # LogfileTool ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # LogfileTool ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\Projects\LogfileToolMa\LogfileTool\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # LogfileTool ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Projects\LogfileToolMa\LogfileTool\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # LogfileTool ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< maven-dependency-plugin:2.8:analyze (default-cli) < test-compile # LogfileTool <<<
[INFO]
[INFO] --- maven-dependency-plugin:2.8:analyze (default-cli) # LogfileTool ---
[WARNING] Unused declared dependencies found:
[WARNING] log4j:apache-log4j-extras:jar:1.2.17:compile
[WARNING] org.projectlombok:lombok:jar:1.16.18:provided
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
Dependencies in Pom.xml
<dependencies>
<!-- Logger -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
<version>1.2.17</version>
</dependency>
<!-- Generating Getter, Setter etc. -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<type>jar</type>
</dependency>
</dependencies>
The used Packages of Lombok are:
lombok.AccessLevel
lombok.Data
lombok.Getter
lombok.Setter
By Removing lombok from my POM i get the following Error by Buildig the Project
-------------------------------------------------------------
COMPILATION ERROR :
-------------------------------------------------------------
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[7,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[8,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[9,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[10,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[26,2] cannot find symbol
symbol: class Data
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[13,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[14,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[15,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[16,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[26,2] cannot find symbol
symbol: class Data
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[34,4] cannot find symbol
symbol: class Getter
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileSearchConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[35,4] cannot find symbol
symbol: class Setter
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileSearchConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[35,4] cannot find symbol
symbol: class Getter
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileParseConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[36,4] cannot find symbol
symbol: class Setter
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileParseConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[62,7] cannot find symbol
symbol: method setXmlToRead(java.lang.String)
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileSearchConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[63,7] cannot find symbol
symbol: method setPathToLogfiles(java.lang.String)
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileSearchConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[63,7] cannot find symbol
symbol: method setPathForStorage(java.lang.String)
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileParseConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[64,7] cannot find symbol
symbol: method setPathToLogfile(java.lang.String)
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileParseConfig
ch/glue/logfiletool/logfiletool/log_handler/LogfileReader.java:[93,50] cannot find symbol
symbol: method getPathToLogfiles()
location: variable logfileSearchConfig of type ch.glue.logfiletool.logfiletool.config_handler.LogfileSearchConfig
ch/glue/logfiletool/logfiletool/log_handler/LogfileReader.java:[95,100] cannot find symbol
symbol: method getXmlToRead()
location: variable logfileSearchConfig of type ch.glue.logfiletool.logfiletool.config_handler.LogfileSearchConfig
ch/glue/logfiletool/logfiletool/Main.java:[61,51] cannot find symbol
symbol: method getPathToLogfile()
location: variable logfileToolConfig of type ch.glue.logfiletool.logfiletool.config_handler.LogfileParseConfig
ch/glue/logfiletool/logfiletool/Main.java:[71,52] cannot find symbol
symbol: method getPathForStorage()
location: variable logfileToolConfig of type ch.glue.logfiletool.logfiletool.config_handler.LogfileParseConfig
22 errors
-------------------------------------------------------------
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.747 s
Finished at: 2017-09-27T10:04:20+02:00
Final Memory: 14M/210M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project LogfileTool: Compilation failure: Compilation failure:
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[7,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[8,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[9,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[10,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[26,2] cannot find symbol
symbol: class Data
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[13,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[14,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[15,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[16,14] package lombok does not exist
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[26,2] cannot find symbol
symbol: class Data
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[34,4] cannot find symbol
symbol: class Getter
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileSearchConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[35,4] cannot find symbol
symbol: class Setter
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileSearchConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[35,4] cannot find symbol
symbol: class Getter
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileParseConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[36,4] cannot find symbol
symbol: class Setter
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileParseConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[62,7] cannot find symbol
symbol: method setXmlToRead(java.lang.String)
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileSearchConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileSearchConfig.java:[63,7] cannot find symbol
symbol: method setPathToLogfiles(java.lang.String)
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileSearchConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[63,7] cannot find symbol
symbol: method setPathForStorage(java.lang.String)
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileParseConfig
ch/glue/logfiletool/logfiletool/config_handler/LogfileParseConfig.java:[64,7] cannot find symbol
symbol: method setPathToLogfile(java.lang.String)
location: class ch.glue.logfiletool.logfiletool.config_handler.LogfileParseConfig
ch/glue/logfiletool/logfiletool/log_handler/LogfileReader.java:[93,50] cannot find symbol
symbol: method getPathToLogfiles()
location: variable logfileSearchConfig of type ch.glue.logfiletool.logfiletool.config_handler.LogfileSearchConfig
ch/glue/logfiletool/logfiletool/log_handler/LogfileReader.java:[95,100] cannot find symbol
symbol: method getXmlToRead()
location: variable logfileSearchConfig of type ch.glue.logfiletool.logfiletool.config_handler.LogfileSearchConfig
ch/glue/logfiletool/logfiletool/Main.java:[61,51] cannot find symbol
symbol: method getPathToLogfile()
location: variable logfileToolConfig of type ch.glue.logfiletool.logfiletool.config_handler.LogfileParseConfig
ch/glue/logfiletool/logfiletool/Main.java:[71,52] cannot find symbol
symbol: method getPathForStorage()
location: variable logfileToolConfig of type ch.glue.logfiletool.logfiletool.config_handler.LogfileParseConfig
-> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
And without log4j-extras i get following Error by running the Project
log4j:ERROR Could not instantiate class [org.apache.log4j.rolling.RollingFileAppender].
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
Both log4j and lombok are used in my Project. Do you have an Idea how to fix this or where this is comming from?
thank you in advance
I have also been running into the issue where project Lombok has been marked by dependency:analyze as an Unused declared dependency. Project Lombok does most of its magic compile time, and as such most annotations are removed after compilation. This is why Maven's dependency analyzer does not recognize it. And why it also fails to detect dependencies that are loaded using SPI.
We have worked around this by explicitly telling the Dependency analyzer plugin to ignore Project Lombok. This can be done with the <usedDependency> configuration option, or the more fine-grained <ignoreUnusedDeclaredDependency> as such:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<ignoredUnusedDeclaredDependencies>
<ignoredUnusedDeclaredDependency>org.projectlombok:lombok</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
</configuration>
</plugin>
</plugins>
</pluginManagement>
PS regarding scopes: Lombok is a compile time dependency, but need not be on the classpath at runtime (or end up in your lib folder). The provided dependency states that the jar should be present for compilation, but at run-time it is expected to be provided by the runtime environment (e.g. the container you run it in). Since Lombok is not needed at runtime, there will be no problems when your runtime does not provide Lombok, contrary to what you'd expect from the Maven dependency declaration.

Maven dependency plugin seems not resolve all dependencies

I have created a very simple Maven project that builds a .war file. Maven version 3.2.3, Java version 1.7.0_67. The pom.xml file is in this gist.
If I run mvn clean install, then the project builds fine. But if I first download all dependencies with mvn dependency:resolve and mvn dependency:resolve-plugins, then run mvn -o install to build offline, I get an error like the following.
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) # docker-restaesy-1 ---
[WARNING] The POM for org.apache.maven:maven-plugin-api:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-project:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-core:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-artifact:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-settings:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-model:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-monitor:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.codehaus.plexus:plexus-utils:jar:3.0.15 is missing, no dependency information available
[WARNING] The POM for org.apache.maven.shared:maven-filtering:jar:1.2 is missing, no dependency information available
[WARNING] The POM for org.codehaus.plexus:plexus-interpolation:jar:1.19 is missing, no dependency information available
[WARNING] Error injecting: org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering
java.lang.NoClassDefFoundError: Lorg/sonatype/plexus/build/incremental/BuildContext;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2436)
at java.lang.Class.getDeclaredFields(Class.java:1806)
at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:661)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:366)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:165)
at com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:609)
at com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:565)
...
Caused by: java.lang.ClassNotFoundException: org.sonatype.plexus.build.incremental.BuildContext
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.544 s
[INFO] Finished at: 2014-12-09T23:24:57+00:00
[INFO] Final Memory: 9M/303M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources) on project docker-restaesy-1: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources failed: A required class was missing while executing org.apache.maven.plugins:maven-resources-plugin:2.7:resources: Lorg/sonatype/plexus/build/incremental/BuildContext;
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-resources-plugin:2.7
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/root/.m2/repository/org/apache/maven/plugins/maven-resources-plugin/2.7/maven-resources-plugin-2.7.jar
[ERROR] urls[1] = file:/root/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.15/plexus-utils-3.0.15.jar
[ERROR] urls[2] = file:/root/.m2/repository/org/apache/maven/shared/maven-filtering/1.2/maven-filtering-1.2.jar
[ERROR] urls[3] = file:/root/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.19/plexus-interpolation-1.19.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
I diff the .m2/repository folder created from the two ways, the one created with dependency plugin is missing many files, most of them related to plexus.
So why doesn't the dependency plugin resolve all the dependencies? Am I doing something wrong here? Thanks
Edit
I get the same error with mvn dependency:go-offline
I understand this is too late but posting this answer if it help someone.
java.lang.ClassNotFoundException: clearly means that jar for org.sonatype.plexus.build.incremental.BuildContext is
not available
available but in wrong path
jar is corrupt
jar responsible for this class is plexus-build-api-0.0.4.jar
check your build output and see which path mvn is looking for this jar.
as an example I have below line in my output
/Users/akash/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.4/
In my case jar plexus-build-api-0.0.4.jar was corrupt in this path.
I checked with $jar -tbv , it it do not return class names , then its corrupt
I downloaded it from link and worked form me.
In your case you do not have this path so you will have to re-create project/reinstall plugins.
you can also try to create this path manually, download jars from linklink and see if it works.

Rest assured with TestNG ins not working with Maven project

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

Downloading Jetty source and Javadoc jars with maven and linking them to binary jars in Eclipse

I am working on a web app project written in Java (1.6) using Eclipse IDE (3.6), and have decided to use Jetty (8.0.4) as the web server and servlet container. I am using maven (2) for dependency and build management. To get started, I decided to write a simple test application to make sure I had things working end-to-end. This is working fine, and I am able to start up the server and create some simple servlets. However, the source and Javadoc jars were not downloaded by maven, so when the mouse hovers over method names or classes, no documentation is found. It just reports the following:
Open Declaration javax.servlet.http.HttpServletResponse
Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.
I've searched for how to do this, and all I could find was this page on the Eclipse website describing how to configure maven to download the source modules as well. It says that the source module jars have the same name as the binary jars, with the suffix "-sources". I added source module dependencies to my maven config for each binary module, like so:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jettyVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server-sources</artifactId>
<version>${jettyVersion}</version>
</dependency>
However, maven failed to find the source module dependencies:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Jetty Servlet Example 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-server-sources/8.0.4.v20111024/jetty-server-sources-8.0.4.v20111024.pom
[WARNING] The POM for org.eclipse.jetty:jetty-server-sources:jar:8.0.4.v20111024 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlet-sources/8.0.4.v20111024/jetty-servlet-sources-8.0.4.v20111024.pom
[WARNING] The POM for org.eclipse.jetty:jetty-servlet-sources:jar:8.0.4.v20111024 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util-sources/8.0.4.v20111024/jetty-util-sources-8.0.4.v20111024.pom
[WARNING] The POM for org.eclipse.jetty:jetty-util-sources:jar:8.0.4.v20111024 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-server-sources/8.0.4.v20111024/jetty-server-sources-8.0.4.v20111024.jar
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlet-sources/8.0.4.v20111024/jetty-servlet-sources-8.0.4.v20111024.jar
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util-sources/8.0.4.v20111024/jetty-util-sources-8.0.4.v20111024.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.098s
[INFO] Finished at: Sun Apr 15 15:42:59 PDT 2012
[INFO] Final Memory: 5M/180M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project hello-world: Could not resolve dependencies for project org.example:hello-world:jar:0.1-SNAPSHOT: The following artifacts could not be resolved: org.eclipse.jetty:jetty-server-sources:jar:8.0.4.v20111024, org.eclipse.jetty:jetty-servlet-sources:jar:8.0.4.v20111024, org.eclipse.jetty:jetty-util-sources:jar:8.0.4.v20111024: Could not find artifact org.eclipse.jetty:jetty-server-sources:jar:8.0.4.v20111024 in central (http://repo1.maven.org/maven2) -> [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/DependencyResolutionException
Any pointers on how to configure maven to download the Jetty sources and javadocs?
Try to recreate your Eclipse project with this Maven command:
mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
Another option is to update your pom.xml:
<plugin>
<artifactId>org.eclipse.jetty</artifactId>
<version>${jettyVersion}</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
Both solutions only work if the source and javadocs were provided to the repo you're downloading from.
In your case (and your version) it should work because you can find the sources.jar in the Jetty repository.

Categories

Resources