Trouble running maven in eclipse - eclipse

I have trouble running the project imported in maven.
I followed the following steps ->
go to Open File...→Import Project from File System, then choose your project1 directory. To compile your project, right click on the project name at the Package Explorer, select Run As, and then Maven install.
I get the error as shown in the pic.....I have installed jdk 1.6 though...any way how to resolve this???
Here's the complete pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.uta.cse6331</groupId>
<artifactId>cse6331-P1</artifactId>
<packaging>jar</packaging>
<version>0.1</version>
<name>CSE6331 Project #1</name>
<properties>
<hadoop.version>2.6.0</hadoop.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>${hadoop.version}</version>
</dependency>
</dependencies>

Please try adding below dependency
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>${java.home}/lib/tools.jar</systemPath>
</dependency>
Also ensure you refer to correct to JDK location not JRE (${java.home})
Please check eclipse is referring to JDK and not JRE.
In Eclipse, Navigate to Window -> Preferences
On the left hand pane, expand Java and you will find the "Installed JREs" entry

Related

Error opening a class in Eclipse Version: 2018-09 (4.9.0) inside a maven module

I have a maven project containing several modules. This is part of the pom.xml file:
<?xml version="1.0"?>
<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">
<parent>
<groupId>com.tdk.booking.codemap</groupId>
<artifactId>tdkmap-maven-parent</artifactId>
<version>3.2.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.tdk.booking.tdk</groupId>
<artifactId>tdks</artifactId>
<version>3.6.0-RC1</version>
<packaging>pom</packaging>
<name>tdk Services</name>
<description>Document, File and Meeting Services</description>
<modules>
<module>tdk-services</module>
<module>tdk-audit</module>
<module>tdk-procedure</module>
<module>tdk-persistence-model</module>
<module>tdk-common</module>
<module>tdk-war</module>
</modules>
<dependencyManagement>
<dependencies>
<!-- Spring BOM -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>${spring.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- Quartz framework -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>${quartz.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- LOG4J2 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.7</version>
</dependency>
.....
</dependencies>
</project>
When I am on Eclipse and I try to open a class using F3 that is inside of one of the modules, like tdk-services, I got the error
Problems opening an editor.
Reason:
tdk-services does not exist
Import all the modules as independent projects: File - Import - Existing Project into Workspace and select the child project. Navigate using F3 or Ctrl - click.

Maven run tests specified in my Eclipse Folder(Path- src/test/java/pakage) but Test Results are not shown correctly

I have a Maven Project in eclipse. On running pom.xml file it runs my 2 tests mentioned on path- src/test/java/pakage.
But,When I check the test results in index.html file in the test-output folder - it shows only 1 test that too method name and class name is not correct.
Also in the info section of htlml file, location is little weird- shows like this -C:\Users..\AppData\Local\Temp\testng-eclipse--1598554117\testng-customsuite.xml (I am expecting my Project location which is- d drive).
Not sure what is going wrong.can somebody plz help.
My pom.xml is like this-
<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>Maven_demo</groupId>
<artifactId>Maven_Project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Maven_Project</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
my Project structure is like this- img attached --https://i.stack.imgur.com/1FqDe.jpg

Eclipse with Maven plugin does not work with latest revisions, but works with older ones

I have a simple project that uses Spring AOP. It uses annotation from AspectJ. The project is in Maven and it compiles ok with aspectjtools-1.7.4. With aspectjtools-1.8.9 it fails to see accept annotation #Aspect imported from org.aspectj.lang.annotation.Aspect. The same project gives no problems with Gradle and same JARs.
Why would my code not work with latest revision of AspectJ, but works ok with older one?
I am attaching 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>com</groupId>
<artifactId>aspectjproblem</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>aspectjproblem</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.3.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<!-- WITH 1.8.9: FAILS to see org.aspectj.lang.annotation.Aspect -->
<!-- <version>1.8.9</version> -->
<!-- WITH 1.7.4: SEES OK: org.aspectj.lang.annotation.Aspect -->
<version>1.7.4</version>
</dependency>
</dependencies>
</project>
I guess it must have something to do with compliance-levels or similar things. Can anyone point me in the right direction? Many thanks.
It took me a while to understand what was the issue. I tried moving to Java8 and I played with dependencies. The problem I had was:
- Invalid LOC header (bad signature)
What means I guess Maven downloaded a corrupted file. I deleted it from repo (e.g. C:\Users\$USER.m2\repository\org\aspectj\aspectjtools ), updated maven and all started working again.

Package does not exist when using Maven

<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.mycompany</groupId>
<artifactId>mavenproject1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mavenproject1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
When I try to import com.mongodb, I get a package does not exist error. I had to manually add the .jar file to make it work. How do I get Maven dependency to work?
Thank you
You have the maven coordinate correct, and the artifact does exist on maven central repository. So I strongly believe your maven settings had configuration problem causing it unable to fetch from central repository.
This commonly occur when you're behind a company internal repository such as nexus and it has stale index, or you set your ~/.m2/settings.xml to NOT lookup from the central repo.

gwt-servlet.jar missing in the WEB-INF/lib on compiling GWT with maven

In my pom file, I have included the dependency of gwt-servlet but if i run mvn clean install and mvn eclipse:eclipse and open the project in eclipse, I get the following error
GWT SDK JAR gwt-servlet.jar is missing in the WEB-INF/lib directory
EDIT :
Here is my dependency (we use a custom maven repository):
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smart-gwt</artifactId>
<version>2.5</version>
</dependency>
EDIT 2 (main pom):
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
</extension>
</extensions>
....
There are two things I noticed.
1) The smartgw dependency you specified cannot be resolved from the maven central repository
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smart-gwt</artifactId>
<version>2.5</version>
</dependency>
It only has the 2.4 version of smartgw (see here http://search.maven.org/#search%7Cga%7C1%7Csmartgwt) Instead I had to use this
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>2.4</version>
</dependency>
notice that the artifact ID is different too. (If you have a custom repository containing this then please update your question)
2) You dont need to do eclipse:eclipse instead you can issue the
File > Import > Existing Maven projects
this will auto generate the eclipse project from your pom.xml
UPDATE
I tested with the following :
Parent pom in gwttest2 folder
<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.test</groupId>
<artifactId>gwttest2-main</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>gwttest2-module1</module>
</modules>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
</extension>
</extensions>
</build>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
child pom in gwttest2/gwttest2-module1 folder
<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.test</groupId>
<artifactId>gwttest2-module1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<artifactId>gwttest2-main</artifactId>
<groupId>com.test</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
</extension>
</extensions>
</build>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
Tell Eclipse to use Maven dependencies by right-clicking on your Project folder and selecting
Configure > Convert to Maven Project.
It seems that even after running mvn eclipse:eclipse, you must do this manually to get Eclipse to actually let Maven take care of your dependencies.
If you don't see this option you may not have the M2Eclipse plugin installed in your Eclipse...