spring - 当我添加对其他 bean 的引用时,为什么 Apache CXF 会抛出 IllegalAnnotationsException?

标签 spring web-services grails cxf jax-ws

我有 2 个 Web 服务类,我打算使用 Apache CXF 将它们公开为 SOAP 服务。其中一项服务将另一项服务作为其运营的一部分。我已经在我的 Grails 应用程序中设置了 Apache CXF(没有插件),并通过 resources.groovy 设置了我的 Web 服务(Spring Bean DSL)。

假设我有以下类(class):

@WebService
BookService {
    //class definition
}

和:
@WebService
LibraryService {
    BookService bookService
    //class definition
}

我在我的 resources.groovy 中声明它们如下(省略命名空间声明):
bookService(BookService)
jaxws.endpoint(id: 'bookService', implementor: "#bookService", 
        address: '/book')

libraryService(LibraryService) {
    bookService = ref('bookService')
}
jaxws.endpoint(id: 'libraryService', implementor: "#libraryService", 
        address: '/library')

但是,每次我运行我的应用程序(通过 grails run-app )我都会得到 IllegalAnnotationsException :
Caused by IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
->> 106 | check    in com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder

我不明白它为什么会发生。我是 Apache CXF 的新手,所以我希望有人能启发我。

更新:
我发现 CXF 会为我在服务类中声明的任何私有(private)字段抛出异常,除非它们是用 @XmlRootElement 注释的类型。 .这很奇怪。

最佳答案

为了解决这个问题,我所做的是 define a service endpoint interfaces (SEIs) ,对于我的服务,它们几乎只是 Java/Groovy 接口(interface)。我不确定问题是由于 Groovy 在后台添加的功能,还是 CXF 的 JAX-WS 实现或规范本身确实存在问题,但即使在将我的服务转换为 Java 之后,我仍然得到错误。

因此,LibraryService特别是现在看起来像:

@WebService
interface LibraryService {
    //class definition
}

以及具体实现:
@WebService
class LibraryServiceImpl implements LibraryService {
    BookService bookService
    //class definition
}

和bean定义:
libraryService(LibraryServiceImpl) {
    bookService = ref('bookService')
}
jaxws.endpoint(id: 'libraryService', implementor: "#libraryService", 
        address: '/library')

关于spring - 当我添加对其他 bean 的引用时,为什么 Apache CXF 会抛出 IllegalAnnotationsException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29160128/

相关文章:

java - 我无法在 Mysql 数据库中存储 .doc 简历

java - Spring : How to inject wsdlLocation in @WebServiceRef

ajax - 将在下拉列表中选择的值发布到 Controller

http - 使用 Grails 的简单 GET

spring - “没有端点适配器”异常 - 带有 spring-boot 和 spring-ws 的 apache-camel

java - Spring MVC JSP 应用程序的 WAR 目录结构?

java - 是否可以将 Spring MVC 与 Jersey 注解一起使用?

java - WebService代理类

java - 将Web服务集成到Java中

hibernate - grails hasOne但不属于