Maven can't find classes after downloading dependencies - java

I am new to Maven and I am trying to write a small piece of Java code. I am including some packages. Maven seems to download everything I am expected to need but when it comes to compiling it fails saying it can't find a particular class. The errors further state that it can't find any of of my imports. Can someone tell me what I am missing?
This is my code:
package in.myscratchpad.app;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.dynamodb.AmazonDynamoDBClient;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
AmazonDynamoDBClientBuilder builder = AmazonDBClientBuilder.standard();
}
}
This is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>in.myscratchpad.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>my-app</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>in.myscratchpad.app.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<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>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.60</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</project>
These are the errors I get:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project my-app: Compilation failure: Compilation failure:
[ERROR] /home/ec2-user/projects/kinesisProducer1/my-app/src/main/java/in/myscratchpad/app/App.java:[3,21] package com.amazonaws does not exist
[ERROR] /home/ec2-user/projects/kinesisProducer1/my-app/src/main/java/in/myscratchpad/app/App.java:[4,21] package com.amazonaws does not exist
[ERROR] /home/ec2-user/projects/kinesisProducer1/my-app/src/main/java/in/myscratchpad/app/App.java:[5,26] package com.amazonaws.auth does not exist
[ERROR] /home/ec2-user/projects/kinesisProducer1/my-app/src/main/java/in/myscratchpad/app/App.java:[6,34] package com.amazonaws.auth.profile does not exist
[ERROR] /home/ec2-user/projects/kinesisProducer1/my-app/src/main/java/in/myscratchpad/app/App.java:[7,29] package com.amazonaws.regions does not exist
[ERROR] /home/ec2-user/projects/kinesisProducer1/my-app/src/main/java/in/myscratchpad/app/App.java:[8,29] package com.amazonaws.regions does not exist
[ERROR] /home/ec2-user/projects/kinesisProducer1/my-app/src/main/java/in/myscratchpad/app/App.java:[9,39] package com.amazonaws.services.dynamodb does not exist
[ERROR] /home/ec2-user/projects/kinesisProducer1/my-app/src/main/java/in/myscratchpad/app/App.java:[20,9] cannot find symbol
[ERROR] symbol: class AmazonDynamoDBClientBuilder
[ERROR] location: class in.myscratchpad.app.App
[ERROR] /home/ec2-user/projects/kinesisProducer1/my-app/src/main/java/in/myscratchpad/app/App.java:[20,47] cannot find symbol
[ERROR] symbol: variable AmazonDBClientBuilder
[ERROR] location: class in.myscratchpad.app.App
[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
When I simple keep the Hello, World code without the AWS packages it works fine, when I try to build the service client I get these errors.

It says
...cannot find symbol
[ERROR] symbol: variable AmazonDBClientBuilder
[ERROR] location: class in.myscratchpad.app.App
Which seams to explain clearly that it can compile in.myscratchpad.app.App because there is a symbol in it (namely AmazonDBClientBuilder) which can not be found!
I don't know what this class is for but given that
you do not have import for AmazonDBClientBuilder class
you assign the result to AmazonDynamoDBClientBuilder type
isn't that a typo in your code and you should use AmazonDynamoDBClientBuilder.standard() instead?

Related

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1

i am facing issue while compiling my maven project through command prompt , need help
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project Automation: Compilation failure: Compilation failure:
i am using JDK14 and latest eclipse IDE Version: 2020-03 (4.15.0)
Error message :
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/kits/sit/Base_Setup/BQUK_Agent_Flow.java:[50,39] unmappable character (0x93) for encoding UTF-8
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/kits/sit/Base_Setup/BQUK_Agent_Flow.java:[50,66] unmappable character (0x94) for encoding UTF-8
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[3,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[11,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[12,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[13,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[14,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[15,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[16,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[17,22] package org.testng.xml does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[23,48] cannot find symbol
[ERROR] symbol: class IReporter
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[31,37] cannot find symbol
[ERROR] symbol: class XmlSuite
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[31,63] cannot find symbol
[ERROR] symbol: class ISuite
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[52,33] cannot find symbol
[ERROR] symbol: class IResultMap
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/RetryAnalyzer.java:[4,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/RetryAnalyzer.java:[5,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/RetryAnalyzer.java:[6,39] cannot find symbol
[ERROR] symbol: class IRetryAnalyzer
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/RetryAnalyzer.java:[25,30] cannot find symbol
[ERROR] symbol: class ITestResult
[ERROR] location: class com.qa.analyzer.RetryAnalyzer
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/MyTransformer.java:[6,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/MyTransformer.java:[7,30] package org.testng.annotations does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/MyTransformer.java:[11,39] cannot find symbol
[ERROR] symbol: class IAnnotationTransformer
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/MyTransformer.java:[13,31] cannot find symbol
[ERROR] symbol: class ITestAnnotation
[ERROR] location: class com.qa.analyzer.MyTransformer
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[36,26] cannot find symbol
[ERROR] symbol: class ISuite
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[37,49] cannot find symbol
[ERROR] symbol: class ISuiteResult
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[39,42] cannot find symbol
[ERROR] symbol: class ISuiteResult
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[40,53] cannot find symbol
[ERROR] symbol: class ITestContext
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[56,42] cannot find symbol
[ERROR] symbol: class ITestResult
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] -> [Help 1]
POM.xml that i am using :
<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>com.kingfisher</groupId>
<artifactId>Automation</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<properties>
<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>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</project>
First of all remove the unwanted testng dependency from the POM.xml and second you have added the scope as test in the testng dependency. You have also accessed the class file of the testng dependency with the scope test in src/main/java. Please remove the test scope from the dependency and then execute the test again. Let me know if the issue persists even after fixing the above issues.

Issue with maven compile

When trying to build in jenkins an E2E project using selenium wd and testng , I got the following error:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[9,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[10,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[11,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[12,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[13,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[14,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[15,22] package org.testng.xml does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[21,42] cannot find symbol
symbol: class IReporter
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[24,37] cannot find symbol
symbol: class XmlSuite
location: class resources.ExtentReporterNG
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[24,63] cannot find symbol
symbol: class ISuite
location: class resources.ExtentReporterNG
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[43,33] cannot find symbol
symbol: class IResultMap
location: class resources.ExtentReporterNG
[INFO] 11 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.605 s
[INFO] Finished at: 2020-04-03T19:51:37-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project E2EProject: Compilation failure: Compilation failure:
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[9,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[10,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[11,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[12,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[13,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[14,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[15,22] package org.testng.xml does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[21,42] cannot find symbol
[ERROR] symbol: class IReporter
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[24,37] cannot find symbol
[ERROR] symbol: class XmlSuite
[ERROR] location: class resources.ExtentReporterNG
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[24,63] cannot find symbol
[ERROR] symbol: class ISuite
[ERROR] location: class resources.ExtentReporterNG
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[43,33] cannot find symbol
[ERROR] symbol: class IResultMap
[ERROR] location: class resources.ExtentReporterNG
[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
This was not happening when running the mvn compile command before, but after updating my POM and re-compiling, it started to show in the terminal too. The project works perfectly fine when running it from the testng.xml in eclipse.
Here's how my POM file looks like
<url>http://maven.apache.org</url>
<build>
<resources>
<resource>
<directory>src/main/java/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.apple</groupId>
<artifactId>AppleJavaExtensions</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.6</version>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8.2</version>
</dependency>
</dependencies>
</project>
Attaching image of how the project looks like:
Project
I was finally able to solve this by updating my POM file doing the following:
Removing the extent report dependency that had the avenstack groupID
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.6</version>
</dependency>
updating the other Extent Report to this v:
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.5</version>
</dependency>
And adding this one too:
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
</dependency>

How to call test classes from src folder and build using maven

I am trying to call test classes from src main using maven but unable compile using maven my project structure is like below
My main class looks like
package com.automation.selenium.demo;
import com.automation.selenium.test.demo.TestClass;
public class EntryClass {
public static void main(String[] args) {
System.out.println("!!!!!!!!!!!!!!! Calling From Main Class !!!!!!!!!!!!");
TestClass testNGtest = new TestClass();
testNGtest.testMethod();
}
}
My test class looks like
package com.automation.selenium.test.demo;
public class TestClass {
public void testMethod() {
System.out.println("!!!!!!!!!!!!!!! Calling From Test Class !!!!!!!!!!!!");
}
}
My pom.xml is
<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.ibm.automation.selenium.demo</groupId>
<artifactId>Demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>${project.build.directory}\test-classes\com\automation\selenium\test\demo</argument>
</arguments>
<!-- <testSourceRoot>${project.basedir}/src/test{</testSourceRoot> -->
<mainClass>com.automation.selenium.demo.EntryClass</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have use the following command to run
clean compiler:testCompile exec:java
but it is showing the following error
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project Demo: Unable to parse configuration of mojo org.codehaus.mojo:exec-maven-plugin:1.6.0:java for parameter arguments: Cannot store value into array: ArrayStoreException -> [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/PluginConfigurationException
I am new in Maven anyone please help me to findout the issue.
A class in src/main/java should never call a class in src/test/java. Classes in src/test/java are meant to test the classes in src/main/java. They are not meant to be used as dependencies or parts of self-constructed test frameworks.
If you want to build a jar for testing, put the classes into src/main/java.

maven can't find dependency basiclti-util

I need to implement LTI Consumer in my E-learning platform
I'm trying to run this code LTI example Java
here is the pom.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.paulgray</groupId>
<artifactId>ExampleLtiApp</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>MockLtiApp</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springVersion>4.0.6.RELEASE</springVersion>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.imsglobal</groupId>
<artifactId>basiclti-util</artifactId>
<version>1.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
but maven doesn't contain basic-util-1.0.1-SNAPSHOT
so I edit it to
<dependency>
<groupId>org.imsglobal</groupId>
<artifactId>basiclti-util</artifactId>
<version>1.1.1</version>
</dependency>
but it gave me this error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ExampleLtiApp: Compilation failure: Compilation failure:
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[29,30] package org.imsglobal.basiclti does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[30,30] package org.imsglobal.basiclti does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[74,5] cannot find symbol
[ERROR] symbol: class LtiSigner
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[78,56] cannot find symbol
[ERROR] symbol: class LtiVerificationResult
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[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 can I solve this problem?
Edit:
I tried basiclti-util-1.0.0 but it gave this error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ExampleLtiApp: Compilation failure: Compilation failure:
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/JsonReader.java:[5,43] package org.imsglobal.lti2.objects.consumer does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[29,30] cannot find symbol
[ERROR] symbol: class LtiSigner
[ERROR] location: package org.imsglobal.basiclti
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[31,43] package org.imsglobal.lti2.objects.consumer does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[32,43] package org.imsglobal.lti2.objects.provider does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[33,43] package org.imsglobal.lti2.objects.provider does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[34,43] package org.imsglobal.lti2.objects.provider does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[74,5] cannot find symbol
[ERROR] symbol: class LtiSigner
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[155,13] cannot find symbol
[ERROR] symbol: class ToolProfile
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[204,13] cannot find symbol
[ERROR] symbol: class SecurityContract
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[116,9] cannot find symbol
[ERROR] symbol: class ToolConsumer
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[116,70] cannot find symbol
[ERROR] symbol: class ToolConsumer
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[122,9] cannot find symbol
[ERROR] symbol: class ToolProxy
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[122,28] cannot find symbol
[ERROR] symbol: class ToolProxy
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[123,23] cannot find symbol
[ERROR] symbol: variable ToolProxy
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[156,9] cannot find symbol
[ERROR] symbol: class ToolProfile
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[156,30] cannot find symbol
[ERROR] symbol: class ToolProfile
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[188,49] package ToolConsumer does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[193,47] package ToolConsumer does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[205,9] cannot find symbol
[ERROR] symbol: class SecurityContract
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[205,41] cannot find symbol
[ERROR] symbol: class SecurityContract
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[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
lti-example-java was out-of-date, and using an old branch of basiclti-util-java (one where the package structure wasn't compatible with 1.0.0 or 1.0.1).
It's updated and should be working now.
Use
<dependency>
<groupId>org.imsglobal</groupId>
<artifactId>basiclti-util</artifactId>
<version>1.0.0</version>
</dependency>
version 1.0.0 contains the basiclti package.Version 1.1.1 removes the basiclti package

Java project in IntelliJ is error free but compilation fails via Maven

I've worked my way through the example hello world dropwizard project which appears error free in IntelliJ (I'm an Eclipse veteran but new to IntelliJ) but compilation fails via maven.
The source directory contains:
/src/main/java/com/example/helloworld/HelloWorldConfiguration.java
/src/main/java/com/example/helloworld/HelloWorldService.java
where HelloWorldService looks like:
package com.example.helloworld;
import com.example.helloworld.resources.HelloWorldResource;
import com.example.helloworld.health.TemplateHealthCheck;
import com.yammer.dropwizard.Service;
import com.yammer.dropwizard.config.Bootstrap;
import com.yammer.dropwizard.config.Environment;
public class HelloWorldService extends Service<HelloWorldConfiguration> {
public static void main(String[] args) throws Exception {
new HelloWorldService().run(args);
}
#Override
public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) {
bootstrap.setName("hello-world");
}
#Override
public void run(HelloWorldConfiguration configuration,
Environment environment) {
final String template = configuration.getTemplate();
final String defaultName = configuration.getDefaultName();
environment.addResource(new HelloWorldResource(template, defaultName));
environment.addHealthCheck(new TemplateHealthCheck(template));
}
}
and maven is coming back with:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project my-project: Compilation failure: Compilation failure:
[ERROR] /Users/markdsievers/IdeaProjects/dropwizard/src/main/java/com/example/helloworld/HelloWorldService.java:[9,48] cannot find symbol
[ERROR] symbol: class HelloWorldConfiguration
[ERROR] /Users/markdsievers/IdeaProjects/dropwizard/src/main/java/com/example/helloworld/HelloWorldService.java:[15,38] cannot find symbol
[ERROR] symbol : class HelloWorldConfiguration
[ERROR] location: class com.example.helloworld.HelloWorldService
[ERROR] /Users/markdsievers/IdeaProjects/dropwizard/src/main/java/com/example/helloworld/HelloWorldService.java:[20,21] cannot find symbol
[ERROR] symbol : class HelloWorldConfiguration
[ERROR] location: class com.example.helloworld.HelloWorldService
where the pom.xml looks like:
<?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.example.helloworld</groupId>
<artifactId>my-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.yammer.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>0.6.2</version>
</dependency>
</dependencies>
<properties>
<!-- use UTF-8 for everything -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
I get the same error from maven if the compile goal is run from the command line or within IntelliJ. Source root (/src/main/java) is set in IntelliJ and no amount of cleaning and recompiling has had any effect.
Any suggestions appreciated.
Found the issue... HelloWorldConfiguration did not have a .java extension. Pretty evil IMO, IDE is treating it as a valid java file and was created via the New Java Class (or must not have or something went wrong). Anyways, probably need to enable view of file extensions.

Categories

Resources