[jboss-user] [JBoss Tools] - Hacking AS7 using Eclipse

Andre Dietisheim do-not-reply at jboss.com
Tue Apr 12 09:47:27 EDT 2011


Andre Dietisheim [http://community.jboss.org/people/adietish] modified the document:

"Hacking AS7 using Eclipse"

To view the document, visit: http://community.jboss.org/docs/DOC-16718

--------------------------------------------------------------
h1. Preface
There's already a article that shows you very well how to checkout and build the AS7 code base using command line tools. Unfortunately using Eclipse on top of those steps shows some gotchas that are not obvious. This article will show you how to import the AS7 projects to Eclipse.



h1. Checkout the AS7 code base

The reference documentation may be reached at  http://community.jboss.org/docs/DOC-15596 http://community.jboss.org/wiki/HackingonAS7. It shows you extensively what steps need to be achieve to get things up and running on the command line. Please follow these steps. I'll try to add the corresponding steps for  http://www.eclipse.org/egit/ EGit later on

+TODO: add instructions using EGit+

h3. Install M2Eclipse and EGit
The next step involves installing the appropriate plug ins for Eclipse. The easiest way to achieve that is to install them from the Eclipse Marketplace.


 http://community.jboss.org/servlet/JiveServlet/showImage/16140/install-from-marketplace.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/16140/install-from-marketplace.png 


 http://community.jboss.org/servlet/JiveServlet/showImage/16139/install-egit.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/16139/install-egit.png 

h1.  http://community.jboss.org/servlet/JiveServlet/showImage/16138/install-m2eclipse.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/16138/install-m2eclipse.png 

h1. Add local git Repository

After rebooting Eclipse, you'll now be able to import the local git repository.


 http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-6-16132/add-local-git-repo.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-6-16132/449-73/add-local-git-repo.png 


 http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-6-16133/add-local-git-repo-2.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-6-16133/450-455/add-local-git-repo-2.png 

h1. Import Maven Project
You'll then finally be able to import your AS7 sub-project into Eclilpse. Pick it in the list of available folders in the *Working Directory* and choose *Import Maven Project* from the context menu.


 http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-6-16143/import-mavenproj-from-git.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-6-16143/300-405/import-mavenproj-from-git.png 

You'll then end up with an project in your package explorer, that holds the name given to it in the maven pom.

h1. Correct compilation errors
h2. Run the maven build in eclipse
You may eventually have to run the maven build in a first place so that all required maven artifacts get installed to the local maven repo. 

h3. Quick fix the M2Eclipse lifecycle errors
You may also experience maven related probles when using the latest *m2eclipse 0.13*. M2eclipse speeds up the build cycle by stripping it down to the bare minimum needed in Eclipse (you may read detailed documentation about in the  https://docs.sonatype.org/display/M2ECLIPSE/Project+build+lifecycle+mapping m2eclipse wiki). M2eclipse will therefore report you that specific plugins are not covered by the build lifecycle. Those errors are easily fixable with quick fixes that are offered to you in the pom editor.

h2. Correct build path precedence errors
You may experience compilation errors that are not related to m2eclipse. Most of them are due to the fact, that the build setup in Eclipse differs from what is used with bare Maven on the command line. 
In my particular case, where I imported the AS7 demos, I ended up with the odd case where the Eclipse compiler complained about an illegal attribute to the *@Resource* annotation.


 http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-6-16144/compilation-errors.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-6-16144/450-249/compilation-errors.png 


The compilation error that is reported is due to a bad resolution of the *@Resource* annotation. 

If you use Eclipse with m2eclipse you'll end up with at least 2 *compilation containers* that resolve required classes. Eclipse will lookup in the *JRE System Library* in a first place and fall back to the *Maven dependencies* in a second step.


 http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-6-16145/build-path.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-6-16145/450-122/build-path.png 


The Eclipse compiler actually applies the annotation that may be found in the *jdk*. This jdk annotation does not support the lookup attribute and compilation therefore fails. On the other hand the *maven dependencies* hold the correct, extended annotation which knows about a lookup attribute. So this basically boils down to the precendece of the compilation containers in Eclipse. You may fix the above error in the project build path:

> Remove the *JRE System Library* and add it back again. 

The GUI will actually not show any change, it will still show the JRE System Library in first and the *Maven Dependencies* in second place. Behind the scenes though, their order was inverted. Eclipse now resolves artifacts from the Maven container and will fall back to the JRE if needed.


 http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-6-16137/classpath-file.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-6-16137/450-90/classpath-file.png 

The root cause is adressed in the following Eclipse bugzilla:  https://bugs.eclipse.org/bugs/show_bug.cgi?id=342128 https://bugs.eclipse.org/bugs/show_bug.cgi?id=342128
--------------------------------------------------------------

Comment by going to Community
[http://community.jboss.org/docs/DOC-16718]

Create a new document in JBoss Tools at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2128]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110412/36516e42/attachment.html 


More information about the jboss-user mailing list