Building Struts 2 on Mac OS X with Maven using mvn install

When trying to build Struts 2 on Mac OS X (I'm using 10.4.8) you might get an error like:
 class="codeContent" class="codeContent"[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

----------
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) org.apache.struts:struts2-core:jar:2.0.3-SNAPSHOT
        2) org.apache.struts:struts-annotations:jar:1.0-SNAPSHOT
        3) com.sun:tools:jar:1.5.0

----------
1 required artifact is missing.

for artifact:
  org.apache.struts:struts2-core:jar:2.0.3-SNAPSHOT

from the specified remote repositories:
  Maven Snapshots (http://snapshots.maven.codehaus.org/maven2/),
  central (http://repo1.maven.org/maven2),
  opensymphony (http://maven.opensymphony.com),
  apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository),
  snapshots-maven-codehaus (http://snapshots.maven.codehaus.org/maven2)
The problem is that there is no tools.jar on Mac OS X. The analog for tools.jar on Mac OS X is classes.jar. A quick fix to allow the build to continue is to change the sun.jdk dependency in a pom.xml. For this, I edited the
 class="commentblock"pom.xml
located in
 class="commentblock"~/.m2/repository/org/apache/struts/struts-annotations/1.0-SNAPSHOT/
 class="codeContent"    <dependency>
      <groupId>com.sun</groupId>
      <artifactId>tools</artifactId>
      <version>1.5.0</version>
      <scope>system</scope>
      <!-- This line doesn't work on a Mac: <systemPath>${java.home}/../lib/tools.jar</systemPath> -->
      <systemPath>${java.home}/../Classes/classes.jar</systemPath>

    </dependency>

Troubleshooting and other Tips

OutOfMemoryError

If you are getting OutOfMemoryError exceptions when attempting a full build of Mule you may try increasing the max heap and the PermGen space sizes. Either export a MAVEN_OPTS variable in your shell or add it to the original mvn script.

 class="codeContent"MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=256m

or edit your bash shell

export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"

Comments

Popular Posts