Intellij Maven Projects - missing plugins - java

My maven project plugs are in red and they wont download. how can this be resolved? here is an image of the maven projects fro intellij:
and here is my pom.xml file contents:
<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.example.ema</groupId>
<artifactId>jerseyexample</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>jerseyexample Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.10.1</version>
</dependency>
</dependencies>
<build>
<finalName>jerseyexample</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<server>TomcatServer</server>
<path>/newjersey</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
i put the mouse over the first maven directory in the image called 'jerseyexample Maven Webapp' and it showed the following error, hope this helps:
and here is how i added the jersey dependencies... i simply downloaded the jar files and added them to the app module:

the issue was with my settings.xml file that maven uses to build the project. I had a mirror defined in there that used a proxy and it was blocking the download

Related

Can't run robotframework project using maven

I want to run tests using java & robotframework using maven.
I have inserted the dependencies of robotframework and the related plugin in the pom.xml file.
I also tried inserting the dependency on com.sun for the tools.jar file, but running doesn't work.
As for the run setup I inserted a custom maven run with the base directory of the project and as goals I inserted robotframework:run.
I also tried to create an eclipse link by putting the correct path for tools.jar but it doesn't work the same.
This is the error that appears to me:
Could not find artifact com.sun:tools:jar:1.7 at specified path C:\Program Files\Java\jre1.8.0_191/../lib/tools.jar
<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>AppQuality</groupId>
<artifactId>EVD_Robot_01</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>EVD_Robot_01</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.robotframework</groupId>
<artifactId>robotframework-maven-plugin</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.robotframework</groupId>
<artifactId>robotframework</artifactId>
<version>2.8.7</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

I have project A and converted as JAR ,when tried to use in project B not seeing any packages and not able to access

enter image description hereenter image description hereI have used maven plugin in eclipse so I dont see any setting.xml even I tried by adding manually setting.xml.
What I am missing please correct me with In details step.
My pom is
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>demo</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</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>com.project</groupId>
<artifactId>SOA_API_Automation</artifactId>
<scope>system</scope>
<version>0.0.1-SNAPSHOT</version>
<systemPath>{jar/path}</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
If you are referring to the settings.xml which is user-specific configuration for Maven, that is not present inside the POM. It's present in ~/.m2/settings.xml. For more details refer the maven doc

Maven Error:Artifact is not a dependency of the project

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-
plugin:2.6:generate-application-xml (default-generate-application-xml)
on project itaras-ear: Artifact[war:org.apache.maven.plugins:maven-war-
plugin] is not a dependency of the project.
First I built a WAR file for my application. Now I am in the process of building my EAR file which is supposed to have WAR as dependency.
I have run ITARAS-EAR module with m2e plugin when I got the above mentioned error message.
module WAR's pom.xml is below.
<parent>
<groupId>itaras</groupId>
<artifactId>itaras</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>itaras-war</groupId>
<artifactId>itaras-war</artifactId>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>src\main\webapp\WEB-INF\web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
Module EAR's pom.xml is here.
<parent>
<groupId>itaras</groupId>
<artifactId>itaras</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>itaras-ear</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>itaras-war</groupId>
<artifactId>itaras-war</artifactId>
<type>war</type>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<applicationXML>src/main/application/META-
INF/application.xml</applicationXML>
</configuration>
</plugin>
</plugins>
</build>
<groupId>itaras-ear</groupId>
</project>
Thanks in advance. Do Correct me if I had gone fundamentally wrong :)
Your war project has 2 groupIds
<parent>
<groupId>itaras</groupId>
<artifactId>itaras</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
*** <groupId>itaras-war</groupId> ****
<artifactId>itaras-war</artifactId>
<packaging>war</packaging>
Remove the groupId and allow it to pick it's groupId from the parent. Only specify the artifactId, version and groupId from the parent.
Then your dependency to the war in your ear project is:
<dependencies>
<dependency>
<groupId>itaras</groupId>
<artifactId>itaras-war</artifactId>
<type>war</type>
<version>${project.version}</version>
</dependency>
</dependencies>

Eclipse not showing run as maven test when right click on maven project

I have created a maven project through Eclipse and added all dependency's and plugins to pom.xml file. Now, I have created a package as "com.Qedge" under "src/test/java" folder then,created a class under com.Qedge package with a piece of code written using JAVA. when I right click on project to run as "maven Test", Eclipse not showing the option in run. I could able to see the same option when i right click on pom.xml file of the project.
I am new to Maven, I would like to know is there any specific reason for this behavior? What am I supposed to do to get the same option from Project folder (I.e Right click on project - Run as - Maven Test).
Please find my pom.xml file below.
<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.Qedge</groupId>
<artifactId>MavenProjectDemo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MavenProjectDemo</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.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<inherited>true</inherited>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Do a right click on your project Mark as Deployable.
After it would be ok.
Right click project, Configure -> Convert to Maven Project.

How can I add a dependency to embedded tomcat using the maven plugin?

UPDATE
As it turns out there is nothing wrong with my dependencies. The problem is that my META-INF/context.xml file packaged inside my war is not being read by the tomcat plugin. I am still looking for a solution as to why this isn't working.
ORIGINAL QUESTION
I have a multi-module project that looks like this:
myproject
+ - business
+ - app
where "business" and "app" are modules with "myproject" defined as parent in their pom.xml. The app module packages a war file with a context.xml file containing a definition for a JDBC connection pool. When the war file is packaged and deployed to a standalone tomcat instance everything works. The standalone tomcat instance has the required MySql connector jar in its lib classpath directory.
When I run the app module using the tomcat7 maven plugin with the tomcat7:run goal and then access my application I get the "SQLException: No suitable driver" error. How can I get the embedded tomcat to see the MySql connector jar at the right time?
myproject pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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.robsite</groupId>
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>app</module>
<module>business</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8080</port>
<path>/app</path>
<contextReloadable>true</contextReloadable>
</configuration>
</plugin>
</plugins>
</build>
</project>
app pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.robsite</groupId>
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>app</artifactId>
<packaging>war</packaging>
<dependencies>
<!-- Jersey modules -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.26-b01</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.25.1</version>
</dependency>
<!-- Spring modules -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.6.RELEASE</version>
</dependency>
<!-- Modules provided by web container -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- Dependency on business module and its provided dependencies -->
<dependency>
<groupId>com.robsite</groupId>
<artifactId>business</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
In answer to my original question the way to add dependencies on the tomcat plugin, and have classes loaded by the classloader before loading a web app, is by adding a dependency tag inside the plugin.
To solve the real problem I had to add a specific configuration to tell the tomcat plugin to read the /META-INF/context.xml file from my web application module stored at app/src/main/webapp/META-INF/context.xml.
The corrected pom.xml for my root myproject parent pom is below.
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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.robsite</groupId>
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>app</module>
<module>business</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8080</port>
<path>/app</path>
<contextReloadable>true</contextReloadable>
<contextFile>${project.basedir}/src/main/webapp/META-INF/context.xml</contextFile>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.40</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

Categories

Resources