THIS IS A RAW VERSION, IDENTICAL TO http://docs.codehaus.org/display/SM/Using+Eclipse AND WILL BE CHANGED IN THE NEXT HOUERS.
Introduction
This document will guide you through importing ServiceMix into ServiceMix 3.0 into the IDE Eclipse Java Development Tools v3.x.
Pre-Installation Requirements
...
- 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 1.0. 2 or greater.
- Eclipse 3.x or greater.
...
- Grab the sources from svnor download servicemix source distribution.
- From the Open a command line execute and change to the source root folder. Execute the following Maven 2 command to ready the project for Eclipse. It will take around two minutes.
Code Block mvn eclipse:eclipse
...
- From the "File" menu select "Import".
- Select "Existing Projects into Workspace" and click "Next"
- Browse for the root directory, which is the directory in which you downloaded ServiceMix. "Select All" the files in the Import pop-up window. They are probably already pre-selected for you (check box is 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.
- From the "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, pull down menu and select.
Check the "Use default compliance settings" box.
- Then check under "Installed JREs" that you have JDK 5, e.g., jre_1.5.x
- Click on the Java plus sign, then click on "Build Path
" and then select "Classpath Variables".
- 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
- Click "OK" button. The necessary build takes around three minutes.
Running an Example
Now you can run an example:
- a. In the Package Explorer find the Main class, which should be located in: servicemix-core/src/main/java/
under org.apache.servicemix/Main.java.
Double click on the main() classmethod.
- From the Run menu select "Run..."
- You will get a Run window pop-up, from there select Java Application.
- Click on New button in botton left (Eclipse <3.2) or the icon in the top left (Eclipse v3.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.
- Click on arguments button"Arguments" tab:
- In the "Program Arguments" box enter
servicemix.xml
- In the Working Directory enter the path of your example. Such as:
C S:\Program Files\servicemix-1.0.1apache-servicemix\src\main\release\examples\file-binding
where S:\ is assumed as your servicemix root directory.
You can use the "File System..." button to browse for your directory.
- In the "Program Arguments" box enter
- 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:
- You can add other projects of the workbench. Doing this will make the file-binding example run.
- Click "User Entries"
- 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".
- You can add other projects of the workbench. Doing this will make the file-binding example run.
- 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:
- Click "OK". Now your Run-dialog shall look similar to this screenshot:
- You can add JARs and classes that are stored within a 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 or the like - this case is used for the following description. Often, this way is used to reference depenedencies Maven downloads automatically for you.
- Click "User Entries"
- Click "Advanced", "Add Classpath Variables" and "OK"
- Check M2_REPRO and click "Extend"
- You can add JARs and classes that are stored within a 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 or the like - this case is used for the following description. Often, this way is used to reference depenedencies Maven downloads automatically for you.
- 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.
- Click "OK"
- 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 and the console window contains this message:
No Format |
---|
Error 'Bean class [org.apache.servicemix.components.file.FileWriter] not found'
|
- Click "User Entries"
- Click "Advanced", "Add External Folder" and "OK"
- When S:\ is your servicemix root directory, select/enter
S:\servicemix-components\target\classes
- When S:\ is your servicemix root directory, select/enter
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.
- Click
- "OK".
- aaa
TODO
Click Apply.
Click Run.
error message
No Format |
---|
java.lang.NoClassDefFoundError: org/apache/servicemix/Main
|
class file not found. execute
No Format |
---|
mvn install
|
to get a build
No Format |
---|
Error 'Bean class [org.apache.servicemix.components.file.FileWriter] not found'
|
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.
When you run the example, Eclipse will show in the Console window error messages like "Error creating bean with name", "java.lang.NoClassDefFoundError" or similar. Scan the messages from top to bottom until you find the 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.
First extract the package name (eg: "java.lang.ClassNotFoundException: org.quartz.SimpleTrigger" tells you that the package org.quartz is missing). Add the required library to the classpath like stated above for "Add Classpath Variables". Look for a folder matching the missing package (sometimes the TLD is omitted, so package org.quartz may be placed in folder quartz), and choose a JAR containing executable bytecode classes (so not the quartz-1.5.1-sources.jar but quartz-1.5.1.jar) within the folder. Redo this procedure until no JAR is missing any more.
TODO
Configuring Eclipse
Updating Eclipse from Trunk
...