Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven 3 Artifact problem

I made a new struts project in eclipse using the struts2-archtype-starter.

A few errors where in my project already before doing anything. Solved most of them but there is 1 the still give me some problems.

Missing artifact com.sun:tools:jar:1.5.0:system pom.xml

I tried to add the tools.jar to my repository manually but that didn't solve the issue.

My pom looks like this

<?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>com.divespot</groupId>     <artifactId>website</artifactId>     <packaging>war</packaging>     <version>0.0.1-SNAPSHOT</version>     <name>E-Divespot diving community</name>     <url>http://www.e-divespot.com</url>     <description>A website to support divers from all around the world.</description>      <dependencies>         <!-- Junit -->         <dependency>             <groupId>junit</groupId>             <artifactId>junit</artifactId>             <version>4.8.2</version>             <scope>test</scope>         </dependency>          <!--  Struts 2 -->         <dependency>             <groupId>org.apache.struts</groupId>             <artifactId>struts2-core</artifactId>             <version>2.0.11.2</version>         </dependency>         <dependency>             <groupId>org.apache.struts</groupId>             <artifactId>struts2-sitemesh-plugin</artifactId>             <version>2.0.11.2</version>         </dependency>         <dependency>             <groupId>org.apache.struts</groupId>             <artifactId>struts2-spring-plugin</artifactId>             <version>2.0.11.2</version>         </dependency>          <!-- Servlet & Jsp -->         <dependency>             <groupId>javax.servlet</groupId>             <artifactId>servlet-api</artifactId>             <version>2.4</version>             <scope>provided</scope>         </dependency>         <dependency>             <groupId>javax.servlet</groupId>             <artifactId>jsp-api</artifactId>             <version>2.0</version>             <scope>provided</scope>         </dependency>          <!-- Jakarta Commons -->         <dependency>             <groupId>commons-fileupload</groupId>             <artifactId>commons-fileupload</artifactId>             <version>1.1.1</version>         </dependency>          <!-- Dwr -->         <dependency>             <groupId>uk.ltd.getahead</groupId>             <artifactId>dwr</artifactId>             <version>1.1-beta-3</version>         </dependency>     </dependencies>      <build>       <finalName>website</finalName>         <plugins>             <plugin>                 <artifactId>maven-compiler-plugin</artifactId>                 <configuration>                    <source>1.6</source>                    <target>1.6</target>                 </configuration>             </plugin>             <plugin>                 <groupId>org.mortbay.jetty</groupId>                 <artifactId>maven-jetty-plugin</artifactId>                 <version>6.1.5</version>                 <configuration>                     <scanIntervalSeconds>10</scanIntervalSeconds>                 </configuration>             </plugin>         </plugins>     </build> </project> 
like image 316
Mark Baijens Avatar asked Apr 22 '11 14:04

Mark Baijens


People also ask

How do I fix missing artifact in Maven?

Try right-clicking on the project and select Maven->Update Project. Disable then re-enable dependency management (right-click Maven->Disable Maven Nature then to again convert the project to a Maven project, Right Click on the project and select Configure ->Convert To Maven Project.

How do I resolve a missing jar in Maven repository?

Look in your . m2 directory (use the paths which you see in the dialog above) and check whether the files are there or whether they are really missing. If they are missing, run "mvn install" (see the "Run as..." menu) to download them.


2 Answers

The error you are seeing is probably because you dont have your JAVA_HOME path set up correctly. Are you seeing something like C:\{directories to jre}\..\lib\tools.jar?

You can have eclipse start up using your built in JDK by altering the eclipse.ini and adding something like

-vm C:\{directories to JDK}\bin\javaw.exe 

What I have learned is that eclipse by default will use your system jre to start eclipse. You probably have seen a message when starting eclipse similar to "Eclipse is running under a JRE and m2eclipse requires a JDK some plugins will not work"

If you go to (in eclipse) Help -> Installation Details and look for a -vm you will probably see it pointing to somewhere that does not have the path structure that it is expecting.

Note: For whatever reason when I encountered this issue java.home in maven was evaluated from where eclipse was launched from. So when it tries to pull the tools.jar from what it sees as java.home it may not be what you actually set as JAVA_HOME as an env/system variable.

like image 171
John Vint Avatar answered Sep 29 '22 01:09

John Vint


<dependency>     <groupId>org.apache.struts</groupId>     <artifactId>struts2-core</artifactId>     <version>${struts2.version}</version>     <exclusions>         <exclusion>             <artifactId>tools</artifactId>             <groupId>com.sun</groupId>         </exclusion>     </exclusions> </dependency> 
like image 37
Thamizharasu Avatar answered Sep 29 '22 01:09

Thamizharasu