Version 10

    Preface

    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.

     

     

    Solution

    Checkout the AS7 code base

     

    The reference documentation may be reached at 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 EGit later on

     

    TODO: add instructions using EGit

     

    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. If your build does not have the eclipse market place installed, you should consider using the Eclipse 3.7 M6 Developer Build, or, installing egit and m2eclipse directly from the following update site:  http://download.eclipse.org/releases/indigo

     

    However, using the Eclipse Marketplace can be accomplished as follows:

     

    install-from-marketplace.png

     

     

    install-egit.png

     

    install-m2eclipse.png

     

    Add your local git Repository


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

     

     

    add-local-git-repo.png

     

     

    add-local-git-repo-2.png

     

    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.

     

     

    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.

     

    Correct compilation errors

    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.

     

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

     

    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.

     

     

    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.

     

     

    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.

     

     

    classpath-file.png

     

     

    The root cause is adressed in the following Eclipse bugzilla: 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

     

    Project Configuration is out of date

    If you see an error saying "project configuration is not up-to-date with pom.xml run project configuration", then for the projects in error, right click, Maven -> Update Project Configuration.