A few days ago I setup my first Maven 2 enabled struts 2.0 WTP project. After an hour of muddling through the Eclipse IDE setup with WTP plus Maven, I soon ran into another trouble when I built the project in Eclipse. Maven told me that it missed the com.sun tools artifact that it couldn’t build the project.
Missing dependency tools.jar
8/13/07 5:58:51 PM CST: Missing:
1) com.sun:tools:jar:1.5.0
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=com.sun -DartifactId=tools \
-Dversion=1.5.0 -Dpackaging=jar -Dfile=/path/to/file
Path to dependency:
1) tutorial:tutorial4:war:1.0-SNAPSHOT
2) org.apache.struts:struts2-core:jar:2.0.5
3) com.sun:tools:jar:1.5.0
1 required artifact is missing.
for artifact:
tutorial:tutorial4:war:1.0-SNAPSHOT
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
Huh? It misses the tools.jar from Sun’s JDK.
Murders – Mr. profile “default-tools” & Mr. Sun Micro the JDK
I soon dig out that it is the struts2-core artifact has a dependency on Sun’s tools.jar. A profile named “default-tools.jar” declared the dependency on the tools.jar, which is activated when you are running the maven operation with Sun’s JDK. This is what you can see from struts2-core’s pom.
<profile>
<id>default-tools.jar</id>
<activation>
<property>
<name>java.vendor</name>
<value>Sun Microsystems Inc.</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.5.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
Yet strange enough, I had no problem running the build with my command prompt. It only matters when running in Eclipse. To be exact, there was no problem when I manually triggered the building process by “Run as Maven2 Build” with the pom. But when Eclipse builds the project automatically, say after a clean, the error pops.
Adding the tools.jar to Eclipse’s JDK runtime does not help. Nonetheless this does look like a good practice so I give it up.
So what have went wrong? The profile try to look up the tools.jar by back stepping from the directory java.home, where it is the home directory of running Java process automatically deduced and set by Maven. If java.home points to a JDK, the path works as JDK comes with a tools.jar in the lib/ folder. But if java.home points to a JRE instead, the path should fail as JRE doesn’t bring along the tools.jar. When I start Eclipse, I could have started it by either a JRE or a JDK as I simply doubled clicked the shortcut to it on my desktop. The remaining problem is, isn’t it Eclipse is running the Maven 2 Builder with my configured JDK in the project? So I make the shots.
Starting Eclipse with -vm Option
The configuration free classic way to start Eclipse with desired VM.
$>eclipse -vm "C:\Program Files\Java\jdk1.6.0_01\bin"
Wow! It works. Okay, give it another shot.
Making JDK/bin the First Element in %PATH%
$>set PATH=C:\Program Files\Java\jdk1.6.0_01\bin;%PATH%
$>eclipse
Jesus! it works again.
Conclusion?
It looks like the when Eclipse is told to call the maven build manually with a pom.xml it, it executes with the configured JDK’s path. But when it comes to execute the Maven 2 Builder, it uses the Java process which starts the Eclipse instead. So if the Eclipse’s started with a Sun Micro JRE, it misses the tools.jar for struts2-core. Other JDK/JRE doesn’t matter, however, as the tools.jar or equivalent are usually on the classpath already.
Is it a behavior of Eclipse or just that of the M2Eclipse plug-in? I haven’t figured out yet. May be I just messed all the things up by accident (or luck). If anyone know what’s really inside, let me know
分享到:
相关推荐
Missing artifact com.babasport:page:jar:1.0Missing artifact com.babasport:page:jar:1.0
Missing artifact com.oracle:ojdbc6:jar:11.2.0.1.0问题解决 ojdbc包pom.xml出错 <!-- oracle数据库驱动 --> <groupId>com.oracle</groupId> <artifactId>ojdbc6 <version>11.2.0.1.0 1.首先确定你...
数据库连接包,下载解压,使用命令 mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.5.0 -Dpackaging=jar -Dfile=(你的路径)\ojdbc14.jar
本文将详细解释如何解决“Missing artifact com.sun.:tools:jar:1.8.0”的错误,并探讨与之相关的`tools-1.8.0.jar`文件。 首先,让我们了解这个错误的含义。在Maven或Gradle等构建工具中,当我们构建项目时,如果...
springBoot的pom头部报tools.jar的错所需要的jar包 错误为Missing artifact com.sun:tools:jar:1.8.0
在构建和运行淘淘商城项目时,可能会遇到一个常见的错误提示:“Missing artifact com.github.pagehelper:pagehelper:jar:3.”。这个错误意味着在项目的依赖管理中,缺少了一个名为PageHelper的库,具体版本为3。...
然而,有时我们可能会遇到一些特定的依赖问题,比如在这个案例中,"Unresolved dependency: 'com.aspose:aspose:jar:19'",意味着在执行Maven构建时,Maven无法从配置的阿里云仓库中找到`com.aspose:aspose:jar:19`...
缺少jar包 Description Resource Path Location Type Missing artifact com.sun.jdmk:jmxtools:jar:1.2.1 pom.xml Maven Dependency Problem jmxtools-1.2.1.jar
Missing artifact com.oracle:ojdbc14:jar:10.2.0.3.0-附件资源
Description Resource Path Location Type Missing artifact com.sun.jmx:jmxri:jar:1.2.1 pom.xml /eshop-storm line 2 Maven Dependency Problem
Could not resolve dependencies for project ... Could not find artifact com.sun:jconsole:jar:1.8 at specified path G:\.m2\com\alibaba\druid\1.2.6/lib/openjdk-1.8-jconsole.jar
<systemPath>${java.home}/lib/tools.jar</systemPath> ``` 注意,这里使用了`system`作用域,意味着Maven将从指定的系统路径加载该依赖,而不是从远程仓库。然而,这种方式并不推荐,因为它可能导致构建不具可...
Failure to transfer org.... Original error: Could not transfer artifact org.codehaus.plexus:plexus-io:jar: 1.0.1 from/to central (http://repo.maven.apache.org/maven2): No response received after 60000
com.springsource.org.aspectj.weaver-1.6.8.jar
赠送jar包:mybatis-paginator-1.2.15.jar; 赠送原API文档:mybatis-paginator-1.2.15-javadoc.jar; 赠送源代码:mybatis-paginator-1.2.15-sources.jar; 赠送Maven依赖信息文件:mybatis-paginator-1.2.15.pom;...
1. 解压文件得到:jta-1_0_1B-classes.zip 2. cmd进入zip文件所在目录 ...mvn install:install-file -Dfile=./jta-1_0_1B-classes.zip -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar
在`kaptcha-2.3.2`这个压缩包中,包含了Kaptcha库的所有相关文件,如JAR文件、源代码、文档等,方便开发者进行学习和使用。通过解压并导入这些资源,开发者可以在自己的项目中快速实现验证码功能。 总的来说,`...
maven编译时报找不到这两个jar...jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.sun.jdmk:jmxtools:jar:1.2.1, com.sun.jmx:jmxri:jar:1.2.1: Could not transfer artifact com.sun.jdmk:...