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

Andre Dietisheim do-not-reply at jboss.com
Tue Apr 12 06:05:43 EDT 2011


Andre Dietisheim [http://community.jboss.org/people/adietish] created 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 (*Help -> Eclipse Marketplace...*)

 http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-1-16131/install-from-marketplace.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-1-16131/336-375/install-from-marketplace.png 
 http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-1-16129/install-egit.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-1-16129/450-224/install-egit.png 

h1.  http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-1-16130/install-m2eclipse.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-1-16130/450-228/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-1-16132/add-local-git-repo.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-1-16132/449-73/add-local-git-repo.png 

 http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-1-16133/add-local-git-repo-2.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-1-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-1-16134/import-mavenproj-from-git.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-1-16134/439-593/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. M2Eclipse related errors
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. You may also experience maven related errors when using the latest *m2eclipse 0.13*. M2eclipse tries to speed up the build cycle in eclipse by stripping it down to the bare minimum needed in Eclipse. Those errors are easily fixable with quick fixes that are offered to you in the pom editor.

h2. 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.


@Resource(lookup="java:module/SimpleManagedBean")



 http://community.jboss.org/servlet/JiveServlet/showImage/102-16718-1-16135/compilation-errors.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-1-16135/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-1-16136/build-path.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-16718-1-16136/450-121/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 an the compilation therefore fails. On the other hand, the *maven dependencies* hold the correct, extended annotation which knows about a lookup attribute. So this boils down to the precendece of the compilation container in the Eclipse setup. 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 reflect 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 first and will fall back to the JRE in a second step.


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

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/4ff87447/attachment.html 


More information about the jboss-user mailing list