I am having a problem when trying to compile a Maven project from inside Eclipse Mars (4.5.1).
Specs:
- Win 7 SP1 x64
- JDK x64 1.8.0_72
- Eclipse x64 4.5.1
- Maven 3.3.9
I believe this to be an Eclipse-Maven plugin interaction problem, as I am able to execute goals from the terminal such as:
mvn clean compile
mvn generate-sources
mvn install
In Eclipse, when I right-click on the project name and chose Maven install as the goal to execute, I get the following errors:
Scanning for projects
...
Building project-name-1.0-SNAPSHOT ...
[WARNING] The POM for com.sun.xml.ws:jaxws-rt:jar:2.2.10 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] --- jaxws-maven-plugin:2.3:wsimport (default) @ project-name
[WARNING] The POM for com.sun.xml.ws:jaxws-tools:jar:2.2.10 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] Processing: file:/C:/project-name/src/main/resources/file.wsdl [INFO] jaxws:wsimport args: [-keep, -s, C:\project-name\target\generated-sources\wsimport, -d, C:\project-name\target\classes, -encoding, UTF-8, -Xnocompile, "file:/C:/project-name/src/main/resources/file.wsdl"]
[WARNING] Failed to build parent project for com.sun.xml.ws:bundles:pom:2.2.10
[WARNING] Failed to build parent project for com.sun.xml.ws:jaxws-tools:pom:2.2.10
[WARNING] Invalid POM for com.sun.xml.ws:jaxws-tools:jar:2.2.10, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] BUILD FAILURE
...
[ERROR] Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport (default) on project project-name: Execution default of goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport failed: String index out of range: -1 -> [Help 1]
[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/PluginExecutionException
However, if I execute mvn install from the terminal, the goal is successful!
I think I have all the necessary Maven plugins installed in Eclipse and the pom.xml file is correct, as via the terminal everything seems to work.
Hoping that someone will be able to hint into this problem.
EDIT: while mvn install fails in Eclipse, if I create a Maven Build configuration in Eclipse with goal mvn install -e, the problem does not happen. Passing this flag is somehow solving this problem.
EDIT: I paste the specific pom.xml section which triggers the problem in Eclipse (bold text is what Eclipse underlines in red):
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- http://maven.apache.org/pom.html#Quick_Overview -->
<groupId>group.name</groupId>
<artifactId>project-name</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<wsdl.directory>${basedir}/../project-dep/src/main/resources</wsdl.directory>
<wsdl.filename>file.wsdl</wsdl.filename>
<mainclass>group.name.subname.TestApplication</mainclass>
<ws.url>http://localhost:8081/sample-ws/endpoint</ws.url>
<ws.name>Sample</ws.name>
<uddi.url>http://localhost:9090</uddi.url>
</properties>
<dependencies>
<!-- JAX-WS -->
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.10</version>
</dependency>
<!-- UDDI -->
<dependency>
<groupId>group.name.uddi</groupId>
<artifactId>uddi-naming</artifactId>
<version>1.0</version>
</dependency>
<!-- SOAP Handlers -->
<dependency>
<groupId>group.name.soap</groupId>
<artifactId>ws-handlers</artifactId>
<version>1.0</version>
</dependency>
<!-- JMockit - must appear before JUnit -->
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.21</version>
<scope>test</scope>
</dependency>
<!-- JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- https://jax-ws-commons.java.net/jaxws-maven-plugin/wsimport-mojo.html -->
<wsdlDirectory>${wsdl.directory}</wsdlDirectory>
<wsdlFiles>
<wsdlFile>${wsdl.filename}</wsdlFile>
</wsdlFiles>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.2.10</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- to prevent deprecation warning: -->
<killAfter>-1</killAfter>
<mainClass>${mainclass}</mainClass>
<arguments>
<argument>${ws.url}</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
<configuration>
<programs>
<program>
<mainClass>${mainclass}</mainClass>
<id>${project.artifactId}</id>
</program>
</programs>
</configuration>
</plugin>
</plugins>
</build>
</project>
This is my Maven installation inside Eclipse:
