Eclipse + JBossAS + EJB 3.0 setup instructions

Coding, Linux — October 17, 2006 at 8:30 pm

Today I was tasked with getting my software engineering group’s development environment set up. The requirement for our project is to build a three-tier application using a major component model framework. We chose to use:

  • Java/EJB because it is well documented and in a language we all know (and since we don’t want to use COM+ or .Net as we don’t have Windows boxes, the only language we could use)
  • Eclipse because it is the best Java IDE and is cross platform
  • JBoss AS because it is a well supported J2EE application server and seemed to have good Eclipse support. Additionally, it is one of the few ASes to have J2EE 3.0 support (sort of, see below).

The combination of these tools is supposed to be easy, but I found it fairly tricky because of lack of documentation. I’m sure it could be worse had the guys over at JBoss not worked as hard as they have to bring a J2EE platform to the open-source world. The rest of this post include the steps that we took to install these tools and get them running. Hopefully they’ll be of help for those of you who got here through Google.

Installing Eclipse, JBossAS with EJB 3.0

  1. Prerequisites: A Java 5 JRE must be installed to be able to use JBoss’s EJB 3.0.
  2. Download and install JBossAS: We are using the latest production release of JBoss AS, version 4.0.4, which can be downloaded from Sourceforge. To use the bundled EJB 3.0, you must not download the zip file. Additionally, you must use the graphical installer to select the EJB 3.0 packages.

    Once downloaded, execute
    java -jar jboss-4.0.4.GA-Patch1-installer.jar
    to launch the installer. Select your preferred language, click “OK,” and click “Next.” The installer may freeze for a few moments; this is normal. Continue forward. Choose a sane install directory: because I am administering my own machine, I’ve installed JBossAS into “/usr/local/jboss”. Choose something that makes sense for you, but be aware I reference my own install directory later and appropriate substitutions should be made.

    On the next panel, be sure to select “ejb3″ or else you won’t have EJB 3.0 support. The default values for the remaining options were sufficient for our purposes.

    When this completes, you now have JBossAS installed. Try to run it by executing “bin/run.sh” in the JBossAS directory.

  3. Install / Upgrade Eclipse: Eclipse is a powerful Java IDE that is convenient because it is free and open-source. A plethora of plugins exist for this development platform, some of which we’ll install later. You can download Eclipse from the Eclipse website. (Alternatively, you can install JBoss’s bundle that includes Eclipse and some of the plugins we’ll install later. I had an existing installation of Eclipse and would prefer to run my existing vanilla version over the JBoss-branded one. I had originally installed Eclipse from Gentoo’s Portage system. YMMV).

    If you already have Eclipse installed, launch it and upgrade it: Click on “Help -> Software Updates -> Find and Install” and select “Search for updates of the currently installed features”. Click appropriate buttons to continue.

    (Caveat: if you’ve installed Eclipse into a global install directory like “/usr” or “/opt”, be sure to run Eclipse as root or some user that can write to these directories or more preferably change the install directories).

  4. Install Eclipse Plugins: Our team is using a Subversion repository for source code management; the best Eclipse SVN plugin is the new but complete Subversive from the Polarion group. This plugin integrates SVN actions and management into the Eclipse GUI. We also want to use the JBoss Eclipse plugins to interface our project to the application server we just installed. This plugin has a dependency on an upgraded version of the Eclipse EMF tool, so we need to perform this upgrade.

    In Eclipse, Click on “Help -> Software Updates -> Find and Install” and select “Search for new features to install”. For each of the following URLs, create a new update site by clicking the “New Remote Site” button:

    • Subversive
      http://www.polarion.org/projects/subversive/download/1.1/update-site/
    • Eclipse’s EMF
      http://www.eclipse.org/emf/updates/
    • JBoss Eclipse IDE Plugins
      http://download.jboss.org/jbosside/updates/development

    Update: Thanks to commenters below (!!), it should be reiterated that only the development JBoss plugins will work at this point in time and are the ones used for the remainder of this setup doc.

    Despite it being installed by default with Eclipse 3.2.1, I also had to install APT on one of my two installs for some reason. It can be found at
    http://www.eclipse.org/jdt/apt/JdtAptUpdateSite .

    Once complete, be sure that all remote sites are checked. Click “Finish” and install all available packages. There may be some additional dependencies, be sure to download those first if there seems to be an error.

  5. Create a new Eclipse Java project: We now must begin setting up the source code locations and supporting libraries. Create a new Java project in Eclipse by clicking “File -> New -> Project…”. Select the “EJB 3.0 Project” item. This item is inspired by the skeleton Eclipse project that is described and downloaded at the JBoss EJB 3.0 Wiki.

    Give the project a name (mine is “ejb3-project”) and click next. Now, click the “Create a JBoss Server”. We must first create a JBoss configuration In the directory tree, select the JBoss Inc / JBoss AS 4.0 (NOT JBoss / JBoss v4.0) item. Give a name of (mine is “default”) and specify where you installed JBossAS (mine is “/usr/local/jboss”). If this is successful, Eclipse will detect the configuration we created when we installed JBossAS. Click next.

    Create a new JBoss Server. Give a name to your new JBoss server (I’ll call mine “Eric”). Click “Finish”. Select the configuration we just created and click “Finish.” If you can’t click finish, Eclipse does not detect EJB3 libraries in the installation of JBossAS you specified. We now have an EJB project framework. There are still a few holes we need to patch in this folder tree.

  6. Providing necessary libraries: We need to add some supplied EJB library code to the CLASSPATH of our project. This allows our project to use methods that are provided by JBoss and TestNG.

    Right click on our new project and select “Preferences”. Navigate to the “Java Build Path” pane and click “Add JARs…”. Select the “jboss-ejb3.jar” element contained within the folder structure “ejb3-project/lib/embeddable-ejb3/”. Click “OK”. Now, add the “testng-4.5.2-jdk15.jar” from within the folder structure “ejb3-project/lib/testng/”. Click “OK”. Now, click “OK” on the Properties pane to return to our project.

    The entire project will be refreshed and compiled. But there are errors. For whatever reason, all *.java files are placed in the default package, despite being declared as being within a package. For each java source file, click on the first error in the file and then click “Move xxx to package yyy”. (Alternatively, you can do this manually by creating the appropriate package and moving the files manually). The project should now compile successfully.

  7. Edit build.xml to your environment: Personally, I didn’t have to edit this file. You may have to depending on your environment, but I think it gets generated from the information supplied earlier.
  8. Build and deploy: Now, click the external executable button and select “Build and deploy”. If you configured the build.xml file properly, this will succeed and give some status messages in the console.
  9. Start the server: Click “Window” -> “Show View” -> “Other”, scroll down to the “Server” folder and select “JBoss Server View”. You should see the server we configured earlier. Right click your server and click “Start”. Hooray your server should start!!

    But, you’ll get an error indicating that the ManagedConnectionFactory is not yet installed. This is because you must install a JDBC driver for either MySQL or PostreSQL in the lib/ directory of your project.

That’s where I end these instructions because that’s where real development starts. I refer you to the JBoss TrailBlazer demo to get a better feel for what comes next in JBoss EJB 3.0 developement and deployment.

22 Comments

  1. Hi, there
    I have a problem with EJB3 libraries. When I click finish button, it will pop up an error message, so I won’t be able to create a project. If I cannot create a project, how can I “Right click on our new project and select “Preferences””?

    Comment by weiming chen — October 22, 2006 @ 3:27 am
  2. Hi Weiming chen.
    I was looking for the Preferences menu after right click on new project, but I didn’t found it same you.

    but I found some in “window->preferences” I don’t sure it will be right.

    May some one reply us to solve this.

    thanks alot.

    Sup

    Comment by Sup — November 13, 2006 @ 1:05 am
  3. Eric,

    Thanks for the instructions - they are very useful to the Google wayfarer. I just wanted to point out to people that they should use the development version of the JBoss IDE, as you have mentioned above.

    Also, the EMF location has probably changed since you wrote this piece. Look at http://www.eclipse.org/emf/updates/ for information on how to get EMF.

    Sualeh.

    Comment by Sualeh Fatehi — December 26, 2006 @ 8:57 am
  4. Man, you saving my life!! Big Thanks!!

    Comment by Pankracy — January 10, 2007 @ 2:17 pm
  5. When I follow this tutorial, I get stuck on step #6. When I click on “Add JARs…” the whole dialog is disabled, and there is an error message that says “No entries available.”

    My project folder looks like this:

    ejb-project
    src
    JRE System Library [java-1.5.0-sun-1.5.0_update10]
    JBossAOP 1.3 Libraries (jdk 1.5)
    JBoss EJB3 Libraries [default]

    I have no “lib” directory and no build.xml.

    What am I doing wrong?

    Thanks,
    J

    Comment by jwagon — January 19, 2007 @ 11:38 am
  6. Subversion plugin may want ‘Mylar’ as a prerequisite. This can be found here: http://download.eclipse.org/technology/mylar/update-site/e3.2/site.xml

    Comment by Elkhornbob — January 20, 2007 @ 11:38 am
  7. Actually, I had some trouble with CSC pre-requisites. All in all, it was easier for me to get Subclipse installed and working instead.

    Comment by Elkhornbob — January 20, 2007 @ 11:51 am
  8. doing a program that call a EJB .But getting a error from “lookup” method.

    Error is “Invent” not bound (Invent is my JNDI Name)

    Server JBoss
    Call From SWT Application.

    Comment by Subhabrata — February 7, 2007 @ 6:49 am
  9. i don’t understand the “Providing necessary libraries” part. i followed this tutorial step by step, but i lost in point 6. please help.

    Comment by Jayne — February 23, 2007 @ 10:23 am
  10. Jayne — Your project needs to include the JBoss libraries so that you can use EJB. These libraries are the code that provides the EJB base on which to develop.

    This may be a clearer description on exactly how to do this:
    http://dev.eclipse.org/newslists/news.eclipse.tools/msg03827.html

    You’ll need to include jboss-ejb3.jar and testng-4.5.2-jdk15.jar in this way.

    jwagon — “ejb3-project” shouldn’t be a folder in your project. I made a project called “ejb3-project” and put all of my files in it.

    Comment by Eric — February 23, 2007 @ 3:37 pm
  11. Please help!!! when I try to plugin jboss in eclipse, i got error:

    Current configuration contains errors that are not corrected by the requested operation and more errors would be introduced. See details for more information.
    —– Current configuration problems —–
    Resulting configuration does not contain the platform.
    —– Configuration problems after the operation —–
    Resulting configuration does not contain the platform.
    org.jbpm.feature (3.0.9) requires plug-in “org.eclipse.swt”.
    JBoss AOP Tools (1.1.2.GA) requires plug-in “org.eclipse.core.resources”.
    JBoss Eclipse IDE (1.6.0.GA) requires plug-in “org.eclipse.core.runtime”.
    Hibernate Tools (3.1.0.beta5) requires plug-in “org.eclipse.core.runtime”.
    org.jboss.ide.eclipse.ejb3.feature (1.0.2.GA) requires plug-in “org.eclipse.core.runtime”.

    Comment by Jayne — February 24, 2007 @ 2:15 pm
  12. I managed to cofigure everything y said ,but when i run JBoss
    it reports an error:

    jboss.mq:service=PersistentManager FAILED because
    org.jboss.mq.SpyJMSException:Couldnt resolve uncommited transactions.
    Message recovery may not be accurate…every derived table must have its own alias…

    and it says that the Managed Connection factory for ejbProjectDs is not yet installed(when i copy war and ear and jar files to the deploy folder in jboss)

    can you please help me with that? I would be VERY GRATEFULL!!!
    THANKS IN ADVANCE!

    Comment by Dean — March 6, 2007 @ 4:53 pm
  13. I have a little bit the same problem as Jayne.

    I’m however not working with JBossAS and EJB 3.0, but with JBoss JBPM Graphical Process Designer. I have followed the instructions that I found on http://docs.jboss.com/jbpm/v3/gpd/installation.html.

    When I select the feature to install, I got the following error: org.jbpm.gd.jpdl.feature (3.0.12) requires plug-in “org.apache.xerces”

    Do you know how I can fix this?

    Thanks in advance

    Sofie

    Comment by Sofie — March 26, 2007 @ 1:05 am
  14. Xerces is an XML parser. http://xerces.apache.org/xerces2-j/install.html is information on installation.

    Comment by Eric — March 26, 2007 @ 3:27 pm
  15. How to add a session bean???
    How to add a web app???

    Comment by bakr — April 16, 2007 @ 9:21 pm
  16. Hi,

    I have installed Eclipse 3.2.1, JBoss 4.0.4GA and plugin for EJB3. I could not set up JBoss server setup while creating EJB3 project. ie., when it is asking for “Create JBoss Configuration”. I appreciate if you can help me to resolve this issue.

    Thank you in advance.

    - Harish.

    Comment by Harish — September 17, 2007 @ 10:33 pm
  17. I followed your instructions but I’m not able to find testng-4.5.2-jdk15.jar and jboss-ejb3.jar anywhere (eclipse or jboss or empty example directories).
    I also can’t find how to install the server.

    I’m using jboss-4.2.1.GA and Eclipse 3.3.0

    Thank you for help.

    Comment by PatruzZRocK — September 18, 2007 @ 2:45 am
  18. All: Unfortunately, I have moved away from the position where I was actively using JBossAS et al. I won’t be able to support these instructions any further, as I’ve seen updates have been made to almost all of the core packages, producing behavior it would take me a long time to replicate.

    I highly recommend trying to use Google to solve your problems, especially things like, “Where can I find…” or “I get this error…” That’s the job of a search engine.

    Comment by Eric — September 18, 2007 @ 9:04 pm
  19. I highly recommend hitting up the JBoss discussion board :

    http://jboss.org/index.html?module=bb

    Comment by Eric — September 18, 2007 @ 9:05 pm
  20. I have two things to say:
    1. Congratulations for this kind of support.
    2. A question: I´m using EasyEclipse Version: 1.2.2.2 and getting a repetitive problem. Sometimes in the Java Build Path the JBoss EJB3 Libraries show as JBoss EJB3 Libraries [error]. Expanding it I see that all JBoss jar files are missing, so none reference to any of their library content works like a simple import javax.ejb.Stateless; Do you have any clue how this maybe fixed?

    Comment by Ismael — October 8, 2007 @ 6:34 am
  21. Hello sir
    I am getting this error while build and deploy. “exception occurred executing command line”. please help

    Comment by Harshvardhan koshti — October 12, 2007 @ 8:48 pm
  22. can u pls give a small project using this presentation.

    Comment by Deepmala — July 14, 2008 @ 7:54 am

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. | Eric Garrido