Im generating some classes from WSDL files with wsimport maven plugin # Mule Anypoint Studio 3.5 with JDK 1.7_55
I'm using jaxb 2.2.7 and remove version 2.1.9 from mule libs and replaced by 2.2.7.
When i compile, sometines works fine but others i take this error multiple times:
The attribute required is undefined for the annotation type XmlElementRef
I tried to create an endorsed folder in JDK and include .jars needed,
Do you know any way to avoid this error or replace this libs correctly?
I include this dependencies in pom.xml
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.7</version>
</dependency>
<!-- xjc -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>idlj-maven-plugin</artifactId>
<version>1.2.1</version>
</dependency>
wsimport is 2.2.7 to
wsimport settings:
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>wsdl-AMANSequenceService-exec</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<args>
<arg>-version</arg>
<arg>-B-nv</arg>
<arg>-Xdebug</arg>
<arg>-B-XautoNameResolution</arg>
<arg>-Xendorsed</arg>
</args>
<extension>true</extension>
<sourceDestDir>${basedir}/src/main/java</sourceDestDir>
<destDir>${basedir}/src/main/java</destDir>
<extension>true</extension>
<wsdlDirectory>${basedir}/src/main/resources/SICG/AMANSequenceService</wsdlDirectory>
<wsdlFiles>
<wsdlFile>AMANSequenceService.wsdl</wsdlFile>
</wsdlFiles>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/SICG/external/binding.xjb</bindingFile>
</bindingFiles>
</configuration>
</execution>
We can fix the above behavior by replacing the following jars in Mule CE Runtime Folder (C:\AnypointStudio\plugins\org.mule.tooling.server.3.5.0_3.5.0.201405141856\mule\lib\opt):
jaxb-api-2.1 with jaxb-api-2.2.jar
jaxb-impl-2.1.9 with jaxb-impl-2.2.7.jar
jaxb-xjc-2.1.9 with jaxb-xjc-2.2.7.jar
It would be useful if Mule developers updated these packages to the newest distributions.
The location of your endorsed jars is incorrect. It should be:
%JAVA_HOME%\jre\lib\endorsed
which in your case is:
C:\Java\jdk1.7.0_55\jre\lib\endorsed
Put the jaxb jars here, remove all others and re-try.
This is for people who find this old posting from the search engines.
I was getting the same error message in a new project that I created in Eclipse. The solution was to:
1.) create a new JAXB project instead of some other project type,
2.) specify JDK7,
3.) Specify version 2.2 of JAXB
In Mule specific case, if you are stuck with JAXB2.1, you can force Apache CXF WSDL2Java to generate JAXB2.1 compliant client code
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.1.6</version>
<executions>
<execution>
<id>generate-sources-file1</id>
<phase>generate-sources</phase>
<configuration>
<defaultOptions>
<frontEnd>jaxws21</frontEnd>
</defaultOptions>
<sourceRoot>${project.build.directory}/generated/service-file1</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/some.wsdl</wsdl>
<wsdlLocation>classpath:some.wsdl</wsdlLocation>
<extraargs>
<extraarg>-client</extraarg>
<extraarg>-verbose</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
the key part is
<defaultOptions>
<frontEnd>jaxws21</frontEnd>
</defaultOptions>
Related
I'm trying to generate the code from WSDL file with CXF in Maven. Currently using Java 19 which I'd like to keep.
My plugin is configured with:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.5.4</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/sample.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.1</version>
</dependency>
<!--dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>4.0.1</version>
</dependency-->
</dependencies>
</plugin>
And always get error:
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.5.4:wsdl2java (default) on project customsx: Execution default of goal org.apache.cxf:cxf-codegen-plugin:3.5.4:wsdl2java failed: A required class was missing while executing org.apache.cxf:cxf-codegen-plugin:3.5.4:wsdl2java: javax/xml/bind/annotation/adapters/HexBinaryAdapter
I'm familiar with the bind-api removal in Java 11, and always was able to solve usual JAXB troubles using jakarta libs.
In this particular case the error seems to come from wsdl2java itself. If I do not set the jakarta dependencies the error is exclusively on javax.xml.bind.annotation as expected. If I add the dependency the error is now on HexBinaryAdapter, which I can't seem able to solve.
Any ideas ?
I am having trouble migrating my project to Java 11 from Java 8 with Hibernate validator.
I get the following error while attempting to build my project with maven:
[INFO] --- maven-processor-plugin:3.3.3:process (default) # maple-orm ---
[ERROR] diagnostic: ...\module-info.java:19: error: module not found: org.hibernate.validator
requires org.hibernate.validator;
The plugin in the pom for maven-processor-plugin is defined as follows:
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>3.3.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.4.10.Final</version>
</dependency>
</dependencies>
</plugin>
And the module-info.java looks like this:
module test.module {
...
requires org.hibernate.validator;
}
Is there something specific that I am missing in order to fix this issue with JPMS?
As per documentation from Github repository, Release 3.3.3. maven-processor-plugin supports targets is 9
--release release
Compiles against the public, supported and documented API for a specific VM version.
Supported release targets are 6, 7, 8, and 9.
I was able to get a solution to this problem following fabfas answer. I would suggest upgrading to version 4.0 of maven-processor-plugin and specify the proper plugin to run. Please also keep in mind I am using the jakarta suffixed libraries so this may require some fine tuning.
The module name is indeed org.hibernate.validator
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>4.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen-jakarta</artifactId>
<version>${hibernate.version}</version>
</dependency>
</dependencies>
</plugin>
I am using jaxws-maven-plugin to generate some JAX-WS clients based on WSDL files.
I need to use JDK 1.6 so I am executing with JAX-WS Tools 2.1.7
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.1.7</version>
</dependency>
If I use recent versions of jaxws-maven-plugin 2.2.1 or 2.3 over the 2.1.7 jaxws-tools my build doesn't work because an invalid -encoding parameter is added to the command line.
unrecognized parameter -encoding
Full command is
[DEBUG] cmd.exe /X /C ""C:\Program Files\Java\jdk1.6.0_45\jre\bin\java.exe" -Xbootclasspath/p:.m2\repository\javax\xml\bind\jaxb-api\2.1\jaxb-api-2.1.jar;.m2\repository\javax\xml\soap\saaj-api\1.3\saaj-api-1.3.jar;.m2\repository\javax\xml\ws\jaxws-api\2.1\jaxws-api-2.1.jar org.jvnet.jax_ws_commons.jaxws.Invoker com.sun.tools.ws.wscompile.WsimportTool -keep -s <some dir> -d <some dir> -encoding UTF-8 -p <some package> file:<some wsdl file>"
The following pom.xml is working fine, I use 2.2 which does not send the encoding parameter.
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version> <!-- This version works fine -->
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<wsdlDirectory>src/wsdl</wsdlDirectory>
<sourceDestDir>src/main/java</sourceDestDir>
<wsdlFiles>
<wsdlFile>ConsultarStatusNfe.wsdl</wsdlFile>
</wsdlFiles>
<!-- for JDK 6 compilation compatibility -->
<xnocompile>false</xnocompile>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.1.7</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
I was able to use the latest versions by setting the <target>2.1</target> configuration.
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase/>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<wsdlDirectory>src/wsdl</wsdlDirectory>
<sourceDestDir>src/main/generated</sourceDestDir>
<wsdlFiles>
<wsdlFile>myfile.wsdl</wsdlFile>
</wsdlFiles>
<packageName>com.souzacruz.pwnfeintegrator</packageName>
<!-- for JDK 6 compilation compatibility -->
<xnocompile>false</xnocompile>
<target>2.1</target>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.2.10</version>
</dependency>
</dependencies>
</plugin>
the version 2.1.1 of the plug in jaxws-tools does not support the parameter "-encoding". Use a later version, for example 2.2.6 that it does.
I'm trying to generate schema files from java classes with maven using the jaxb2-maven-plugin under java 6. Generally it works fine.
But additionally I'am using the jaxb-facets fork in order to support the full schema features. Generally jaxb-facets need to override the standard jaxb implementation in order to work. But this seems to be the problem. When using the jaxb2-maven-plugin, the plugin always downloads the original jaxb implementation. I tried using the endorsed strategy, but there seems to be no difference.
I'am banging my head for hours :-(((
This is the relevant part of my pom file:
<!-- The jaxb-facets depedencies: Note that jaxb-facets should be at the top of all dependencies (at least before any dependencies to JAXB libraries) -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.7-facets-1.0.3</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2.6</version>
</dependency> ...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<argline>-Djava.endorsed.dirs="${project.build.directory}/endorsed"</argline>
</configuration>
<executions>
<execution>
<goals>
<goal>schemagen</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<includes>
<include>de/dvka/avaro/model/schema/*.java</include>
</includes>
<outputDirectory>src/main/java/de/dvka/avaro/model/schema</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
I skipped the endorsed part here, because it is to long
How do I generate QueryDsl Q-Classes by only specifying a package name?
Given the source classes reside in my target/generated-sources folder since they are the product of other build plugins (WSDLs, XSDs, etc.)
I have tried using the following plugins, but can't find the right configuration:
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-maven-plugin</artifactId>
<version>2.9.0</version>
<executions>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources</outputDirectory>
<processor>${com.mysema.query.apt.ProcessorClass}</processor>
</configuration>
</executions>
and:
<groupId>com.mysema.maven</groupId>
<artifactId>maven-apt-plugin</artifactId>
<version>1.0.4</version>
What I'd like to do is something like this:
<configuration>
<packageName>com.my.package</packageName>
<sourceFolder>target/generated-sources</sourceFolder>
<targetFolder>target/generated-sources/querydsl</targetFolder>
</configuration>
...which would generate the classes:
com.my.package.QFoo.java
com.my.package.QBar.java
Since there's no common JPA or JDO annotation, and I don't have have access to the source files, I haven't been able to use any of the com.mysema.query.apt.*Processors for the maven-apt-plugin's <processor>.
EDIT 1: added full maven-apt-plugin configuration.
EDIT 2:
- I was able to get the maven-apt-plugin to work sporadically via the maven command line, but not Eclipse/STS by extending AbstractQuerydslProcessor to look for #XmlType-annotated classes. Double code-generation is admittedly not an ideal solution.
The answer is to generate the Q-classes using the strategy Timo outlined here: https://github.com/mysema/querydsl/issues/196
In my module's package-info.java:
#QueryEntities({ com.remote.module.Foo.class,
com.remote.module.Bar.class })
package com.my.local.module.querydsl;
import com.mysema.query.annotations.QueryEntities;
The plugin execution in the Maven POM:
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<executions>
<execution>
<id>apt-maven-plugin-remote-module-QuerydslAnnotationProcessor</id>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources</outputDirectory>
<showWarnings>true</showWarnings>
<!-- genereate Q-classes specified in package-info.java -->
<processor>com.mysema.query.apt.QuerydslAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
</dependency>
</dependencies>
</plugin>