[jboss-user] [JBoss Tools] - Hacking AS7 using Eclipse
do-not-reply at jboss.com
Tue Apr 12 10:41:07 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
There's already an 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.
h2. 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 achieved 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
h6. +TODO: add instructions using EGit+
h2. 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.
h1. http://community.jboss.org/servlet/JiveServlet/showImage/16138/install-m2eclipse.png http://community.jboss.org/servlet/JiveServlet/downloadImage/16138/install-m2eclipse.png
h2. Add your local git Repository
After rebooting Eclipse, you'll now be able to import the local git repository.
h2. 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.
You'll then end up with an project in your package explorer, that holds the name given to it in the maven pom.
h2. Correct compilation errors
h3. 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.
h3. 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.
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.
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.
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
The basic problem behind this is that the lookup attribute was introduced in Java EE6 and the current jdk can't handle it. The basic hack that allows maven to compile this is to put the EE jar into the endorsed directory. You may have an extensive read about this here: http://jaitechwriteups.blogspot.com/2011/02/resource-and-new-lookup-attribute-how.html http://jaitechwriteups.blogspot.com/2011/02/resource-and-new-lookup-attribute-how.html
Comment by going to Community
Create a new document in JBoss Tools at Community
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the jboss-user