JAXB SAXParseException after migrating from Java8 to Java11 - jaxb

I'm upgrading a Spring Boot 2.7.0 project from Java 8 to Java 11.
The project is using maven-jaxb2-plugin to generate classes from wsdl files.
This is the configuration
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.15.1</version>
<executions>
<execution>
<id>organisationalStructure</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generateDirectory>${project.build.directory}/generated-sources</generateDirectory>
<generatePackage>com.test.organisationalStructure</generatePackage>
<schemas>
<schema>
<fileset>
<directory>${basedir}/src/main/resources/wsdl/</directory>
<include>organisationStructure.wsdl</include>
</fileset>
</schema>
</schemas>
<readOnly>true</readOnly>
<removeOldOutput>false</removeOldOutput>
<forceRegenerate>true</forceRegenerate>
</configuration>
</execution>
The configuration stays the same in both versions, only the version of maven-jaxb2-plugin changes from 0.13.3 to 0.15.1. I had to add new maven dependencies jaxwx-api and saaj-impl. They use the default version which comes from Spring Boot.
The output, when running mvn clean install with Java 8, is
[INFO] --- maven-jaxb2-plugin:0.13.3:generate (organisationalStructure) # redb2b ---
[WARNING] You are using forceRegenerate=true in your configuration.
This configuration setting is deprecated and not recommended as it causes problems with incremental builds in IDEs.
Please refer to the following link for more information:
https://github.com/highsource/maven-jaxb2-plugin/wiki/Do-Not-Use-forceRegenerate
Consider removing this setting from your plugin configuration.
[INFO] The [forceRegenerate] switch is turned on, XJC will be executed.
[INFO] Episode file [C:\RPSS\B2B-portal\target\generated-sources\META-INF\sun-jaxb.episode] was augmented with if-exists="true" attributes.
When running mvn clean install with Java 11, the output is identical but it also contains an exception
org.xml.sax.SAXParseException: Are you trying to compile WSDL? Support for WSDL is experimental. You may enable it by using the -wsdl option.
The SAXParseException comes between the last 2 [INFO] lines.
The code is generated successfully from the wsdl file and the application behaves fine.
Still, I would like to understand the reason behind the exception. Nothing changes in the wsdl.
Thanks.

Related

/bin/sh: npx: command not found on linux when trying to install using maven

I am trying to install the node and npm using maven frontend plugin during build.
pom.xml Configuration as below
<properties>
<nodejs.version>v14.15.1</nodejs.version>
<npm.version>6.14.8</npm.version>
<npmRepoUrl> URL </npmRepoUrl>
<nodeRepoUrl> URL </nodeRepoUrl>
</properties>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<configuration>
<nodeDownloadRoot>${nodeRepoUrl}</nodeDownloadRoot>
<npmDownloadRoot>${nodeRepoUrl}</npmDownloadRoot>
<nodeVersion>${nodejs.version}</nodeVersion>
<npmVersion>${npm.version}</npmVersion>
<workingDirectory>src/main/utilities</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<phase>validate</phase>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install test</id>
<phase>validate</phase>
<goals>
<goal>npm</goal>
</goals>
</execution>
</executions>
</plugin>
Using above configuration node and NPM got installed successfully but still gives error that npx command not found for further operations
[INFO] Installing node version v14.15.1
[INFO] Downloading <NODE URL >
[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] Unpacking
[INFO] Copying node binary from
[INFO] Installed node locally.
[INFO] Installing npm version 6.14.8
[INFO] Downloading <NPM URL >
[INFO] No proxies configured
[INFO] No proxy was configured, downloading directly
[INFO] Unpacking
[INFO] Installed npm locally.
Am I missing any configuration can someone please help ?

Failed to execute goal. Could not download npm. Got error code 404 from server

I'm trying to execute the following in my local AEM 6.5.12 instance...
mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate -D archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=35 -D appTitle="WKND Sites Project" -D appId="wknd" -D groupId="com.adobe.aem.guides" -D artifactId="aem-guides-wknd" -D package="com.adobe.aem.guides.wknd" -D version="0.0.1-SNAPSHOT" -D aemVersion="6.5.12"
...but I keep getting errors, such as the following:
[INFO] Reactor Summary for WKND Sites Project 0.0.1-SNAPSHOT:
[INFO]
[INFO] WKND Sites Project ................................. SUCCESS [ 0.457 s]
[INFO] WKND Sites Project - Core .......................... SUCCESS [ 18.337 s]
[INFO] WKND Sites Project - UI Frontend ................... FAILURE [ 1.389 s]
[INFO] WKND Sites Project - Repository Structure Package .. SKIPPED
[INFO] WKND Sites Project - UI apps ....................... SKIPPED
[INFO] WKND Sites Project - UI content .................... SKIPPED
[INFO] WKND Sites Project - UI config ..................... SKIPPED
[INFO] WKND Sites Project - All ........................... SKIPPED
[INFO] WKND Sites Project - Integration Tests ............. SKIPPED
[INFO] WKND Sites Project - Dispatcher .................... SKIPPED
[INFO] WKND Sites Project - UI Tests ...................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.499 s
[INFO] Finished at: 2022-09-22T11:20:18-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.0:install-node-and-npm (install node and npm) on project aem-guides-wknd.ui.frontend: Could not download npm: Could not download https://registry.npmjs.org/npm/-/npm-6.17.14.tgz: Unknown host No such host is known (registry.npmjs.org) -> [Help 1]
Here's my root pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<tarLongFileMode>posix</tarLongFileMode>
</configuration>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
<configuration>
<nodeVersion>v12.22.7</nodeVersion>
<npmVersion>6.17.14</npmVersion>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Maven Jar Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<!-- Maven Clean Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- BND Maven Plugin -->
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>${bnd.version}</version>
<executions>
<execution>
<id>bnd-process</id>
<goals>
<goal>bnd-process</goal>
</goals>
<configuration>
<bnd>
Initially, JAVA HOME was pointing to a JRE folder, but I've since changed it to point to a JDK. Also, there's another discussion where it was suggested to do the following, which worked for several people, but did not work for me:
Change the npm verson of pom.xml in ui folder from 6.4.1 to 3.10.8.
UPDATE: After updating the pom.xml file's npmVersion, I ran Maven again and now get this error:
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.0:npm (npm run prod) on project aem-guides-wknd.ui.frontend: Failed to run task: 'npm run prod' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)

Maven SL4J multiple bindings, previous solutions fail

I have a project that has multiple SLF4J bindings.
I have read and tried the solutions in this SO post, this other SO post
and the slf4j website.
What I see if this when I run the code is
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/Mike/.m2/repository/org/jlab/coat/coat-libs/5.1-SNAPSHOT/coat-libs-5.1-SNAPSHOT.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/Mike/.m2/repository/org/slf4j/slf4j-log4j12/1.7.16/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
However in my pom.xml file, I already have
<dependency>
<groupId>org.jlab.coat</groupId>
<artifactId>coat-libs</artifactId>
<version>5.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
and in the mvn dependency:tree I do not see this dependency for the exclusion jar, only for the Spark jar, i.e.
[INFO] com.IKP:DCdatabase:jar:0.0.1-SNAPSHOT
[INFO] +- org.jlab.coat:coat-libs:jar:5.1-SNAPSHOT:compile
[INFO] +- org.apache.spark:spark-core_2.11:jar:2.2.1:compile
...
...
...
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.16:compile
[INFO] | +- org.slf4j:jul-to-slf4j:jar:1.7.16:compile
[INFO] | +- org.slf4j:jcl-over-slf4j:jar:1.7.16:compile
[INFO] | +- log4j:log4j:jar:1.2.17:compile
[INFO] | +- org.slf4j:slf4j-log4j12:jar:1.7.16:compile
I have also tried a few more steps, such as clean out my .m2 directory, and build all sources from scratch, but I still see this double binding.
The nuance that occurs is that the log suppression for Spark does occur, i.e.
Logger.getLogger("org.apache.spark.SparkContext").setLevel(Level.WARN);
Logger.getLogger("org").setLevel(Level.OFF);
Logger.getLogger("akka").setLevel(Level.OFF);
No longer set the levels to off and I see all the levels.
Is there another way to remove this multiple binding for SLF4J?
It looks to me like coat-libs has been packaged as an uber jar which is why slf4j doesn't show up as a dependency when you do mvn dependency:tree. This explains why your exclusion isn't working.
I would recommend taking a look at the maven shade plugin for packaging your jar. Then, you can use a filter to exclude the slf4j dependencies from coat-libs using a filter.
For example, maybe something like:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>org.jlab.coat:coat-libs</artifact>
<excludes>
<exclude>org/slf4j/**</exclude>
</excludes>
</filter>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Just like the message says, you're getting one binding from coat-libs-5.1-SNAPSHOT.jar, and another binding in slf4j-log4j12-1.7.16.jar. It's not that "coat-libs" is trying to bring in a dependency that has a binding, it is a logging binding that's trying to handle SLF4J logging. You can only use one logging binding, so you either need to remove the usage of coat-libs, or you need to exclude slf4j-log4j12 from the dependencies for spark-core, depending on which logging framework you're actually trying to use.

Maven enforcer plugin 1.4.1 or one of its dependencies cannot be resolved

I am trying to build livy-server on one of the datanodes of our hadoop cluster which has all the prerequisites like Spark 1.6.2, hadoop 2.4.2 already set up.
I am following the instrucctions as described in the link below
https://github.com/cloudera/livy
After executing the mvn package as follows
git clone git#github.com:cloudera/livy.git
cd livy
mvn package
However I am getting an error as
Plugin org.apache.maven.plugins:maven-enforcer-plugin:1.3.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.3.1: Could not transfer artifact org.apache.maven.plugins:maven-enforcer-plugin:pom:1.3.1 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: unknown error: Unknown host repo.maven.apache.org: unknown error ->
I tried searching for this error however since I am a newbie I am not able to follow the solutions mentioned, but one common thing was configuring the pom.xml
my pom.xml conf related to the maven enforcer plugin 1.4.1 is as follows
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>1.7</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
Can anyone help me in resolving this build issue?
Thanks for your help
Your error clearly says the following
Unknown host repo.maven.apache.org
Try
ping repo.maven.apache.org if passes then
wget http://repo.maven.apache.org/maven2

Drools decision tables precompilation using Maven

According to the drools 6.3 documentation, section 4.2.2.3 :
The KIE plugin for Maven ensures that artifact resources are validated and pre-compiled, it is recommended that this is used at all times. To use the plugin simply add it to the build section of the Maven pom.xml
Consequently, my pom.xml is :
<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>6.3.0.Final-redhat-9</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-decisiontables</artifactId>
<version>6.3.0.Final-redhat-9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>6.3.0.Final-redhat-9</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
I placed my decision table file, let's call it rules.xls, in the src/main/resources/my/company/package/. The one and only other file in my Maven project is the kmodule.xml file, which is in src/main/resources/META-INF/ and contains the minimal code :
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule"/>
Because I removed all the other dependencies (including the one that contains the Java objects used in the decision table), I was expecting drools to launch an error message of type cannot find symbol.
But when I try to clean install the project using Maven, the compilation succeed, a JAR file is created and it does contain the kmodule.xml and rules.xls files at the exact location where I placed them. No additional file generated during compilation, no error, no warning, nothing. Just a plain JAR with my files, a MANIFEST.MF file and a maven directory under META-INF.
In the maven trace, here are the plugins activated (in that order) :
[INFO] --- maven-clean-plugin:2.4.1:clean
[INFO] --- maven-resources-plugin:2.5:resources
[INFO] --- maven-compiler-plugin:2.3.2:compile
[INFO] --- maven-resources-plugin:2.5:testResources
[INFO] --- maven-compiler-plugin:2.3.2:testCompile
[INFO] --- maven-surefire-plugin:2.10:test
[INFO] --- maven-jar-plugin:2.3.2:jar
[INFO] --- maven-install-plugin:2.3.1:install
Nothing about the kie plugin. Any hint to activate the rules compilation at build time ?
In order to activate kie-maven-plugin it is also necessary to specify the correct packaging type in your pom.xml
<packaging>kjar</packaging>
I finally did find a way to activate the plugin. I added this to my pom.xml :
<pluginManagement>
<plugins>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>6.3.0.Final-redhat-9</version>
<extensions>true</extensions>
<executions>
<execution>
<id>brms-rules-compilation</id>
<phase>generate-resources</phase>
<goals>
<goal>build</goal>
</goals>
<inherited>false</inherited>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
And now get a Drools compilation trace including :
[INFO] --- kie-maven-plugin:6.3.0.Final-redhat-9:build
[main] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - Adding KieModule from resource: FileResource[...]
I'm no Maven guru, this solution may not be the best (I even do not entirely understand what I wrote as a Maven perspective), so I would be glad to get an easier one.

Resources