Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 362998

Summary: compile error on Galileo due to missing org.junit4 dependency
Product: z_Archived Reporter: Steffen Pingel <steffen.pingel>
Component: MylynAssignee: Steffen Pingel <steffen.pingel>
Status: RESOLVED FIXED QA Contact: David Green <greensopinion>
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: 3.7   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Steffen Pingel CLA 2011-11-06 11:45:06 EST
http://ci.mylyn.org/job/mylyn-3.7.x/TARGET=galileo/28/console

[INFO] o.h.m.e.h.MavenExecutionResultHandler - Build failed with exception(s)
[INFO] o.h.m.e.h.MavenExecutionResultHandler - [1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.13.0:compile (default-compile) on project org.eclipse.mylyn.wikitext.tests: Compilation failure
[DEBUG] Closing connection to remote
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.13.0:compile (default-compile) on project org.eclipse.mylyn.wikitext.tests: Compilation failure: Compilation failure:
[ERROR] /home/hudson/.hudson/jobs/mylyn-3.7.x/workspace/TARGET/galileo/org.eclipse.mylyn.docs/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/core/MarkupFilesTest.java (at line 38):[-1,-1]
[ERROR] import org.junit.Assert;
[ERROR] ^^^^^^^^^
[ERROR] The import org.junit cannot be resolved
[ERROR] 
[ERROR] /home/hudson/.hudson/jobs/mylyn-3.7.x/workspace/TARGET/galileo/org.eclipse.mylyn.docs/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/core/MarkupFilesTest.java (at line 134):[-1,-1]
[ERROR] Assert.assertTrue(html.contains(expectedContent));
[ERROR] ^^^^^^
[ERROR] Assert cannot be resolved
Comment 1 David Green CLA 2011-11-07 14:22:02 EST
Thanks for the bug Steffen.  Would it make sense to change the JUnit dependency to this: @org.junit;bundle-version="[3.8.2,4.0.0)"@
The down-side of changing the dependency version constraint is that running unit tests from the Ecilpse UI results in an error, since JUnit4 is automatically selected in the launch configuration.  Changing it to JUnit3 works - but it's a pain to have to do that.
Comment 2 Steffen Pingel CLA 2011-11-07 15:07:58 EST
Yes, that works. Alternatively you can limit the use of JUnit classes to JUnit 3 or add a dependency on org.junit4. We have done the latter for bundles in the Mylyn Reviews project to make JUnit 4 APIs available.
Comment 3 David Green CLA 2011-11-07 15:44:34 EST
added dependency to org.junit4
Comment 4 Steffen Pingel CLA 2011-11-08 12:41:47 EST
The change has caused a slightly different error. We may need to change the way integration tests are handled to address this. 

pre.. 
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.eclipse.mylyn.tests.AllTests
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.011 sec <<< FAILURE!
initializationError(org.eclipse.mylyn.tests.AllTests)  Time elapsed: 0.002 sec  <<< ERROR!
java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) previously initiated loading for a different type with name "junit/framework/Test"
	at org.eclipse.mylyn.tests.AllNonConnectorTests.addTests(AllNonConnectorTests.java:58)
	at org.eclipse.mylyn.tests.AllTests.suite(AllTests.java:26)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.internal.runners.SuiteMethod.testFromSuiteMethod(SuiteMethod.java:34)
	at org.junit.internal.runners.SuiteMethod.<init>(SuiteMethod.java:23)
	at org.junit.internal.builders.SuiteMethodBuilder.runnerForClass(SuiteMethodBuilder.java:14)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
	at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
	at org.apache.maven.surefire.junit4.JUnit4TestSet.<init>(JUnit4TestSet.java:45)
	at org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet(JUnit4DirectoryTestSuite.java:56)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:96)
	at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:209)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:156)
	at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:72)
	at org.eclipse.tycho.surefire.osgibooter.AbstractUITestApplication$1.run(AbstractUITestApplication.java:35)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3468)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3115)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.tycho.surefire.osgibooter.UITestApplication.runApplication(UITestApplication.java:31)
	at org.eclipse.tycho.surefire.osgibooter.AbstractUITestApplication.run(AbstractUITestApplication.java:114)
	at org.eclipse.tycho.surefire.osgibooter.UITestApplication.start(UITestApplication.java:37)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Comment 5 David Green CLA 2011-11-08 13:01:48 EST
I've temporarily reverted the bundle constraint to the following: @org.junit;bundle-version="3.8.2"@

Steffen is there an easy way for me to test this change on Galileo - how do you run the build?
Comment 6 Steffen Pingel CLA 2011-11-08 14:19:28 EST
Do you know what is causing the error? 

You can run integration tests like this from the top-level integration repository: mvn -Pgalileo clean verify -Dmaven.test.skip=true -Dmaven.test.error.ignore=true -Dmaven.test.failure.ignore=true -Dpack.skip=true -Dexplicit-target=true -Dtest.all.skip=false
Comment 7 David Green CLA 2011-11-08 15:04:53 EST
That error looks very hard to diagnose - possibly a ClassLoader problem with multiple JUnit jars on the classpath?

(In reply to comment #6)
> You can run integration tests like this from the top-level integration
> repository: mvn -Pgalileo clean verify -Dmaven.test.skip=true
> -Dmaven.test.error.ignore=true -Dmaven.test.failure.ignore=true -Dpack.skip=true
> -Dexplicit-target=true -Dtest.all.skip=false

This didn't work for me locally:

pre. 
[INFO] Resolving target platform for project MavenProject: org.eclipse.mylyn:org.eclipse.mylyn.discovery:2.0.0.v20110321
-0000 @ C:\dev-git\org.eclipse.mylyn\org.eclipse.mylyn.discovery-directory\pom.xml
[INFO] Cannot complete the request.  Generating details.
[INFO] Cannot complete the request.  Generating details.
[INFO] {org.osgi.framework.executionenvironment=OSGi/Minimum-1.0,OSGi/Minimum-1.1, osgi.ws=cocoa, osgi.arch=x86, osgi.os
=macosx, org.eclipse.update.install.features=true, org.osgi.framework.system.packages=}
[ERROR] Cannot resolve project dependencies:
[ERROR]   Software being installed: org.eclipse.mylyn.discovery 2.0.0.v20110321-0000
[ERROR]   Missing requirement: org.eclipse.mylyn.discovery 2.0.0.v20110321-0000 requires 'bundle org.eclipse.mylyn.disco
very.core 1.0.0' but it could not be found
[ERROR]
[ERROR] Internal error: java.lang.RuntimeException: "No solution found because the problem is unsatisfiable.": ["Unable
to satisfy dependency from org.eclipse.mylyn.discovery 2.0.0.v20110321-0000 to bundle org.eclipse.mylyn.discovery.core 1
.0.0.", "No solution found because the problem is unsatisfiable."] -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: "No solution found because the prob
lem is unsatisfiable.": ["Unable to satisfy dependency from org.eclipse.mylyn.discovery 2.0.0.v20110321-0000 to bundle o
rg.eclipse.mylyn.discovery.core 1.0.0.", "No solution found because the problem is unsatisfiable."]
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.RuntimeException: "No solution found because the problem is unsatisfiable.": ["Unable to satisfy de
pendency from org.eclipse.mylyn.discovery 2.0.0.v20110321-0000 to bundle org.eclipse.mylyn.discovery.core 1.0.0.", "No s
olution found because the problem is unsatisfiable."]
        at org.eclipse.tycho.p2.impl.resolver.ProjectorResolutionStrategy.resolve(ProjectorResolutionStrategy.java:106)
        at org.eclipse.tycho.p2.impl.resolver.P2ResolverImpl.resolveProject(P2ResolverImpl.java:102)
        at org.eclipse.tycho.p2.impl.resolver.P2ResolverImpl.resolveProject(P2ResolverImpl.java:69)
        at org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.doResolvePlatform(P2TargetPlatformResolver.java:342)
        at org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.resolvePlatform(P2TargetPlatformResolver.java:162)
        at org.eclipse.tycho.core.resolver.DefaultTychoDependencyResolver.resolveProject(DefaultTychoDependencyResolver.
java:85)
        at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.
java:91)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:273)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        ... 11 more

Is there a hosted build that we can easily trigger? https://hudson.eclipse.org/hudson/job/mylyn-integration-e3.5/ ?
Comment 8 Steffen Pingel CLA 2011-11-08 15:27:11 EST
Did you run it from this repository? http://git.eclipse.org/c/mylyn/org.eclipse.mylyn.all.git

Triggering https://hudson.eclipse.org/hudson/job/mylyn-integration-e3.5/ wouldn't help since it runs against the integration repository which needs to be explicitly updated by a committer of the mylyn top-level project.

I'll try to take a look at this problem later next week. Let's not worry about it for now.

Another way to run tests is to install bundles into the local Maven cache and then run 'mvn -Pgalileo integration-test' in org.eclipse.mylyn/org.eclipse.mylyn.tests.
Comment 9 David Green CLA 2011-11-08 16:09:24 EST
(In reply to comment #8)
> Did you run it from this repository?
> http://git.eclipse.org/c/mylyn/org.eclipse.mylyn.all.git

No.  Cloning from that URL doesn't work - however I did clone what I think is the same repo over ssh.  Here's the result:

pre. $ mvn -Pgalileo clean verify -Dmaven.test.skip=true -Dmaven.test.error.ignore=true -Dmaven.test.failure.ignore=true -Dp
ack.skip=true -Dexplicit-target=true -Dtest.all.skip=false
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project org.eclipse.mylyn:org.eclipse.mylyn.all:3.7.0-SNAPSHOT (c:\dev-git\org.eclipse.mylyn.all\pom.xml)
has 8 errors
[ERROR]     Child module c:\dev-git\org.eclipse.mylyn.all\org.eclipse.mylyn\pom.xml of c:\dev-git\org.eclipse.mylyn.all\
pom.xml does not exist
[ERROR]     Child module c:\dev-git\org.eclipse.mylyn.all\org.eclipse.mylyn.commons\pom.xml of c:\dev-git\org.eclipse.my
lyn.all\pom.xml does not exist
[ERROR]     Child module c:\dev-git\org.eclipse.mylyn.all\org.eclipse.mylyn.versions\pom.xml of c:\dev-git\org.eclipse.m
ylyn.all\pom.xml does not exist
[ERROR]     Child module c:\dev-git\org.eclipse.mylyn.all\org.eclipse.mylyn.tasks\pom.xml of c:\dev-git\org.eclipse.myly
n.all\pom.xml does not exist
[ERROR]     Child module c:\dev-git\org.eclipse.mylyn.all\org.eclipse.mylyn.context\pom.xml of c:\dev-git\org.eclipse.my
lyn.all\pom.xml does not exist
[ERROR]     Child module c:\dev-git\org.eclipse.mylyn.all\org.eclipse.mylyn.builds\pom.xml of c:\dev-git\org.eclipse.myl
yn.all\pom.xml does not exist
[ERROR]     Child module c:\dev-git\org.eclipse.mylyn.all\org.eclipse.mylyn.docs\pom.xml of c:\dev-git\org.eclipse.mylyn
.all\pom.xml does not exist
[ERROR]     Child module c:\dev-git\org.eclipse.mylyn.all\org.eclipse.mylyn.reviews\pom.xml of c:\dev-git\org.eclipse.my
lyn.all\pom.xml does not exist

> I'll try to take a look at this problem later next week. Let's not worry about
> it for now.

Great, sounds good.
Comment 10 Steffen Pingel CLA 2011-11-09 01:46:56 EST
You would have to initialize and update the submodules first to run a build across all projects.

Regarding the LinkageError it seems that org.junit4 conflicts with the org.junit bundle. I assumed that org.junit4 re-exports packages from org.junit but that does not appear to be the case on Eclipse 3.5. This seems only have changed in Eclipse 3.6 or later. 

I am tempted to add org.junit 4.8 to the target definition and to mandate that all tests require org.junit 4.0 or later to make sure all bundles get wired to the same version. I'll send out an email to gather some input.
Comment 11 Steffen Pingel CLA 2011-11-09 07:55:43 EST
I added org.junit 4.8.2 to the 3.4 and 3.5 target. We'll use that bundle for running all tests now.