Maven 使用 JAX-WS 2.1 而不是 JAX-WS 2.2

发布于 2024-11-27 18:07:07 字数 3003 浏览 1 评论 0原文

我将 Netbeans 7 与 Maven 2.2.1 和 jaxws-maven-plugin 1.12 一起使用。代码部署在 Glassfish 3.1 上 - 或者当我编译它时就会部署:)

当我构建项目时,wsimport 按预期运行并从提供的 WSDL 生成源文件。问题是构建在编译阶段失败,并出现以下三个异常。通过研究,我发现这些构造函数是从 JAX-WS 2.1 添加到 JAX-WS 2.2 的。我相信 wsimport 使用 JAX-WS 2.1,编译使用 JAX-WS 2.2。

有人可以证实我的怀疑吗?或者,如果我错了,您可能知道是什么原因造成的吗?

谢谢。


问题的更新/澄清 Web 服务客户端扩展了 javax.xml.ws.Service,并且当客户端尝试使用三个参数调用超类构造函数时会引发错误。由于超类没有任何带有三个参数的构造函数,因此它会失败。

在 JDK SE 1.6 和 JAX-WS 2.1 中发现 javax.xml.ws.Service 版本错误。

javax.xml.ws.Service 在 JAX-WS 2.2 中被发现是正确的版本。


该错误发生了三次,因为它位于三个重写的构造函数中,但它是相同的错误,所以我只包含它一次。

cannot find symbol
symbol  : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
location: class javax.xml.ws.Service


<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>1.12</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <wsdlFiles>
                            <wsdlFile>*path to WSDL*</wsdlFile>
                        </wsdlFiles>
                        <wsdlLocation>*url to WSDL*</wsdlLocation>
                        <staleFile>${project.build.directory}/jaxws/stale/BudgetCheckingServiceService.stale</staleFile>
                    </configuration>
                    <id>wsimport-generate-BudgetCheckingServiceService</id>
                    <phase>generate-sources</phase>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.sun.xml.ws</groupId>
                    <artifactId>jaxws-tools</artifactId>
                    <version>2.2.6-SNAPSHOT</version>                            
                </dependency>

                <dependency>
                    <groupId>javax.xml</groupId>
                    <artifactId>webservices-api</artifactId>
                    <version>1.4</version>
                </dependency>
            </dependencies>
            <configuration>                    
                <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
                <xnocompile>true</xnocompile>
                <verbose>true</verbose>
                <extension>true</extension>
                <catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
            </configuration>
        </plugin>

I am using Netbeans 7 with Maven 2.2.1 and jaxws-maven-plugin 1.12. Code is deployed on Glassfish 3.1 - or will be when I get it to compile :)

When I build the project, the wsimport runs as expected and generates the source files from the WSDL provided. The problem is that the build fails during the compile phase with the following three exceptions. From researching this, I see that these constructors were added from JAX-WS 2.1 to JAX-WS 2.2. My belief is that the wsimport is using JAX-WS 2.1 and the compile is using JAX-WS 2.2.

Can someone confirm my suspicion? Or, if I'm wrong, might you have an idea what may be causing this?

Thank you.


UPDATED/CLARIFICATION OF PROBLEM
The Web service client extends javax.xml.ws.Service and the error is thrown when the client tries to call the super class constructor with three arguments. Since the super class doesn't have any constructor with three arguments, it fails.

javax.xml.ws.Service is found in JDK SE 1.6 and JAX-WS 2.1 as the wrong version.

javax.xml.ws.Service is found in JAX-WS 2.2 as the correct version.


The error occurs three times since it is in three overridden constructors but it's the same error so I've included it only once.

cannot find symbol
symbol  : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
location: class javax.xml.ws.Service


<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>1.12</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <wsdlFiles>
                            <wsdlFile>*path to WSDL*</wsdlFile>
                        </wsdlFiles>
                        <wsdlLocation>*url to WSDL*</wsdlLocation>
                        <staleFile>${project.build.directory}/jaxws/stale/BudgetCheckingServiceService.stale</staleFile>
                    </configuration>
                    <id>wsimport-generate-BudgetCheckingServiceService</id>
                    <phase>generate-sources</phase>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.sun.xml.ws</groupId>
                    <artifactId>jaxws-tools</artifactId>
                    <version>2.2.6-SNAPSHOT</version>                            
                </dependency>

                <dependency>
                    <groupId>javax.xml</groupId>
                    <artifactId>webservices-api</artifactId>
                    <version>1.4</version>
                </dependency>
            </dependencies>
            <configuration>                    
                <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
                <xnocompile>true</xnocompile>
                <verbose>true</verbose>
                <extension>true</extension>
                <catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
            </configuration>
        </plugin>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挖鼻大婶 2024-12-04 18:07:07

正如您在 jaxws-maven-plugin-1.12的pom,它有依赖jaxws-tools-2.1.7。好吧,你已经通过 pom 覆盖了它。但是,只要覆盖版本 (2.2.6-SNAPSHOT) 与插件的默认版本 (2.1.7) api 兼容,这种覆盖就有效。

显然,根据您的评论,它们与 api 不兼容。所以,据我所知,这是行不通的。 这里'参考以下内容。

使用 -X 标志运行 mvn install 以确定此插件使用的 jaxws-tools 的确切版本。如果你不介意的话,做一个pastebin,我们也可以看看!

编辑:你可以做的一件事是;将 maven-jaxws-plugin 的 jaxws-tools dep 升级到您所需的版本。然后修复由于 api 不兼容而出现的问题(例如构造函数问题)。然后将补丁发送到 上游

As you can see in the jaxws-maven-plugin-1.12's pom, it has the dependency jaxws-tools-2.1.7. Well, you have over-ridden it via the pom. But, this over-riding works as long as the over-rode version (2.2.6-SNAPSHOT) is api-compatible with the plugin's default version (2.1.7).

Clearly, based on your remarks, they are not api-compatible. So, as I see this won't work. Here's a reference to follow.

Run mvn install with -X flag to determine the exact version of the jaxws-tools is used by this plugin. Do a pastebin if you don't mind, then we can have a look too!

EDIT: One thing you can do is; upgrade the maven-jaxws-plugin's jaxws-tools dep to the needed version of yours. And, then fix the issues occur due to api-incompatibility (such as constructor problems.) Then send a patch to the upstream.

不奢求什么 2024-12-04 18:07:07

我遇到了类似的问题,通过将文件 webservices-api.jar 放入我的 %JDK_HOME%/jre/lib/endorsed 文件夹中解决了这个问题。

I had a similar problem and it was solved by putting the file webservices-api.jar in my %JDK_HOME%/jre/lib/endorsed folder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文