Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 370823 - Authentication to protected p2 repositories fails when using more than one <location>s in target file
Summary: Authentication to protected p2 repositories fails when using more than one <l...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Tobias Oberlies CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-07 08:36 EST by Mirko Swillus CLA
Modified: 2021-04-28 16:54 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mirko Swillus CLA 2012-02-07 08:36:51 EST
Build Identifier: Version: 0.14.0 STAGED

Tycho fails to resolve a target platform which defines more than one <location>s which are pointing to a basic http-auth protected p2 repository. Below a part of the example .target-file. The error message is "Authentication failed" (see complete stack trace at the end). When merging the different locations with its repository and units to one single location, the authentication works fine.  

<locations>
<location includeAllPlatforms="false" includeMode="slicer" includeSource="false" type="InstallableUnit">
<!-- some units here -->
<repository id="settings.xml-server-ID-one" location="https://secured-p2-repo-one:8443/"/>
</location>

<location includeAllPlatforms="false" includeMode="slicer" includeSource="false" type="InstallableUnit">
<!-- some units here -->
<repository id="settings.xml-server-ID-two" location="https://secured-p2-repo-two:8443/"/>
</location>
</locations>

A stack trace for this use case (not exactly for this readable example above):

[INFO] Scanning for projects...
[INFO] Resolving target platform for project MavenProject: com.test.rcp:commons:4.0.0.qualifier @ C:\Users\test\workspaces\commonsPluginTycho\Commons Plug-in\pom.xml
06.02.2012 15:26:30 org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
06.02.2012 15:26:30 org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: No credentials available for BASIC 'Sonatype Nexus Repository Manager'@repository.local:8443
06.02.2012 15:26:30 org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
06.02.2012 15:26:30 org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: No credentials available for BASIC 'Sonatype Nexus Repository Manager'@repository.local:8443
06.02.2012 15:26:30 org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
06.02.2012 15:26:30 org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: No credentials available for BASIC 'Sonatype Nexus Repository Manager'@repository.local:8443
06.02.2012 15:26:30 org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
06.02.2012 15:26:30 org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: No credentials available for BASIC 'Sonatype Nexus Repository Manager'@repository.local:8443
06.02.2012 15:26:30 org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
06.02.2012 15:26:30 org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: No credentials available for BASIC 'Sonatype Nexus Repository Manager'@repository.local:8443
06.02.2012 15:26:30 org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
06.02.2012 15:26:30 org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: No credentials available for BASIC 'Sonatype Nexus Repository Manager'@repository.local:8443
[ERROR] Internal error: java.lang.RuntimeException: Failed to resolve target definition C:\Users\test\workspaces\commonsPluginTycho\Commons Plug-in\indigo.target: Failed to load metadata repository from location https://repository.local:8443/nexus/content/repositories/test_snapshots/.meta/p2/: Authentication failed for https://repository.local:8443/nexus/content/repositories/test_snapshots/.meta/p2/. -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: Failed to resolve target definition C:\Users\test\workspaces\commonsPluginTycho\Commons Plug-in\indigo.target
    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: Failed to resolve target definition C:\Users\test\workspaces\commonsPluginTycho\Commons Plug-in\indigo.target
    at org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.doResolvePlatform(P2TargetPlatformResolver.java:336)
    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:274)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    ... 11 more
Caused by: org.eclipse.tycho.p2.target.facade.TargetDefinitionResolutionException: Failed to load metadata repository from location https://repository.local:8443/nexus/content/repositories/test_snapshots/.meta/p2/
    at org.eclipse.tycho.p2.target.TargetDefinitionResolver$LoadedLocation.loadRepository(TargetDefinitionResolver.java:287)
    at org.eclipse.tycho.p2.target.TargetDefinitionResolver$LoadedLocation.<init>(TargetDefinitionResolver.java:272)
    at org.eclipse.tycho.p2.target.TargetDefinitionResolver$IUResolver.addLocation(TargetDefinitionResolver.java:108)
    at org.eclipse.tycho.p2.target.TargetDefinitionResolver.resolveContent(TargetDefinitionResolver.java:82)
    at org.eclipse.tycho.p2.impl.resolver.ResolutionContextImpl.addTargetDefinition(ResolutionContextImpl.java:343)
    at org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.doResolvePlatform(P2TargetPlatformResolver.java:331)
    ... 16 more
Caused by: org.eclipse.equinox.p2.core.ProvisionException: Authentication failed for https://repository.local:8443/nexus/content/repositories/test_snapshots/.meta/p2/.
    at org.eclipse.equinox.internal.p2.repository.CacheManager.createCache(CacheManager.java:140)
    at org.eclipse.tycho.p2.impl.resolver.TychoP2RepositoryCacheManager.createCache(TychoP2RepositoryCacheManager.java:49)
    at org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory.getLocalFile(SimpleMetadataRepositoryFactory.java:66)
    at org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory.load(SimpleMetadataRepositoryFactory.java:88)
    at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.factoryLoad(MetadataRepositoryManager.java:57)
    at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:749)
    at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:651)
    at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:96)
    at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:92)
    at org.eclipse.tycho.p2.target.TargetDefinitionResolver$LoadedLocation.loadRepository(TargetDefinitionResolver.java:285)
    ... 21 more
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/InternalErrorException 
 



Reproducible: Always

Steps to Reproduce:
1.Define a .target with more than one locations, add http-auth basic protected p2-repositories with a ID pointing to a <server>-entry in the settings.xml file.
2.Build the bundle.
Comment 1 Tobias Oberlies CLA 2012-05-23 09:51:26 EDT
I have a refactoring/cleanup pending around authentication [1]. We should check if this problem still occurs once this is in.

[1] https://git.eclipse.org/r/#/c/6056/
Comment 2 Tobias Oberlies CLA 2012-06-14 08:37:56 EDT
I believe that this is fixed in 0.16.0-SNAPSHOT (with the refactoring mentioned above). I have successfully resolved a target file with two locations with different password-protected repositories, but I'm not sure I exactly reproduced your situation. Feel free to re-open if you still have this problem.