1
votes

I ran into a strange problem..
I work on a project that use the ProcessBuilder Class.
On my local machine (Java6 and Java7 tested) I can easily mvn clean install & mvn assembly:single the project without any errors. Now I want to let the project build by travis-ci and ran into to following error

error: no suitable constructor found for ProcessBuilder(String)

full log file here.. but the Javadoc for ProcessBuilder show me that constructor.
My .travis.yml looks like this

language: java

jdk:
- oraclejdk7
- openjdk6
- openjdk7

after_success:
- mvn assembly:single

Any ideas why the build fails on travis-ci?

Thanks, F481

Edit:
Locally I'm using Maven 3, like travis-ci too (travis doc: "Travis Java builder will use Maven 3 to build it.") My pom.xml: https://github.com/MultiServerControl/MineControl/blob/master/pom.xml
And the java code of the first error: this.processBuilder = new ProcessBuilder("");
The full class is available here

Edit2: I specified a source and target version for the maven compilation like this:

<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.0</version>
      <configuration>
          <source>1.7</source>
          <target>1.7</target>
      </configuration>
</plugin>

Now the build is working for JDK7: https://travis-ci.org/MultiServerControl/MineControl/jobs/5963859

But I don't get the reason for that behavior.. and I want to build the project for JDK 5,6 too.
How can I do that?

1
Probably it is openjdk compiler bug. And it cannot apply String to "public ProcessBuilder(String... command)" constructor.. - Taky
Hm.. if so, why the oracle jdk build fails too on travis-ci? :P - F481
Very strange indeed. It seems to be related to varargs, since you also have other compilation failures in the same class (calling the command method). I'd suppose it would be resolved by excplicit calling the methods with String[] instead, but it wouldn't solve the mystery... Does other vararg invocations work? The first thing that came to mind was that it must have something to do with source or target versions used with javac, but I'm not sure how that would happen. - NilsH
You get the same error if you specify source and target 1.5? - NilsH
Strange... Maybe it was picking up the wrong version of the maven compiler plugin for some reason. But great that you have it working now :) - NilsH

1 Answers

0
votes

I specified the version of the maven compiler plugin and the source and target version for the compilation like this:

<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.0</version>
      <configuration>
          <source>1.5</source>
          <target>1.5</target>
      </configuration>
</plugin>

Now the build is working! Much thanks to NilsH who pushed me in the right direction.