Mixed versions of JAXB? undefined attribute 'required'

Im creating some classes from WSDL files with wsimport maven @Mule Anypoint Studio 3.5 plugin with JDK 1.7_55

I am using jaxb 2.2.7 and uninstall version 2.1.9 from mule libs and replace it with 2.2.7.

When I compile, sometines works fine, but others accept this error several times:

The attribute required is undefined for the annotation type XmlElementRef 

I tried to create an approved folder in the JDK and enable .jars,

Do you know any way to avoid this error or replace these libraries correctly?

I include these 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 options:

 <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> 
+7
java java-7 jax-ws jaxb mule
source share
4 answers

We can fix the behavior described above by replacing the following banks in the Runtime Mule CE 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 helpful if the Mule developers updated these packages to the latest distributions.

+3
source share

The location of your approved cans is incorrect. It should be:

% JAVA_HOME% \ JRE \ Lib \ approved

which in your case:

C: \ Java \ jdk1.7.0_55 \ JRE \ Lib \ approved

Put jaxb jars here, delete all the others and try again.

+2
source share

In the specific case of Mule, if you are stuck in JAXB2.1, you can force Apache CXF WSDL2Java to generate JAXB2.1-compatible 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> 

key part

 <defaultOptions> <frontEnd>jaxws21</frontEnd> </defaultOptions> 
+1
source share

This is for anyone who finds this old post on search engines.

I was getting the same error message in a new project that I created in Eclipse. The solution was as follows:

 1.) create a new JAXB project instead of some other project type, 2.) specify JDK7, 3.) Specify version 2.2 of JAXB 
0
source share

All Articles