Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JAXB混合版本?未定义';必需的';属性_Java_Jaxb_Jax Ws_Mule_Java 7 - Fatal编程技术网

Java JAXB混合版本?未定义';必需的';属性

Java JAXB混合版本?未定义';必需的';属性,java,jaxb,jax-ws,mule,java-7,Java,Jaxb,Jax Ws,Mule,Java 7,我使用wsimport maven plugin@Mule Anypoint Studio 3.5和JDK 1.755从WSDL文件生成一些类 我使用的是JAXB2.2.7,从mule libs中删除了2.1.9版,取而代之的是2.2.7版 当我编译时,有些代码可以正常工作,但有些代码会多次出现此错误: The attribute required is undefined for the annotation type XmlElementRef 我试图在JDK中创建一个认可的文件夹,

我使用wsimport maven plugin@Mule Anypoint Studio 3.5和JDK 1.755从WSDL文件生成一些类

我使用的是JAXB2.2.7,从mule libs中删除了2.1.9版,取而代之的是2.2.7版

当我编译时,有些代码可以正常工作,但有些代码会多次出现此错误:

The attribute required is undefined for the annotation type XmlElementRef   
我试图在JDK中创建一个认可的文件夹,并包含所需的.jars

您知道如何避免此错误或正确替换此LIB吗

我将此依赖项包括在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>       

com.sun.xml.ws
jaxws工具
2.2.7
com.sun.xml.bind
jaxb impl
2.2.7
com.sun.xml.bind
jaxbxjc
2.2.7
javax.xml.bind
jaxb api
2.2.7
org.codehaus.mojo
idlj maven插件
1.2.1
wsimport是2.2.7到

wsimport设置:

<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>

org.jvnet.jax-ws-commons
jaxws-maven插件
2.2.1
wsdl服务执行器
wsimport
-版本
-B-nv
-Xdebug
-B-XautoNameResolution
-森多塞德
真的
${basedir}/src/main/java
${basedir}/src/main/java
真的
${basedir}/src/main/resources/SICG/AMANSequenceService
AMANSequenceService.wsdl
${basedir}/src/main/resources/SICG/external/binding.xjb

您认可的罐子的位置不正确。应该是:

%JAVA\u HOME%\jre\lib\approved

在你的情况下,这是:

C:\Java\jdk1.7.0\u 55\jre\lib\annowed


将jaxb JAR放在此处,删除所有其他jars,然后重试。

我们可以通过替换Mule CE运行时文件夹中的以下jars来修复上述行为。(C:\AnypointStudio\plugins\org.Mule.tooling.server.3.5.0_3.5.0.201405141856\Mule\lib\opt):

jaxb-api-2.1jaxb-api-2.2.jar

jaxb-impl-2.1.9withjaxb-impl-2.2.7.jar

jaxb-xjc-2.1.9withjaxb-xjc-2.2.7.jar


如果Mule开发人员将这些软件包更新为最新发行版,这将非常有用。

这是为那些从搜索引擎中找到这篇旧文章的人准备的

我在Eclipse中创建的一个新项目中收到了相同的错误消息。解决办法是:

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

在Mule特定的情况下,如果您坚持使用JAXB2.1,可以强制Apache CXF WSDL2Java生成符合JAXB2.1的客户机代码

<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>

org.apache.cxf
cxf-codegen插件
3.1.6
生成-sources-file1
生成源
jaxws21
${project.build.directory}/generated/service-file1
${basedir}/src/main/resources/some.wsdl
类路径:some.wsdl
-客户
-冗长的
wsdl2java
关键部分是

<defaultOptions>
  <frontEnd>jaxws21</frontEnd>
</defaultOptions>

jaxws21

认可jar的路径是什么?C:\Java\jdk1.7.0_55\lib\annowed\jaxb-api-2.2.jar C:\Java\jdk1.7.0_55\lib\annowed\jaxb-impl-2.2.7.jar C:\Java\jdk1.7.0_55\lib\annowed\jaxb-xb-xjc-xjc-2.2.7.jar C:\AnypointStudio\plugins\org.mule.tooling.server.3.5.0_3.5.0.0.201851416\mule\endora\endoru知道如何重建DLA!