Importing Sample Maven projects in Eclipse for the book OReilly's Enterprise JavaBeans 3.1

Printer-friendly versionPDF version

So while reading this book, I though I might as well get the source code and look and run it in an IDE instead of just glance at it in the book. So turned my attention to section V, examples and proceeded to the anonymous git cloning instruction and building as below :

git clone git://github.com/jbossejb3/oreilly-ejb-6thedition-book-examples.git
cd oreilly-ejb-6thedition-book-examples
mvn clean install

Wow that was easy, but wait, that doesn't run the projects for me. And my goal was to open the project in eclipse atleast. And be able to run junits and build and deploy there as well. The book forgets to mention how to do this. Or probably it deems it too mundane a task. I did not really see an eclipse project file in there so I was lost for a bit. I went down the road to import a chapter as a project but that was too painful.

Than I resigned at this. Didnot want to do this for each chapter, adding dependencies and jar manually. The example section mention that they use "Shrinkwrap" and "Arquillian" for assembling and deploying to container respectively. So I thought I might as well take a look at what these are. And surprise surprise, the Arquillian "Getting Started" guide just provided my the full blown steps to open books source code effortlessly in eclipse. You can read the precise steps and alternative steps for "Open the Project in Eclipse" for your selves here . But this is what I did approximately and what you need to load the examples as eclipse projects:

  • Install the Maven integration plugin for eclipse.
  • Install the Jboss tools for eclipse.
  • Restart eclipse and
  • Choose File->Import and find the option "Maven existing" projects.
  • Navigate to the top folder with the top level "pom.xml" in the git clone location above and click finish. You can see the import screen below and the loaded projects already in the background below.

Maven project import dialog box

You get the project perfectly created without any dependencies issue. And that is how it should be, after all maven is used exactly for this purpose, to save you from dependency hell. Run a few junit test that come with the projects and everything should be as green as grass. Or atleast as long as the examples don't start using something other than maven. Well enjoy these steps for as long as they work.

 

 

Top level category:

Add new comment