Announcement Announcement Module
Collapse
No announcement yet.
STS tutorial quirk in Creating a Spring-powered OSGi bundle Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • STS tutorial quirk in Creating a Spring-powered OSGi bundle

    Hi
    I can't run the simple junit testcase that comes with the example.
    I've finished setting up the workspace and defined the module context.
    Now I'd like to simply dry run the junit test case as suggested in the text under 'writing and launching the unit test'. However when I use the 'run as' or the 'run' button in the toolbar JUnit is not presented to me as an option. I've tried to create my own JUnit configuration for it under Run Configurations -> JUnit
    Here it doesn't allow me to choose the 'Spring powered bundle' as Project (most likely because it is not associated with the Eclipse 'java nature'). I've then changed the project nature to java in .project which in turn messes up the whole STS setup..
    At this point I'm asking for assistance. This is probably something that others must have found before me, however I searched the forum/google and couldn't find anything...
    Please provide a pointer or suggestion how to fix this.
    Cheers,
    Robert

    I'm using Eclipse 3.5 with STS 2.3.2 on Linux (Fedora 12)

  • #2
    Fix

    Hi
    I've just finished fixing this myself. These are the necessary steps:
    After unpacking the Spring Powered Bundle (Step: "Workspace Setup" in the tutorial)
    1. Assign Spring Project Nature to it:
    Right click on the Project in Package Explorer -> Spring Tools -> Add Spring Project Nature
    2. Transform it into a Plugins Project:
    Right click on the Project in Package Explorer -> Configure -> Convert to Plugins Project
    these steps add the necessary lines to the project home .project file
    3. Now we need to add the Java Nature to the Project. This can't be done through the UI
    as several users have already described earlier, e.g.
    http://enarion.net/programming/tools...-java-project/
    Shutdown eclipse and manually add Java Nature to the .project file:
    under <buildspec> add
    <buildCommand>
    <name>org.eclipse.jdt.core.javabuilder</name>
    <arguments>
    </arguments>
    </buildCommand>

    and unter <natures>
    <nature>org.eclipse.jdt.core.javanature</nature>

    4. Next we need to update the project's classpath. I've simply done it inside the .classpath file, also located by default on the project's home directory.
    Modify the .classpath to contain
    xml version="1.0" encoding="UTF-8"?>
    <classpath>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.Standar dVMType/J2SE-1.5"/>
    <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
    <classpathentry kind="src" path="src/main/java"/>
    <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
    <classpathentry kind="src" output="target/integration-test-classes" path="src/integration-test/java"/>
    <classpathentry kind="src" path="src/main/resources"/>
    <classpathentry kind="src" path="src/test/resources"/>
    <classpathentry kind="src" path="src/integration-test/resources"/>
    <classpathentry kind="lib" path="lib/commons-logging.jar"/>
    <classpathentry kind="lib" path="lib/junit-4.4.jar"/>
    <classpathentry kind="lib" path="lib/spring-test.jar"/>
    <classpathentry kind="lib" path="lib/spring.jar"/>
    <classpathentry kind="output" path="target/classes"/>
    </classpath>

    5. Finally in the project root dir create a directory called .settings
    in it create two files
    File 1: Name: org.eclipse.jdt.core.prefs
    Content:
    #Wed Mar 12 12:11:15 GMT 2008
    eclipse.preferences.version=1
    org.eclipse.jdt.core.compiler.codegen.targetPlatfo rm=1.5
    org.eclipse.jdt.core.compiler.compliance=1.5
    org.eclipse.jdt.core.compiler.problem.assertIdenti fier=error
    org.eclipse.jdt.core.compiler.problem.enumIdentifi er=error
    org.eclipse.jdt.core.compiler.source=1.5

    File 2: Name: org.eclipse.pde.core.prefs
    Content:
    #Wed Mar 12 12:11:15 GMT 2008
    eclipse.preferences.version=1
    pluginProject.extensions=false
    resolve.requirebundle=false

    As far as I understand these are very basic Eclipse UI settings. I wonder why these have been missing in this sample. With these modifications it is now possible to start Eclipse and execute the JUnit tests as described in the tutorial.
    Good luck!
    Cheers,
    Robert

    Comment


    • #3
      Thank you for taking the time to post this fix.
      I wonder why these have been missing in this sample.
      I assume this is because the developer has overlooked these project files when they packaged the tutorial. This is not the only tutorial with quirky behavior and I suspect the problems of a similar nature.

      Comment

      Working...
      X