Hobione's Weblog

Living & Breathing in Web 2.0 Era

Maven Jetty-plugin and IntelliJ IDEA

Scenario: You have a maven project and you want to tie with IntelliJ 9 to make it part of IDE built-in commands instead of using command line interface.

Pre-requisite: Need to read Maven Jetty-Plugin User Guide.

Solution: Here is a skeleton project hierarchy:
You also should have a pom.xml file directly under the project.

Now, open up the IntelliJ. Go to File –> Open Project and choose the pom.xml file to bring the project into Intellij and here how it looks. Notice, Idea has created few extraneous files like .impl, .ipr and .iws.
Project in Intellij

How to configure Run command?
In the IDEA, go to Run –> Edit Configurations
You see the “Run/Debug Configurations” window. Under Parameters tab choose the directory and set the goal command:
Run/Debug Configurations

Under Runner tab, set VM Parameters to these: (You may not need to sett all these)


Runner Tab

Application is ready to run by click the play button.
Play Button
Here is the proof:
Jetty Run

How to configure Build?

It should shows the Build option to the IDEA drop down. Choose the Build option and click the play button.
Build with Play Button

How to configure clean?
Clean Project from target directory

How to configure scm bootstrap?
SCM BootStrap

Here is the final configured list looks like:
Configured List

Hopefully, this post will help me to remember and configure all my future apps with maven jetty-plugin in IntelliJ Idea.


September 22, 2010 Posted by | Maven | Leave a comment

Missing com.sun:tools:jar:1.4.2

Error message: Missing:
1) com.sun:tools:jar:1.4.2

  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.4.2 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there:
      mvn deploy:deploy-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency:
  	1) HRTrainingModel:HRTrainingModel:jar:1.0-SNAPSHOT
  	2) commons-attributes:commons-attributes-compiler:jar:2.1
  	3) com.sun:tools:jar:1.4.2

1 required artifact is missing.

for artifact:

from the specified remote repositories:
  Eclipse (http://repo1.maven.org/eclipse/),
  Maven2 (http://repo2.maven.org/maven2/),
  central (http://repo1.maven.org/maven2),
  JBOSS (http://repository.jboss.org/maven2/),
  Ibiblio (http://www.ibiblio.org/maven/mule/dependencies/maven2/)

Group-Id: HRTrainingModel
Artifact-Id: HRTrainingModel
Version: 1.0-SNAPSHOT
From file: C:\WorkspaceMyEclipse\HRTrainingPersistence\pom.xml

Solution: You can use command line to resolve this but here how I did it.
1. Right click on the project to import the jar file manually because, I could not find the tools.jar file from any publicly available repositories.  I have set up the JAVA_HOME = C:\Program Files\Java\jdk1.6.0_10

Import Jar File in Maven Manually

Step 2. Setup Artifact form as follows.

Maven setup artifact

Once you click okay, the Maven repository should looks like as follows.
Maven repository, .m2

3. Now, the last step.  Open up the pom.xml file add the dependency.


Under Maven Dependencies, you should able to find tools.jar.

Similar issue:

FAILED for project: 



Unable to locate the Javac Compiler in:
  C:\Program Files\MyEclipse 6.6\jre\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

Caution: You must have both the Maven JDK and the default Java JDK set to the same version.
See Jason Lee’s two comments under Comments tab below.

March 11, 2009 Posted by | Maven | 9 Comments

MyEclipse Maven Error: Generics are not supported in -source 1.3

Problem: I got this error:

C:\WorkspaceMyEclipse\HRTrainingPersistence\src\main\java\gov\faa\amc\nas\hrtraining\persistence\TrainingClass.java:[45,2] annotations are not supported in -source 1.3</pre>
(use -source 5 or higher to enable annotations)

Solution: Maven’s default java complier is 1.3 (very weird).  I had to add a plugin tag for Java 1.5,  right after <dependencies> tag.

   <!-- For annotations and other Java5 stuff -->

References: Maven Documentation Home

Q: How to setup Maven JDK Home?
Maven JDK Home setup

Reference: How to fix Maven ‘Add JDK’ warning?

March 4, 2009 Posted by | Maven | 4 Comments

Oracle Driver and Maven Repository

Why it is so hard to find a Oracle Driver in a Maven Reposity?

I don’t know the answer.  I have looked up so many places but apparently only one repository so far I found has the latest jar.  A “remote repository” that has the artifacts you are looking for. By default Maven uses the iBiblio repository but a lot of projects create and maintain their own repositories.

Here is the pom.xml. pom.xml
Sorry, I had to make my pom.xml to JPEG. Some reason WordPress was giving me Javascript error b/c of all different kind of tags the pom has.

Thanks to Jason Lee for his support and being my mentor in JEE world. Appreciated your help as always …..

For local jar file or project dependency, I have used <distributionManagement> tag.  It’s very handy.  This tag has to reside outside of <repositories> tag.  So intead of http:// url, I have used windows file system path for repository references.

            <id>Local Windows Repository</id>

Click here to see the whole Maven pom file.

January 9, 2009 Posted by | Maven | 1 Comment