Error during maven "clean install" with plug-in resolve - maven

I try to to use clean install in Maven and get the error below. I have two questions:
Is this an error to be solved with a fair amount of work or is it such an esoteric error, that any attempt to solve it would end up in a long-term project?
Has anybody a solution in mind?
I can provide further info, if necessary. The java version is:
openjdk version "10.0.1" 2018-04-17
I'm running this on Ubuntu 18.04.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] DeepLearning4j Examples Parent
[INFO] DeepLearning4j Examples
[INFO] dl4j-spark-examples
[INFO] dl4j-spark
[INFO] datavec-examples
[INFO] DeepLearning4j CUDA special examples
[INFO] nd4j-examples
[INFO] Reinforcement Learning4j Examples
[INFO] lstm-hdfs
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DeepLearning4j Examples Parent 1.0.0-alpha
[INFO] ------------------------------------------------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-enforcer-plugin/1.0.1/maven-enforcer-plugin-1.0.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] DeepLearning4j Examples Parent ..................... FAILURE [ 1.359 s]
[INFO] DeepLearning4j Examples ............................ SKIPPED
[INFO] dl4j-spark-examples ................................ SKIPPED
[INFO] dl4j-spark ......................................... SKIPPED
[INFO] datavec-examples ................................... SKIPPED
[INFO] DeepLearning4j CUDA special examples ............... SKIPPED
[INFO] nd4j-examples ...................................... SKIPPED
[INFO] Reinforcement Learning4j Examples .................. SKIPPED
[INFO] lstm-hdfs .......................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.774 s
[INFO] Finished at: 2018-05-01T21:23:04+02:00
[INFO] Final Memory: 8M/34M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-enforcer-plugin:1.0.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-enforcer-plugin:jar:1.0.1: Could not transfer artifact org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0.1 from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty -> [Help 1]
[ERROR]
[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/PluginResolutionException
Here is the pom.xml
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-examples-parent</artifactId>
<version>1.0.0-alpha</version>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<name>DeepLearning4j Examples Parent</name>
<description>Examples of training different data sets</description>
<properties>
<!-- Change the nd4j.backend property to nd4j-cuda-8.0-platform, nd4j-cuda-9.0-platform or nd4j-cuda-9.1-platform to use CUDA GPUs -->
<nd4j.backend>nd4j-native-platform</nd4j.backend>
<!--<nd4j.backend>nd4j-cuda-9.1-platform</nd4j.backend>-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<shadedClassifier>bin</shadedClassifier>
<java.version>1.8</java.version>
<nd4j.version>1.0.0-alpha</nd4j.version>
<dl4j.version>1.0.0-alpha</dl4j.version>
<datavec.version>1.0.0-alpha</datavec.version>
<arbiter.version>1.0.0-alpha</arbiter.version>
<rl4j.version>1.0.0-alpha</rl4j.version>
<!-- For Spark examples: change the _1 to _2 to switch between Spark 1 and Spark 2 -->
<dl4j.spark.version>1.0.0-alpha_spark_1</dl4j.spark.version>
<datavec.spark.version>1.0.0-alpha_spark_1</datavec.spark.version>
<!-- Scala binary version: DL4J's Spark and UI functionality are released with both Scala 2.10 and 2.11 support -->
<scala.binary.version>2.11</scala.binary.version>
<hadoop.version>2.2.0</hadoop.version> <!-- Hadoop version used by Spark 1.6.3 and 2.2.1 (and likely others) -->
<guava.version>19.0</guava.version>
<logback.version>1.1.7</logback.version>
<jfreechart.version>1.0.13</jfreechart.version>
<jcommon.version>1.0.23</jcommon.version>
<maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
<exec-maven-plugin.version>1.4.0</exec-maven-plugin.version>
<maven.minimum.version>3.3.1</maven.minimum.version>
<javafx.version>2.2.3</javafx.version>
<javafx.runtime.lib.jar>${env.JAVAFX_HOME}/jfxrt.jar</javafx.runtime.lib.jar>
<aws.sdk.version>1.11.109</aws.sdk.version>
<jackson.version>2.6.6</jackson.version>
<scala.plugin.version>3.2.2</scala.plugin.version>
</properties>
<modules>
<module>dl4j-examples</module>
<module>dl4j-spark-examples</module>
<module>datavec-examples</module>
<module>dl4j-cuda-specific-examples</module>
<module>nd4j-examples</module>
<module>rl4j-examples</module>
<module>lstm-hdfs</module>
</modules>
<!-- Maven Enforcer: Ensures user has an up to date version of Maven before building -->
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>enforce-default</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>[${maven.minimum.version},)</version>
<message>********** Minimum Maven Version is ${maven.minimum.version}. Please upgrade Maven before continuing (run "mvn --version" to check). **********</message>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<!-- Automated Code Formatting -->
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<configFile>${session.executionRootDirectory}/contrib/formatter.xml</configFile>
<directories>
<directory>dl4j-examples</directory>
<directory>dl4j-spark-examples</directory>
<directory>datavec-examples</directory>
<directory>dl4j-cuda-specific-examples</directory>
<directory>nd4j-examples</directory>
<directory>rl4j-examples</directory>
<directory>arbiter-examples</directory>
<directory>lstm-hdfs</directory>
</directories>
</configuration>
</plugin>
<plugin>
<groupId>com.lewisd</groupId>
<artifactId>lint-maven-plugin</artifactId>
<version>0.0.11</version>
<configuration>
<failOnViolation>true</failOnViolation>
<onlyRunRules>
<rule>DuplicateDep</rule>
<rule>RedundantPluginVersion</rule>
<rule>VersionProp</rule>
<rule>DotVersionProperty</rule>
</onlyRunRules>
</configuration>
<executions>
<execution>
<id>pom-lint</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.lewisd</groupId>
<artifactId>lint-maven-plugin</artifactId>
<versionRange>[0.0.11,)</versionRange>
<goals>
<goal>check</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>OpenJFX</id>
<activation>
<jdk>1.7</jdk>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>enforce-default</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>env.JAVAFX_HOME</property>
<message>You must set the environment variable JAVAFX_HOME to the installation directory of the JavaFX 2.0 SDK! (with Oracle JDK1.7, $JRE_HOME/lib/jfxrt.jar)</message>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-external</id>
<phase>clean</phase>
<configuration>
<file>${javafx.runtime.lib.jar}</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>${javafx.version}</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

Related

JDK7, mvn-3.2.2 - maven-enforcer-plugin - RequireJavaVersion failed

I'm using JDK 1.7.0_60 and maven-3.2.2. When I run mvn clean install on my project new-project, I get the following error-
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # new-project ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (default) # new-project ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
Detected JDK Version: 1.7.0-60 is not in the allowed range [1.5,1.6,1.7.0-60).
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.621 s
[INFO] Finished at: 2014-07-10T20:37:32+05:30
[INFO] Final Memory: 7M/18M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (default) on project new-project: Some Enforcer rules have failed.
Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR]
[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/MojoExecutionException
Here are parts of my pom.xml as I cannot share the complete content-
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<showDeprecation>true</showDeprecation>
<source>1.7.0-60</source>
<target>1.7.0-60</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<classpathContainers>
<classpathContainer>
org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5
</classpathContainer>
</classpathContainers>
<additionalConfig>
<file>
<name>
.settings/org.eclipse.core.resources.prefs
</name>
<content>
eclipse.preferences.version=1${line.separator}encoding/<project>=UTF-8${line.separator}
</content>
</file>
</additionalConfig>
<downloadSources>true</downloadSources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.5,1.6,1.7.0-60)</version>
</requireJavaVersion>
<requireMavenVersion>
<version>[3.2.2,)</version>
</requireMavenVersion>
</rules>
</configuration>
<executions>
<execution>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<sourcepath>
${project.basedir}/src/main/javadoc;${project.basedir}/src/main/java
</sourcepath>
<charset>UTF-8</charset>
<docencoding>UTF-8</docencoding>
<docfilessubdirs>true</docfilessubdirs>
<links>
<link>
http://docs.oracle.com/javase/7/docs/api/
</link>
</links>
<source>1.7.0-60</source>
<show>protected</show>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
</reportSets>
</plugin>
If you want to include version 1.7.0-30 in the accepted range, then you have to use square brackets when you declare the range. And you can leave out version 1.6 as it is included in the range:
<requireJavaVersion>
<version>[1.5,1.7.0-60]</version>
</requireJavaVersion>

Embedded error: Failed to transfer file: http://localhost:4502/apps/myProject-core.jar. Return code is: 401

I use the following profile to deploy my osgi bundle to CQ5/crx:
<id>deployToAuthor</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>echo Deployment auf Authoren-Instanz, myProject</id>
<phase>install</phase>
<configuration>
<tasks>
<echo
message="Deployment auf Instanz AUTHOR ! (${install.host}:${install.port}), myProject!"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<id>upload-felix-bundle-author</id>
<phase>install</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<fromDir>${project.build.directory}</fromDir>
<includes>*.jar</includes>
<excludes>pom.xml</excludes>
<serverId>${install.host}</serverId>
<url>dav:${webdav.protocol}://${install.host}:${install.port}</url>
<toDir>apps/${portal.name}/install</toDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I get the following Error:
[INFO] Tests are skipped.
[INFO] [bundle:bundle {execution: default-bundle}]
[WARNING] Bundle path.myProject:myProject-core:bundle:1.5.18-SNAPSHOT : Export path.myProject.components.alerts, has 1, private references [au.com.bytecode.opencsv],
[WARNING] Bundle path.myProject:myProject-core:bundle:1.5.18-SNAPSHOT : Export path.myProject.unionhtmlimport, has 1, private references [path.myProject.unionhtmlimport.impl],
[INFO] [resources:copy-resources {execution: copy-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] [install:install {execution: default-install}]
[INFO] Installing C:\path\myProject\myProject-core\target\myProject-core.jar to C:\path\.m2\repository\path\myProject\myProject-core\1.5.18-SNAPSHOT\myProject-core-1.5.18-SNAPSHOT.jar
[INFO] [bundle:install {execution: default-install}]
[INFO] Installing path/myProject/myProject-core/1.5.18-SNAPSHOT/myProject-core-1.5.18-SNAPSHOT.jar
[INFO] Writing OBR metadata
[INFO] [antrun:run {execution: echo Deployment auf Authoren-Instanz, myProject}]
[INFO] Executing tasks
[echo] Deployment auf Instanz AUTHOR ! (localhost:4502), Project myProject!
[INFO] Executed tasks
[INFO] [wagon:upload {execution: upload-felix-bundle-author}]
[INFO] Uploading C:\path\myProject\myProject-core\target\myProject-core.jar to http://localhost:4502/apps/myProject/install/myProject-core.jar ...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error handling resource
Embedded error: Failed to transfer file: http://localhost:4502/apps/myProject/install/myProject-core.jar. Return code is: 401
Seems to be quite complicated. Why not to use Maven Sling plugin?
<project>
<properties>
<sling.url>http://localhost:4502</sling.url>
<sling.username>admin</sling.username>
<sling.password>admin</sling.password>
</properties>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>maven-sling-plugin</artifactId>
<version>2.1.0</version>
<configuration>
<bundleFileName>${project.build.directory}/${project.build.finalName}.jar</bundleFileName>
<user>${sling.username}</user>
<password>${sling.password}</password>
<slingUrl>${sling.url}/system/console</slingUrl>
</configuration>
</plugin>
...
Usage:
mvn clean package sling:install
Also, please take a look on a sample project using this plugin: Sling-Query.

Possible bug when parsing properties with goal "regex-property" of build-helper-maven-plugin?

The requirement is that I have to parse a system property with regex in order to remove the dot from the value.
Execution example is: mvn install -Dsomeversion=1.3
pom.xml configuration is:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>regex-property</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>someversion.parsed</name>
<value>$\{someversion}</value>
<regex>(.*)[\._](.*)</regex>
<replacement>$1$2</replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
Based on the plugin's documentation, the backslash must be there after the dollar sign in <value>
The issues are:
When the backslash is there, the system property is not parsed
If I remove the backslash:
a) system property is parsed successfully
b) if execute "mvn install" I am getting the error that the parameter 'value' is
missing or incorrect, despite the fact that I have configured <failIfNoMatch>false</failIfNoMatch>
Any feedback would be highly appreciated
Thank you in advance
after some tests, I came to following conclusion:
didn't see the documentation stating that '\' should follow '$' sign
(maybe you can point me to it), so I removed it :), anyway escaping usually achieved by - '\' is relevant for next rather than previous character, as far as I know
for the errror you see for mvn install is value of the config
property <failIfNoMatch> irrelevant
The <failIfNoMatch> decides, should I fail if the system property is there but is not in the expected format? It doens't cover the case that property is not there at all. However for this purpose, in maven exist so called profiles, these can be activated in a different ways, one of them is system property presence.
So the following does the job for me:
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>sample</groupId>
<artifactId>sample</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<profiles>
<profile>
<activation>
<property>
<name>someversion</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>regex-property</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>someversion.parsed</name>
<value>${someversion}</value>
<regex>(.*)[\._](.*)</regex>
<!-- <regex>notmatched</regex>-->
<replacement>$1$2</replacement>
<failIfNoMatch>false</failIfNoMatch>
<!--<failIfNoMatch>true</failIfNoMatch>-->
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>******** Displaying value of property ********</echo>
<echo>${someversion.parsed}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Please note that maven-antrun-plugin is there just to show debugging output.
Now some tests:
mvn install -Dsomeversion=1.3
...
main:
[echo] ******** Displaying value of property ********
[echo] 13
[INFO] Executed tasks
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
...
For no system property version:
mvn install
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
...
Without having special profile stuff in my pom.xml I'd get following output:
mvn install
...
INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] One or more required plugin parameters are invalid/missing for 'build-helper:regex-property'
[0] Inside the definition for plugin 'build-helper-maven-plugin' specify the following:
<configuration>
...
<value>VALUE</value>
</configuration>
-OR-
on the command line, specify: '-Dsomeversion=VALUE'
...
And just to make things complete, in case I'd use in my solution (currently commented out) <regex>notmatched</regex> as well as <failIfNoMatch>true</failIfNoMatch>:
mvn install -Dsomeversion=1.3
...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - sample:sample:pom:1.0.0-SNAPSHOT
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [build-helper:regex-property {execution: regex-property}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] No match to regex 'notmatched' found in '1.3'.
[INFO] ------------------------------------------------------------------------
...
Please note, that last 2 errors differ - one is for missing property and the other one for the non-matching regexp.
So just to sum up, I believe that build-helper-maven-plugin works as expected.

Maven Jaxb2 xjc plugin error No schemas have been found

These days I've spent some time on JAXB for converting XSD to Java Class and vice versa. Here's a very good tutorial for beginners, http://www.journaldev.com/1312/how-to-generate-java-classes-from-xsd-using-xjc-maven-plugin. I follow the steps strictly, but always get error when mvn clean install
Here's my pom.xml file.
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jd</groupId>
<artifactId>jd</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<!-- Plugin required to build java classes from XSD using XJC -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The name of your generated source package -->
<arguments>-extension -npa -b ${project.basedir}/src/main/java/com/moodys/jaxb/global.xjb</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
But when I type mvn clean install, it always give me error as following:
C:\Users\congy\Desktop\Work\workspace\JaxbFromClass>mvn clean jaxb2:xjc
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jd 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # jd ---
[INFO] Deleting C:\Users\congy\Desktop\Work\workspace\JaxbFromClass\target
[INFO]
[INFO] --- jaxb2-maven-plugin:1.5:xjc (default-cli) # jd ---
[INFO] Generating source...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.487s
[INFO] Finished at: Thu Jul 04 19:09:37 CST 2013
[INFO] Final Memory: 4M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.5:xjc (default-cli) on project jd: No schemas have been found -> [Help 1]
[ERROR]
[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/MojoExecutionException
Can anyone show me the cause or simply tell me what should I refer to for further information?
Another question is : according to this question Difference of Maven JAXB plugins, there's at least three jaxb plugins. So all of these plugins are all generated for the same purposes? If so ,why?
Thanks in advance!
As you did not provide any schemaDirectory, the plugin is trying to generate Java sources from all XML schema files in the default schema directory. You should configure the plugin according to the documentation :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>id1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/jaxb</outputDirectory>
<packageName>com.your.package.jaxb</packageName>
<schemaDirectory>src/main/xsd</schemaDirectory>
<schemaFiles>jaxb.xsd</schemaFiles>
</configuration>
</execution>
</executions>
</plugin>
Try to make sure that jaxb.xsd is present under src/main/resources, the plugin is waring since it coudn't find the scheme in the specified location.
We can use as below in pom.xml file
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>id1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<outputDirectory>src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
<packageName>com.subu.xsd.model</packageName>
<schemaDirectory>src/main/java/schemadir</schemaDirectory>
<schemaFiles>XYZ.xsd</schemaFiles>
</configuration>
</execution>
</executions>
</plugin>
The OP already got their answer, but I ran into this same problem for a different reason...
I introduced a new class that JAXB wasn't generating source for. This is because I used a parameterized constructor. Once I added a no-arg constructor the problem was fixed.

maven-deploy-plugin deploy-file goal insists on deploying javadoc file for previous deploy-file execution

I have a pom which I use to package some third party jars to deploy to a local nexus.
However it always fails with the second upload. It seems as if it is always picking up the javadoc associated with the first deploy-file execution, eventhough I have not specified this.
Is this a bug, or what am I doing wrong?
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>a.b.c</groupId>
<artifactId>vendorx_jdbc_driver_wrapper</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<vendorx_jdbc_driver_wrapper.javadoczip>${basedir}/files/11.2.0.1.0/jdbc/javadoc.zip</vendorx_jdbc_driver_wrapper.javadoczip>
<vendorx_jdbc_driver_wrapper.javadoctemp>${basedir}/files/11.2.0.1.0/jdbc/javadoctemp</vendorx_jdbc_driver_wrapper.javadoctemp>
<vendorx_jdbc_driver_wrapper.javadocfile>${basedir}/files/11.2.0.1.0/jdbc/javadoctemp/thejavadocs.jar</vendorx_jdbc_driver_wrapper.javadocfile>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>prepare</id>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo message="repackge the vendorx javadoc zip to be in the expected format" />
<delete includeemptydirs="true">
<fileset dir="${vendorx_jdbc_driver_wrapper.javadoctemp}" includes="**/*" defaultexcludes="false"/>
</delete>
<unzip src="${vendorx_jdbc_driver_wrapper.javadoczip}" dest="${vendorx_jdbc_driver_wrapper.javadoctemp}" />
<!-- N.B. vendorx zip version specific location - you will have to change this to make it work -->
<jar destfile="${vendorx_jdbc_driver_wrapper.javadocfile}" basedir="${vendorx_jdbc_driver_wrapper.javadoctemp}/E13995_02/html"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>install-library-main</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${basedir}/files/11.2.0.1.0/jdbc/lib/vjdbc99.jar</file>
<groupId>a.b.c.com.vendorx</groupId>
<artifactId>vjdbc99</artifactId>
<version>11.2.0.1.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
<execution>
<id>install-javadocs-main</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${vendorx_jdbc_driver_wrapper.javadocfile}</file>
<groupId>a.b.c.com.vendorx</groupId>
<artifactId>vjdbc99</artifactId>
<version>11.2.0.1.0</version>
<packaging>jar</packaging>
<classifier>javadoc</classifier>
</configuration>
</execution>
<execution>
<id>install-library-debug</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${basedir}/files/11.2.0.1.0/jdbc/lib/vjdbc99_g.jar</file>
<groupId>a.b.c.com.vendorx</groupId>
<artifactId>vjdbc99_g</artifactId>
<version>11.2.0.1.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
<execution>
<id>install-javadocs-debug</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<!-- same javadocs as for non debug -->
<file>${vendorx_jdbc_driver_wrapper.javadocfile}</file>
<groupId>a.b.c.com.vendorx</groupId>
<artifactId>vjdbc99_g</artifactId>
<version>11.2.0.1.0</version>
<packaging>jar</packaging>
<classifier>javadoc</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<!-- Don't bother deploying this POM ... its only the artifact we want to deploy -->
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
<!-- This is the real thing we are deploying -->
<execution>
<id>deploy-library-main</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<file>${basedir}/files/11.2.0.1.0/jdbc/lib/vjdbc99.jar</file>
<groupId>a.b.c.com.vendorx</groupId>
<artifactId>vjdbc99</artifactId>
<version>11.2.0.1.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
<javadoc>${vendorx_jdbc_driver_wrapper.javadocfile}</javadoc>
<url>http://foo.lan:8888/nexus/content/repositories/releases</url>
<repositoryId>releases</repositoryId>
</configuration>
</execution>
<execution>
<id>deploy-library-debug</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<file>${basedir}/files/11.2.0.1.0/jdbc/lib/vjdbc99_g.jar</file>
<groupId>a.b.c.com.vendorx</groupId>
<artifactId>vjdbc99_g</artifactId>
<version>11.2.0.1.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
<url>http://foo.lan:8888/nexus/content/repositories/releases</url>
<repositoryId>releases</repositoryId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>releases</id>
<url>http://foo.lan:8888/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://foo.lan:8888/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
</project>
Here's the output
C:\Users\wibble\workspace\vendorx_jdbc_driver_wrapper>mvn deploy
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building vendorx_jdbc_driver_wrapper 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-antrun-plugin:1.2:run (prepare) # vendorx_jdbc_driver_wrapper ---
[INFO] Executing tasks
[echo] repackge the vendorx javadoc zip to be in the expected format
[unzip] Expanding: C:\Users\wibble\workspace\vendorx_jdbc_driver_wrapper\files\11.2.0.1.0\jdbc\javadoc.zip into C:\Users\wibble\workspace\vendorx_jdbc_driver_wrapper\files\11.2.0.1.0\j
dbc\javadoctemp
[jar] Building jar: C:\Users\wibble\workspace\vendorx_jdbc_driver_wrapper\files\11.2.0.1.0\jdbc\javadoctemp\thejavadocs.jar
[INFO] Executed tasks
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) # vendorx_jdbc_driver_wrapper ---
[INFO] Installing C:\Users\wibble\workspace\vendorx_jdbc_driver_wrapper\pom.xml to C:\Users\wibble\.m2\repository\uk\co\his\vendorx_jdbc_driver_wrapper\0.0.1-SNAPSHOT\vendorx_jdbc_driver_wr
apper-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (install-library-main) # vendorx_jdbc_driver_wrapper ---
[INFO] Installing C:\Users\wibble\workspace\vendorx_jdbc_driver_wrapper\files\11.2.0.1.0\jdbc\lib\vjdbc99.jar to C:\Users\wibble\.m2\repository\uk\co\his\com\vendorx\vjdbc99\11.2.0.1.0\ojdbc
6-11.2.0.1.0.jar
[INFO] Installing C:\Users\wibble\AppData\Local\Temp\1\mvninstall1181445077198226588.pom to C:\Users\wibble\.m2\repository\uk\co\his\com\vendorx\vjdbc99\11.2.0.1.0\vjdbc99-11.2.0.1.0.pom
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (install-javadocs-main) # vendorx_jdbc_driver_wrapper ---
[INFO] Installing C:\Users\wibble\workspace\vendorx_jdbc_driver_wrapper\files\11.2.0.1.0\jdbc\javadoctemp\thejavadocs.jar to C:\Users\wibble\.m2\repository\uk\co\his\com\vendorx\vjdbc99\11.
2.0.1.0\vjdbc99-11.2.0.1.0-javadoc.jar
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (install-library-debug) # vendorx_jdbc_driver_wrapper ---
[INFO] Installing C:\Users\wibble\workspace\vendorx_jdbc_driver_wrapper\files\11.2.0.1.0\jdbc\lib\vjdbc99_g.jar to C:\Users\wibble\.m2\repository\uk\co\his\com\vendorx\vjdbc99_g\11.2.0.1.0\o
jdbc6_g-11.2.0.1.0.jar
[INFO] Installing C:\Users\wibble\AppData\Local\Temp\1\mvninstall4548076073436253537.pom to C:\Users\wibble\.m2\repository\uk\co\his\com\vendorx\vjdbc99_g\11.2.0.1.0\vjdbc99_g-11.2.0.1.0.pom
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (install-javadocs-debug) # vendorx_jdbc_driver_wrapper ---
[INFO] Installing C:\Users\wibble\workspace\vendorx_jdbc_driver_wrapper\files\11.2.0.1.0\jdbc\javadoctemp\thejavadocs.jar to C:\Users\wibble\.m2\repository\uk\co\his\com\vendorx\vjdbc99_g\1
1.2.0.1.0\vjdbc99_g-11.2.0.1.0-javadoc.jar
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) # vendorx_jdbc_driver_wrapper ---
[INFO] Skipping artifact deployment
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy-file (deploy-library-main) # vendorx_jdbc_driver_wrapper ---
Uploading: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99/11.2.0.1.0/vjdbc99-11.2.0.1.0.jar
Uploaded: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99/11.2.0.1.0/vjdbc99-11.2.0.1.0.jar (2062 KB at 3152.7 KB/sec)
Uploading: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99/11.2.0.1.0/vjdbc99-11.2.0.1.0.pom
Uploaded: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99/11.2.0.1.0/vjdbc99-11.2.0.1.0.pom (404 B at 8.8 KB/sec)
Downloading: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99/maven-metadata.xml
Uploading: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99/maven-metadata.xml
Uploaded: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99/maven-metadata.xml (316 B at 6.1 KB/sec)
Uploading: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99/11.2.0.1.0/vjdbc99-11.2.0.1.0-javadoc.jar
Uploaded: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99/11.2.0.1.0/vjdbc99-11.2.0.1.0-javadoc.jar (780 KB at 1621.4 KB/sec)
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy-file (deploy-library-debug) # vendorx_jdbc_driver_wrapper ---
Uploading: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99_g/11.2.0.1.0/vjdbc99_g-11.2.0.1.0.jar
Uploaded: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99_g/11.2.0.1.0/vjdbc99_g-11.2.0.1.0.jar (3323 KB at 2472.1 KB/sec)
Uploading: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99_g/11.2.0.1.0/vjdbc99_g-11.2.0.1.0.pom
Uploaded: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99_g/11.2.0.1.0/vjdbc99_g-11.2.0.1.0.pom (406 B at 6.8 KB/sec)
Downloading: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99_g/maven-metadata.xml
Uploading: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99_g/maven-metadata.xml
Uploaded: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99_g/maven-metadata.xml (318 B at 4.7 KB/sec)
Uploading: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99/11.2.0.1.0/vjdbc99-11.2.0.1.0-javadoc.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.311s
[INFO] Finished at: Mon Jan 23 12:34:09 GMT 2012
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (deploy-library-debug) on project vendorx_jdbc_driver_wrapper: Error deploying attached artifact C:\Users\Adm
inistrator\workspace\vendorx_jdbc_driver_wrapper\files\11.2.0.1.0\jdbc\javadoctemp\thejavadocs.jar: Failed to deploy artifacts: Could not transfer artifact uk.co.his.com.vendorx:vjdbc99:jar:javadoc:11.2.
0.1.0 from/to releases (http://foo.lan:8888/nexus/content/repositories/releases): Failed to transfer file: http://foo.lan:8888/nexus/content/repositories/releases/a/b/c/com/vendorx/vjdbc99/1
1.2.0.1.0/vjdbc99-11.2.0.1.0-javadoc.jar. Return code is: 400 -> [Help 1]
[ERROR]
[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/MojoExecutionException
C:\Users\wibble\workspace\vendorx_jdbc_driver_wrapper>
I have created a bug on the deploy plugin jira:
MDEPLOY-143
Third party POMs will almost never play together nicely with your local Maven infrastructure.
The POM in question modifies the Maven build lifecycle by associating a number of goals with the phase install.
To deploy artifacts defined by that POM, I'd recommend you first create the artifacts by issuing a mvn package command. This will create the artifacts in your project's build folder (target/) but not send them to your local repository. Then upload them manually one by one into your repository.
If instead you prefer to deploy straight from that POM file, be prepared to do some serious editing beforehand.
As a side note: you might want to put such artifacts into a 3rd party repository inside your Nexus, not into nexus/content/repositories/releases, which is reserved for releases of your own software only (by convention).
Hope this helps!

Resources