Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

THIS IS A RAW VERSION, IDENTICAL TO http://docs.codehaus.org/display/SM/Using+EclipseImage Removed AND WILL BE CHANGED IN THE NEXT HOUERS.

Introduction

This document will guide you through importing ServiceMix into the IDE through importing ServiceMix 3 into the Eclipse IDE.

The Maven website offers some additional information concerning Maven and Eclipse, for example how Maven goals can be executed from within Eclipse or alternative ways of importing projects into Eclipse.

Pre-Installation Requirements

Hardware:

...

...

Operating Systems:

  • Windows: Windows XP SP2, Windows 2000.
  • Unix: Ubuntu Linux, Powerdog Linux, MacOS, AIX, HP-UX, Solaris, any Just about any Windows or Linux/Unix platform that supports Java.

Environment:

  • Java Developer Kit (JDK ) 1.5.x (Java 5) for compiling/building.
  • The JAVA_HOME environment variable must be set to the directory where the JDK is installed, e.g., c:\Program Files\jsdk.1.5.x
  • Maven 1Maven 2.0.2 6 or greater.
  • Eclipse 3.x 3 or greater.

Importing ServiceMix

Below are the steps to import ServiceMix as a project in Eclipse.:

Preparing the

...

Source for Eclipse

1) Grab the sources from

...

the Subversion repository or download

...

the ServiceMix source distribution

...


2) Build the source with the following command on the command line:

On Unix:

Code Block

export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"
mvn install

On Windows:

Code Block

set MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"
mvn install
Warning
Unit tests errors
Unit tests errors

If you encounter some failures due to unit tests errors do the following:

Code Block

mvn install -Dmaven.test.skip=true
Warning
ServiceMix 3.2.x build
ServiceMix 3.2.x build

If you try to build ServiceMix 3.2.x version, you need to do the following:

Code Block

mvn -Dmaven.test.skip=true -P=step1
mvn -Dmaven.test.skip=true -P=step2
Warning
On checkstyle errors
On checkstyle errors

If maven build dies with some checkstyle or pmd errors then do the following:

Code Block

mvn -Dmaven.test.skip=true -Pstep1,nochecks install
mvn -Dmaven.test.skip=true -Pstep2,nochecks install
Warning

3) Now create the necessary Eclipse project files using the following command on the command line:

Code Block

mvn eclipse:eclipse

...

Importing the Source Into Eclipse:

  1. From the "File" menu select "Import"


  2.  Select Select "Existing Projects into Workspace" and click "Next"

    Image Added
      Image Removed
  3. Browse for the root directory , which is the directory in which (into which you downloaded ServiceMix).  "Select All" the files projects in the "Import" pop-up window. They window - they are probably already pre-selected for you (check box is boxes are checked).  Un-checking the option "Copy projects into workspace" allows you to automatically always edit the current version of the SVN checkout folder, thus avoiding an import after each SVN update. Click "Finish" in the "Import" window; the import takes around three minutes.

    Image Added
      Image Removed
  4. From the In the menu bar, open "Windows"  menu and click "Preferences"
    The "Preferences" window will pop-up.
    Change to JDK 5
    Windows>preferences click on Compiler
    Click on the "Java" plus sign and change to "Compiler". Compiler compliance level must be 5.0, ; select this option in the pull down menu and select.
    Check the "Use default compliance settings" box. 


     
  5. Then check under "Installed JREs" that you have JDK 5, e.g., jre_1.5.x 


     
  6. Click on the Java plus sign, then click on "Build Path
    " and then select "Classpath Variables"


     
  7. Click on "New" button to right
    A pop-up appears.
    Enter the Name: M2_REPO
    Enter the Path , which is of your local maven repository, usually located in
    your <your home directory directory>\.m2, for example:
    C:\Documents and Settings\gnodetexjobb\.m2\repository  repository
     

     
  8. Click "OK" button. The necessary build takes around three minutes.

Running an Example

Now you can run an example:

  1. a. In the Package Explorer find the Main class, which should be located in : org.apache.servicemix/Main.java under servicemix-core/src/main/java/
    under org.apache.servicemix/Main.java.
    Double and double click on the main() classmethod
    Image Removed
    Image Added
     
  2. From the Run menu select "Run..." 


     
  3. You will get a "Run" window pop-up, from there select "Java Application".
    1. Click on New button in botton left (Eclipse <v3.2) or the icon in the top left (Eclipse v3.2)
    2. Name the Project: any name you like, for example if you want to run the FilePoller / FileBinding application call it "filepoller", so it's easy for you to remember what this run configuration does.
    3. Click on arguments button"Arguments" tab:
      1. In the "Program Arguments" box enter servicemix.xml
      2. In the Working Directory enter the path of your example. Such as :
        C:\Program Files\servicemix-1.0.1\examples\file-binding S:\apache-servicemix\src\main\release\examples\file-binding where S:\ is assumed to be your servicemix root directory.
        Note

        For ServiceMix 3.1 S:\ is assumed to be <servicemix_root>\distributions

        You can use the "File System..." button to browse for your directory.
         
        Image Added
    4. Click Apply.
    5. Click Run 
      Image Removed

Configuring Eclipse

Updating Eclipse from Trunk

...

      1.  
    1. Click on the tab "Classpath" to give Eclipse needed information on where to search for executable files.
      This description sticks to the file-binding example, but a similar procedure will be needed for most examples and your own code as well.
      There are three main ways to add classes to the classpath:
      1. You can add other projects of the workbench. Doing this will make the file-binding example run.
        1. Click "User Entries"
        2. Click "Add Projects" and click the checkbox(es) in front of the project(s) that are required. For convenience reasons you may click "Select All".
           
          Image Added
           
        3. Click "OK". Now your Run-dialog shall look similar to this screenshot:
           
          Image Added
           
      2. You can add JARs and classes that are stored within a path contained in the classpath environment variable. This is not required for the file-binding example, but possible, e.g. if you want to run a specific ServiceMix version from a JAR for bug reproduction - this case is used for the following description. Often, this way is used to reference dependencies Maven downloads automatically for you.
        1. Click "User Entries"
        2. Click "Advanced", "Add Classpath Variables" and "OK"
           
          Image Added
           
        3. Check M2_REPO and click "Extend"
           
          Image Added
           
        4. Choose the JAR containing the bytecode for the missing classes. If you want to run SOME_VERSION of ServiceMix, choose /org/apache/servicemix/servicemix-core/SOME_VERSION/servicemix-core-SOME_VERSION.jar
           
          In case you want to reference a dependency, proceed in the same way. In case you do not know which package you shall select, see below at #Troubleshooting.
           
          Image Added
           
        5. Click "OK"
      3. You can add arbitrary folders to the classpath. This is usually only needed for your own code. To explain the workflow, let's assume you did not add any projects, thus your file-binding example does not run but thows errors and the console window contains this message:
        No Format
        
        Error 'Bean class [org.apache.servicemix.components.file.FileWriter] not found'
        
        1. Click "User Entries"
        2. Click "Advanced", "Add External Folder" and "OK"
           
          Image Added
           
        3. When S:\ is your servicemix root directory, select/enter S:\servicemix-components\target\classes
           
          Why this directory? Well, have a closer look at the error message presented above. The package org.apache.servicemix.components indicates the location of the missing bean FileWriter is servicemix-components, and as we need an executable file, the target\classes subdirectory is where to look. Of course we shall proof that FileWriter really is located here, so execute dir /s FileWriter.class in the given directory and watch the output. For further hints, see below at #Troubleshooting.
           
          Image Added
           
        4. Click "OK".
  1. Click Apply.
  2. Click Run.

Now, ServiceMix shall start with the static configuration file (servicemix.xml) you pointed at and in the Console tab all log output will be displayed.

Debugging ServiceMix

This is extremely easy when ServiceMix was already running - it just requires to set a breakpoint in the Main.java (or anywhere else) and a press of F11 (debug last launched).

Troubleshooting

One or two lines of error messages

In case you see an error message like

No Format

java.lang.NoClassDefFoundError: org/apache/servicemix/Main

in the console window, the ServiceMix class (or xbean or whatever is stated) file is not found. Did you add the class files to the classpath like stated above (see "Add Projects")? In case you did, there may not exist any class files as they were not yet built. You can do that by executing

No Format

mvn install

in the source's root directory. This will take roughly 10 to 15 minutes. Maybe you prefer to reference a binary distribution (see "Add Classpath Variables" above).

Lengthy error messages (stack trace)

Scan the messages in the console window from top to bottom until you find one stating a missing component, indicated by a package name - in case it's a "java.lang.NoClassDefFoundError" or "java.lang.ClassNotFoundException", the missing class is printed directly after that error string, whereas for instance "Error creating bean with name" is demanding slightly more search in order to find out the missing component.

Messages may look like one of the following

No Format

Error 'Bean class [org.apache.servicemix.components.file.FileWriter] not found'

or 

No Format

java.lang.ClassNotFoundException: org.quartz.SimpleTrigger

First extract the package name from the error message, so org.apache.servicemix.components respectively org.quartz for the above examples.

Now, you have to choose the appropriate procedure:

  • Build the class / project. "One or two lines of error messages" above gives some hints.
  • Add the required library to the classpath like stated above for "Add Classpath Variables". Look in the Maven repository for a folder matching the missing package. Sometimes the top level domain (org, com, de and the like) is omitted, so package org.quartz may be placed in folder quartz. Then choose a JAR containing executable bytecode classes, so not the quartz-1.5.1-sources.jar but quartz-1.5.1.jar
  • Add the required library to the classpath like stated above for "Add External Folder". The package indicates the location of the missing bean FileWriter is servicemix-components, and as we need an executable file, the target\classes subdirectory is where to look. Of course we shall proof that FileWriter really is located here, so execute dir /s FileWriter.class in the given directory and watch the output.

Redo this until no class/JAR is missing any more.

See also User's Guide: 3. Installation, Troubleshooting.

Projects with failing build in Eclipse workspace

The first line of java classes in projects with failing build will look like this:

No Format

package ${packageName};

Reason for the problem is Eclipse which considers the .java files as classes to compile.  In the case of archetypes, they are just resources to be bundled, and there is no real code to compile.  To tell Eclipse to not compile these archetype files, one may add an exclusion pattern to the source folder in Eclipse's build path configuration (see screenshot). This has to be done manually every time one imports the projects as the maven eclipse plug-in cannot generate this information in the .classpath files automatically. For ServiceMix 3.0, the change has to be applied in three Eclipse projects: servicemix-binding-component, servicemix-jsr181-annotated-service-unit and servicemix-service-engine.

Image Added

...