Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-dev] java.lang.ClassCastException: TargetPlatformBuilderImpl cannot be cast to P2TargetPlatform

are you explicitly invoking a mojo goal on the commandline, such as

mvn org.eclipse.tycho.extras:tycho-version-bump-plugin:update-product

?

explicit mojo goals without version resolve to the latest *released* version, i.e. 0.14.0.

Now if you invoke this on a pom.xml which registers the tycho build extension in another version, e.g.

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-maven-plugin</artifactId>
        <version>0.15.0-SNAPSHOT</version>
        <extensions>true</extensions>
      </plugin>

this will lead to class loading conflicts as the build extension artifacts (which are also used by the mojo above) are hooked into the maven classloader hierarchy at low level.

So make sure you use the same version consistently everywhere, e.g. by using 

mvn org.eclipse.tycho.extras:tycho-version-bump-plugin:0.15.0-SNAPSHOT:update-product

HTH
Jan

From: tycho-dev-bounces@xxxxxxxxxxx [mailto:tycho-dev-bounces@xxxxxxxxxxx] On Behalf Of Mickael Istria
Sent: Dienstag, 22. Mai 2012 16:15
To: tycho-dev@xxxxxxxxxxx
Subject: [tycho-dev] java.lang.ClassCastException: TargetPlatformBuilderImpl cannot be cast to P2TargetPlatform

Hello,

I am trying to write the plugin requested here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=378987 to validate .target files.
I started by imitating what is done on tycho-version-bump-plugin to read and resolve target platforms:

==== CODE ====
 this.factory = this.equinox.getService(P2ResolverFactory.class);
 this.p2 = this.factory.createResolver(new MavenLoggerAdapter(this.logger, false));
 resolutionContext = this.factory.createTargetPlatformBuilder(null, false);
            
 TargetDefinitionFile target = TargetDefinitionFile.read(targetFile);
 resolutionContext.addTargetDefinition(target, this.environment);
 P2ResolutionResult result = this.p2.resolveMetadata(resolutionContext, this.environment.get(0));
==== END CODE ====

but this return me the following:
==== OUTPUT EXCEPTION ====
java.lang.ClassCastException: org.eclipse.tycho.p2.target.TargetPlatformBuilderImpl cannot be cast to org.eclipse.tycho.artifacts.p2.P2TargetPlatform
    at org.eclipse.tycho.p2.impl.resolver.P2ResolverImpl.resolveMetadata(P2ResolverImpl.java:92)
    at org.eclipse.tycho.extras.tpvalidator.TPValidationMojo.validateTarget(TPValidationMojo.java:117)
==== END OUTPUT ====

By looking at code, there is indeed a cast from TargetPlatformBuilder to P2TargetPlatform, but I don't understand how it is supposed to work. Could you please provide me some insight about this issue?
-- 
Mickael Istria
Eclipse developer at JBoss, by Red Hat
My blog - My Tweets


Back to the top