exec-maven-plugin exec:java failing: Cannot assign configuration values to array of type java.lang.String

13,276

Solution 1

I would suggest to remove the empty entries from your configuration and try it again.

 <argument>-classpath</argument>
 <classpath/>

Cause in java goal the classpath is not allowed based on the documentation.

BTW: Never use "\" in your maven pom. Use forward slashes instead.

Solution 2

According to exec:java Docs here, you have to :

Remove <arguments> part

And use <additionalClasspathElements> declarations to define a classpath.

Solution 3

If you want to use <classpath/>, you have to use exec:exec and not exec:java. You also have to add the executable, which is java in your case:

<executable>java</executable>

If I understand it correctly, exec:java automatically adds the classpath you cannot override it. The arguments are added after the main class. exec:exec is more generic, it executes any executable with any arguments, one of which can be the <classpath/>.

Share:
13,276

Related videos on Youtube

David Camilleri
Author by

David Camilleri

Updated on June 29, 2022

Comments

  • David Camilleri
    David Camilleri almost 2 years

    When executing mvn exec:java it fails to correctly parse the configuration arguments, throwing the following error:

    [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project autotest-programmes: Unable to parse configuration of mojo org.codehaus.mojo:exec-maven-plugin:1.2.1:java: Cannot assign configuration values to array of type java.lang.String: [-classpath, Classpath {}, --glue, com.company.test.cucumber, --format, pretty, --format, html:C:\workspace\autotest\target] -> [Help 1]

    This is the plugin configuration used (using Apache Maven 3.0.3):

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
            <execution>
                <goals>
                    <goal>java</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <includeProjectDependencies>false</includeProjectDependencies>
            <includePluginDependencies>true</includePluginDependencies>
            <executableDependency>
                <groupId>info.cukes</groupId>
                <artifactId>cucumber-core</artifactId>
            </executableDependency>
            <mainClass>cucumber.cli.Main</mainClass>
            <commandlineArgs>-Dfile.encoding=UTF-8</commandlineArgs>
            <arguments>
                <argument>-classpath</argument>
                <classpath/>
                <argument>--glue</argument>
                <argument>com.company.test.cucumber</argument>
                <argument>--format</argument>
                <argument>pretty</argument>
                <argument>--format</argument>
                <argument>html:${project.basedir}\target</argument>
            </arguments>
        </configuration>
        <dependencies>
            <dependency>
                <groupId>info.cukes</groupId>
                <artifactId>cucumber-core</artifactId>
                <version>1.0.2</version>
            </dependency>
        </dependencies>
    </plugin>
    
  • David Camilleri
    David Camilleri about 12 years
    I removed the empty entries and changed the "\" to "/". It moved on from the previous error, however it's now complaining that it cannot find the mainClass. [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project autotest-programmes: An exception occured while executing the Java class. cucumber.cli.Main -> [Help 1]
  • Chris
    Chris almost 11 years
    to what empty entries are you referring? <classpath/>?