Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.String cannot be cast to org.codehaus.mojo.exec.Modulepath #75

Closed
ttelford opened this issue Mar 8, 2017 · 20 comments
Closed
Labels
Milestone

Comments

@ttelford
Copy link

ttelford commented Mar 8, 2017

I had some pomfiles which didn't specify a version for exec-maven-plugin. (Ignoring warnings at my own peril!)

When the new version became available in Maven Central, I started seeing errors along the lines of:

A type incompatibility occured while executing org.codehaus.mojo:exec-maven-plugin:1.6.0:exec: java.lang.String cannot be cast to org.codehaus.mojo.exec.Modulepath
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.codehaus.mojo:exec-maven-plugin:1.6.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0]  = file:/home/user/.m2/repository/org/codehaus/mojo/exec-maven-plugin/1.6.0/exec-maven-plugin-1.6.0.jar
[ERROR] urls[1]  = file:/home/user/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
[ERROR] urls[2]  = file:/home/user/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[3]  = file:/home/user/.m2/repository/org/slf4j/slf4j-jdk14/1.5.6/slf4j-jdk14-1.5.6.jar
[ERROR] urls[4]  = file:/home/user/.m2/repository/org/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.jar
[ERROR] urls[5]  = file:/home/user/.m2/repository/org/slf4j/jcl-over-slf4j/1.5.6/jcl-over-slf4j-1.5.6.jar
[ERROR] urls[6]  = file:/home/user/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.2.1/maven-reporting-api-2.2.1.jar
[ERROR] urls[7]  = file:/home/user/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.1/doxia-sink-api-1.1.jar
[ERROR] urls[8]  = file:/home/user/.m2/repository/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
[ERROR] urls[9]  = file:/home/user/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar
[ERROR] urls[10] = file:/home/user/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
[ERROR] urls[11] = file:/home/user/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[12] = file:/home/user/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[13] = file:/home/user/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.20/plexus-utils-3.0.20.jar
[ERROR] urls[14] = file:/home/user/.m2/repository/org/apache/commons/commons-exec/1.3/commons-exec-1.3.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

There isn't any stack dump

I'm using Maven 3.2.5 and JDK 1.7.0_71, which are both older.

Obviously, I can fix the problem by going to the previous version of the plugin (1.5.0).

Is this an actual issue, or am I simply using a toolstack that's "too old"?

@markus-s24
Copy link

Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to org.codehaus.mojo.exec.Modulepath
at org.codehaus.mojo.exec.ExecMojo.handleArguments(ExecMojo.java:483)
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:271)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more

@markus-s24
Copy link

markus-s24 commented Apr 5, 2017

It seems to be related to the "-p" in the arguments of the configuration:

<configuration>
   <executable>redis-cli</executable>
   <arguments>
      <argument>-p</argument>
      <argument>${integrationTest.redisPort}</argument>
      <argument>shutdown</argument>
   </arguments>
</configuration>

This configuration worked fine with the 1.5.0 version of the plugin.

@earcam
Copy link

earcam commented Apr 20, 2017

I'm getting similar with 9-ea+165 on OSX, when using maven-exec-plugin:1.6.0 to run a simple java jigsaw multi-module.

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (default) on project io.earcam.example.javanine.jmod.consumer: A type incompatibility occurred while executing org.codehaus.mojo:exec-maven-plugin:1.6.0:exec: java.base/java.lang.String cannot be cast to org.codehaus.mojo.exec.Modulepath

This doesn't happen with maven-exec-plugin:1.5.0.

@bguerin
Copy link

bguerin commented May 3, 2017

Same here

I think the bug has been introduced in 093153b

Line 477 of ExecMojo.java should be

else if ( argument instanceof Modulepath && isLongModulePathArgument( (String) argument ) )

instead of

if ( argument instanceof String && isLongModulePathArgument( (String) argument ) )

@jpopadak
Copy link

jpopadak commented Jun 6, 2017

I get the same issue on my end.
We send a few different properties:

<argument>-p</argument>
<argument>
   ${project.basedir}/src/main/resources/config/svc-${service}-client-java.properties
</argument>
<argument>-r</argument>
<argument>${request}</argument>
<argument>-e</argument>
<argument>${envName}</argument>

Here is a more full stack trace:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (default) on project svc-client-java: A type incompatibility occurred while executing org.codehaus.mojo:exec-maven-plugin:1.6.0:exec: java.lang.String cannot be cast to org.codehaus.mojo.exec.Modulepath
-----------------------------------------------------
realm =    plugin>org.codehaus.mojo:exec-maven-plugin:1.6.0
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/Users/jamespopadak/.m2/repository/org/codehaus/mojo/exec-maven-plugin/1.6.0/exec-maven-plugin-1.6.0.jar
urls[1] = file:/Users/jamespopadak/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
urls[2] = file:/Users/jamespopadak/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
urls[3] = file:/Users/jamespopadak/.m2/repository/org/slf4j/slf4j-jdk14/1.5.6/slf4j-jdk14-1.5.6.jar
urls[4] = file:/Users/jamespopadak/.m2/repository/org/slf4j/jcl-over-slf4j/1.5.6/jcl-over-slf4j-1.5.6.jar
urls[5] = file:/Users/jamespopadak/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.2.1/maven-reporting-api-2.2.1.jar
urls[6] = file:/Users/jamespopadak/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.1/doxia-sink-api-1.1.jar
urls[7] = file:/Users/jamespopadak/.m2/repository/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
urls[8] = file:/Users/jamespopadak/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar
urls[9] = file:/Users/jamespopadak/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
urls[10] = file:/Users/jamespopadak/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
urls[11] = file:/Users/jamespopadak/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
urls[12] = file:/Users/jamespopadak/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.20/plexus-utils-3.0.20.jar
urls[13] = file:/Users/jamespopadak/.m2/repository/org/apache/commons/commons-exec/1.3/commons-exec-1.3.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: A type incompatibility occurred while executing org.codehaus.mojo:exec-maven-plugin:1.6.0:exec: java.lang.String cannot be cast to org.codehaus.mojo.exec.Modulepath
-----------------------------------------------------
realm =    plugin>org.codehaus.mojo:exec-maven-plugin:1.6.0
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/Users/jamespopadak/.m2/repository/org/codehaus/mojo/exec-maven-plugin/1.6.0/exec-maven-plugin-1.6.0.jar
urls[1] = file:/Users/jamespopadak/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
urls[2] = file:/Users/jamespopadak/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
urls[3] = file:/Users/jamespopadak/.m2/repository/org/slf4j/slf4j-jdk14/1.5.6/slf4j-jdk14-1.5.6.jar
urls[4] = file:/Users/jamespopadak/.m2/repository/org/slf4j/jcl-over-slf4j/1.5.6/jcl-over-slf4j-1.5.6.jar
urls[5] = file:/Users/jamespopadak/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.2.1/maven-reporting-api-2.2.1.jar
urls[6] = file:/Users/jamespopadak/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.1/doxia-sink-api-1.1.jar
urls[7] = file:/Users/jamespopadak/.m2/repository/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
urls[8] = file:/Users/jamespopadak/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar
urls[9] = file:/Users/jamespopadak/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
urls[10] = file:/Users/jamespopadak/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
urls[11] = file:/Users/jamespopadak/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
urls[12] = file:/Users/jamespopadak/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.20/plexus-utils-3.0.20.jar
urls[13] = file:/Users/jamespopadak/.m2/repository/org/apache/commons/commons-exec/1.3/commons-exec-1.3.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:196)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 20 more
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to org.codehaus.mojo.exec.Modulepath
    at org.codehaus.mojo.exec.ExecMojo.handleArguments(ExecMojo.java:483)
    at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:271)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    ... 21 more

@Sovietaced
Copy link

+1

@ctubbsii
Copy link

Same problem here with Maven 3.3.9 and OpenJDK 1.8

Apache Maven 3.3.9 (NON-CANONICAL_2016-07-01T11:53:38Z_mockbuild; 2016-07-01T07:53:38-04:00)
Maven home: /usr/share/maven
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-1.b12.fc25.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.11.3-202.fc25.x86_64", arch: "amd64", family: "unix"

This issue prevents me from upgrading to 1.6.0 version of this plugin.

@martinreck
Copy link

martinreck commented Jun 15, 2017

A similar error may occurs when an executable expects a -cp argument and property longClasspath is true.

See line 465 of ExecMojo.java.

@fgaule
Copy link

fgaule commented Aug 14, 2017

+1

@nipafx
Copy link

nipafx commented Oct 6, 2017

Short term fix is to set <longModulepath>false</longModulepath>.

@aaccioly
Copy link

aaccioly commented Dec 11, 2017

Hi @martinreck, is your commit in #80 meant to fix #75? If so, do you have a estimate date for release 1.6.1?

@ctubbsii
Copy link

I saw this same issue with Maven 3.5.0 and Java 1.7.

gunnarmorling added a commit to gunnarmorling/exec-maven-plugin that referenced this issue Mar 17, 2018
@gunnarmorling
Copy link

Sent a PR to fix it here: #100. Tried that with a project of mine and all looked good. Would be cool if people here did the same and reported back if there are any issues with the fix.

@ghost
Copy link

ghost commented Jun 5, 2018

+1

@blling
Copy link

blling commented Jun 10, 2018

+1

3 similar comments
@malikoski
Copy link

+1

@jackson-chris
Copy link

+1

@keltik85
Copy link

+1

@keltik85
Copy link

keltik85 commented Oct 11, 2018

<plugin><configuration><longModulepath>false</longModulepath>... fixed it for me as a workaround.

@ctubbsii
Copy link

@keltik85 said:

Short term fix is to set <longModulepath>false</longModulepath> into <plugin><configuration> fixed it for me as a workaround.

I think that will work for the case I stated in #100 (comment) , although it's kind of annoying to have to set a module-related config item when the bug is manifesting itself in a way that has nothing to do with modules at all, but just some arbitrary parameter with the same -p name on a different executable.

I don't think that it's going to be a short-term fix, though. Given the slowness to address this bug, it's probably going to be a long-term fix. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests