Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Lyo/creating OSLC4J project

< Lyo
Revision as of 15:03, 29 November 2016 by Jad.kth.se (Talk | contribs)

General Setup for OSLC4J development

You first need to setup an Eclipse environment for general OSLC4J development:

  1. Unless already installed, you need to first install the JDK 8 (see the prerequisites).
  2. Install your preferred Eclipse distribution. Which distribution to use?
  3. Once Eclipse is installed, you need to make sure the JAVA_HOME environment variable is set to the installed JDK (instead of the default JRE).
    1. Select Window-->Preferences
    2. Select Java-->Installed JREs
    3. Click Add...
    4. In the new window that appears,
      1. choose Standard VM as JRE Type
      2. click Next.
      3. As JRE home choose the installation dir of your JDK
      4. click Finish.
    5. Back to the preferences screen
      1. select the old JRE
      2. click Remove
      3. check the newly added JDK and
      4. click OK.

Sample Project

As a complement when following the instructions below, this sample OSLC4J project contains a basic but complete Eclipse project that can be used as a starting point and/or a reference.

The project is configured with the following values:

ProjectName: SampleAdaptor
PackageName: your.basepackage.name
  1. If you desire to change the project configuration, search and replace in the files below each of the above keywords with the specific values for your project
    • .project
    • pom.xml
    • adaptorModel/my.adaptorInterface
    • src/main/webapp/WEB-INF/web.xml
    • src/test/resources/launches/Launch SampleAdaptor.launch
  2. If you get the error "Project configuration is not up-to-date with pom.xml", simply right click on the eclipse project and select Maven-->Update Project....

Setup an OSLC4J project

Note: This information is based on the tutorial from The MBAT Tutorial on Implementing OSLC Consumers and Providers with OSLC4J - By Stefan Paschke ViF.

The steps below guide you through the necessary steps of creating an Eclipse project with the necessary configurations to develop any OSLC4J adaptor.

In the instructions below, we assume an eclipse project named SampleAdaptor, where the java classes are managed under the base package named your.basepackage.name.

  1. Create a JAVA EE Web Application
    1. File-->New-->Project...
    2. Select Web/Dynamic Web Project
    3. As project name, specify SampleAdaptor
    4. On the final step of the wizard, check the Generate web.xml... option
    5. Select Finish
  2. Convert project to Maven
    1. Right click on the project, and select Configure --> Convert to Maven Project
    2. In the window that appears, select war under Packaging
  3. Configure the project
    1. Create a folder test at the root of the project
    2. Create the sub-folders launches & resources under the new folder test
    3. Copy the 3 configuration files from the Configuration File Templates into the corresponding folders:
      1. /SampleAdaptor/pom.xml
      2. /SampleAdaptor/src/main/webapp/WEB-INF/web.xml
      3. /SampleAdaptor/src/main/webapp/WEB-INF/jetty.xml
      4. If necessary, refresh your Eclipse workspace by right clicking on SampleAdaptor -> Refresh
    4. If you choose a different name for your project and/or java package, search and replace these values in the project files as instructed under the Sample Project above.
  4. Activate Project Facet JAX-RS
    1. Right click the project & Select properties
    2. Select the Project Facets window
    3. Select JAX-RS (REST Web Services)
    4. Click OK to commit the changes.
    5. Right click again on the project & Select properties
    6. select the new JAX-RS sub-window under Project Facets
    7. Set Type: to Disable Library Configuration
    8. Enter JAX-RS servlet class name: org.apache.wink.server.internal.servlet.RestServlet
    9. Under URL mapping patterns:
      1. Remove the existing pattern
      2. Add a new pattern /services/*
      • Note: the above two steps (8 and 9) are no longer available in the Eclipse Mars 4.5 Java EE dialog for the JAX-RS facet. The web.xml file can, of course, be manually edited to make the indicated changes.
    10. Click OK to commit the changes.
  5. Further project configuration
    1. right click the project & select Properties
    2. select Deployment Assembly
    3. Add...
    4. In the new window that appears
      1. select Java Build Path Entries
      2. click Next >
      3. select Maven Dependencies
      4. click Finish
      5. click Apply
      6. click OK
  6. Create a new Run configuration
    1. Select the menu Run-->Run Configurations...
    2. Select Maven Build
    3. Create a new Configuration (Right click on Maven Build -> New)
    4. Enter a name for the new configuration (such as "Launch SampleAdaptor")
    5. Set the Base directory to ${workspace_loc:/SampleAdaptor}
    6. Set Goal as jetty:run-exploded
    7. Switch to tab JRE
      1. Set Runtime JRE to Workspace default JRE...
    8. Switch to tab Source
      1. Click Add...
      2. In the new window, select Project and click OK
        1. Check the SampleAdaptor project
        2. Check the add required projects of selected projects option
        3. Click OK
    9. Switch to Tab Common
      1. Select Shared file
      2. Click Browse...
      3. In the window that appears, select the recently created folder test/launches under the SampleAdaptor project
      4. click OK
    10. Click Apply
    11. Clock Close

Back to the top