【问题标题】:Exception thrown using @WebService in Grails CXF service在 Grails CXF 服务中使用 @WebService 引发的异常
【发布时间】:2016-02-02 02:40:04
【问题描述】:

我正在尝试在 Grails 中使用 CFX 生成 Web 服务。

我已将 compile ":cxf:2.1.1" 添加到 BuildConfig.groovy 并创建了一个服务:

package servicetest

import grails.transaction.Transactional
import javax.jws.*;
import org.grails.cxf.utils.EndpointType

@Transactional
class TestService {

    static expose = EndpointType.JAX_WS

    @WebMethod( operationName="createUpdateUser" )
    @WebResult( name="result" )   
    def serviceMethod() {

    }
}

这工作正常。但是,我想更改生成的 WSDL 中的目标命名空间。为此,我添加了@WebService:

package servicetest

import grails.transaction.Transactional
import javax.jws.*;
import org.grails.cxf.utils.EndpointType

@Transactional
@WebService(name = 'CustomerServiceWsdlEndpoint',
    targetNamespace = 'http://test.cxf.grails.org/',
    serviceName = 'CustomerServiceWsdlEndpoint',
    portName = 'CustomerServiceWsdlPort')
class TestService {

    static expose = EndpointType.JAX_WS

    @WebMethod( operationName="createUpdateUser" )
    @WebResult( name="result" )   
    def serviceMethod() {

    }
}

但是,当我启动 Grails 应用程序时,我收到以下错误消息:

|Running Grails application
Error |
2015-12-04 11:21:07,506 [localhost-startStop-1] ERROR [localhost].[/ServiceTest]  - StandardWrapper.Throwable
Message: Error creating bean with name 'testServiceBean': Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.apache.cxf.endpoint.Server org.apache.cxf.jaxws.JaxWsServerFactoryBean.create()] threw exception; nested exception is org.apache.cxf.service.factory.ServiceConstructionException
    Line | Method
->>  593 | createApplicationContext in grails.spring.BeanBuilder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     53 | loadAdditionalConfig     in org.grails.cxf.servlet.GrailsCxfServlet
|     25 | init . . . . . . . . . . in     ''
|    262 | run                      in java.util.concurrent.FutureTask
|   1145 | runWorker . . . . . . .  in java.util.concurrent.ThreadPoolExecutor
|    615 | run                      in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run . . . . . . . . . .  in java.lang.Thread
Caused by BeanDefinitionStoreException: Factory method [public org.apache.cxf.endpoint.Server org.apache.cxf.jaxws.JaxWsServerFactoryBean.create()] threw exception; nested exception is org.apache.cxf.service.factory.ServiceConstructionException
->>  593 | createApplicationContext in grails.spring.BeanBuilder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     53 | loadAdditionalConfig     in org.grails.cxf.servlet.GrailsCxfServlet
|     25 | init . . . . . . . . . . in     ''
|    262 | run                      in java.util.concurrent.FutureTask
|   1145 | runWorker . . . . . . .  in java.util.concurrent.ThreadPoolExecutor
|    615 | run                      in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run . . . . . . . . . .  in java.lang.Thread
Caused by ServiceConstructionException: null
->>  336 | initialize               in org.apache.cxf.jaxb.JAXBDataBinding
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     86 | initializeDataBindings   in org.apache.cxf.service.factory.AbstractServiceFactoryBean
|    467 | buildServiceFromClass .  in org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean
|    712 | buildServiceFromClass    in org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean
|    527 | initializeServiceModel . in org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean
|    261 | create                   in     ''
|    215 | create . . . . . . . . . in org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean
|    102 | createEndpoint           in org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory
|    159 | create . . . . . . . . . in org.apache.cxf.frontend.ServerFactoryBean
|    211 | create                   in org.apache.cxf.jaxws.JaxWsServerFactoryBean
|    593 | createApplicationContext in grails.spring.BeanBuilder
|     53 | loadAdditionalConfig     in org.grails.cxf.servlet.GrailsCxfServlet
|     25 | init . . . . . . . . . . in     ''
|    262 | run                      in java.util.concurrent.FutureTask
|   1145 | runWorker . . . . . . .  in java.util.concurrent.ThreadPoolExecutor
|    615 | run                      in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run . . . . . . . . . .  in java.lang.Thread
Caused by IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
->>  106 | check                    in com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    460 | getTypeInfoSet           in com.sun.xml.bind.v2.runtime.JAXBContextImpl
|    292 | <init> . . . . . . . . . in     ''
|    139 | <init>                   in     ''
|   1138 | build . . . . . . . . .  in com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder
|    162 | createContext            in com.sun.xml.bind.v2.ContextFactory
|    248 | newInstance . . . . . .  in javax.xml.bind.ContextFinder
|    235 | newInstance              in     ''
|    432 | find . . . . . . . . . . in     ''
|    637 | newInstance              in javax.xml.bind.JAXBContext
|    347 | run . . . . . . . . . .  in org.apache.cxf.common.jaxb.JAXBContextCache$2
|    345 | run                      in     ''
|    246 | getCachedContextAndSchemas in org.apache.cxf.common.jaxb.JAXBContextCache
|    479 | createJAXBContextAndSchemas in org.apache.cxf.jaxb.JAXBDataBinding
|    334 | initialize . . . . . . . in     ''
|     86 | initializeDataBindings   in org.apache.cxf.service.factory.AbstractServiceFactoryBean
|    467 | buildServiceFromClass .  in org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean
|    712 | buildServiceFromClass    in org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean
|    527 | initializeServiceModel . in org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean
|    261 | create                   in     ''
|    215 | create . . . . . . . . . in org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean
|    102 | createEndpoint           in org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory
|    159 | create . . . . . . . . . in org.apache.cxf.frontend.ServerFactoryBean
|    211 | create                   in org.apache.cxf.jaxws.JaxWsServerFactoryBean
|    593 | createApplicationContext in grails.spring.BeanBuilder
|     53 | loadAdditionalConfig     in org.grails.cxf.servlet.GrailsCxfServlet
|     25 | init . . . . . . . . . . in     ''
|    262 | run                      in java.util.concurrent.FutureTask
|   1145 | runWorker . . . . . . .  in java.util.concurrent.ThreadPoolExecutor
|    615 | run                      in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run . . . . . . . . . .  in java.lang.Thread
Error |
2015-12-04 11:21:07,595 [localhost-startStop-1] ERROR [localhost].[/ServiceTest]  - Servlet /ServiceTest threw load() exception
Message: 1 counts of IllegalAnnotationExceptions
    Line | Method
->>  106 | check                       in com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    460 | getTypeInfoSet              in com.sun.xml.bind.v2.runtime.JAXBContextImpl
|    292 | <init> . . . . . . . . . .  in     ''
|    139 | <init>                      in     ''
|   1138 | build . . . . . . . . . . . in com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder
|    162 | createContext               in com.sun.xml.bind.v2.ContextFactory
|    248 | newInstance . . . . . . . . in javax.xml.bind.ContextFinder
|    235 | newInstance                 in     ''
|    432 | find . . . . . . . . . . .  in     ''
|    637 | newInstance                 in javax.xml.bind.JAXBContext
|    347 | run . . . . . . . . . . . . in org.apache.cxf.common.jaxb.JAXBContextCache$2
|    345 | run                         in     ''
|    246 | getCachedContextAndSchemas  in org.apache.cxf.common.jaxb.JAXBContextCache
|    479 | createJAXBContextAndSchemas in org.apache.cxf.jaxb.JAXBDataBinding
|    334 | initialize . . . . . . . .  in     ''
|     86 | initializeDataBindings      in org.apache.cxf.service.factory.AbstractServiceFactoryBean
|    467 | buildServiceFromClass . . . in org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean
|    712 | buildServiceFromClass       in org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean
|    527 | initializeServiceModel . .  in org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean
|    261 | create                      in     ''
|    215 | create . . . . . . . . . .  in org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean
|    102 | createEndpoint              in org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory
|    159 | create . . . . . . . . . .  in org.apache.cxf.frontend.ServerFactoryBean
|    211 | create                      in org.apache.cxf.jaxws.JaxWsServerFactoryBean
|    593 | createApplicationContext .  in grails.spring.BeanBuilder
|     53 | loadAdditionalConfig        in org.grails.cxf.servlet.GrailsCxfServlet
|     25 | init . . . . . . . . . . .  in     ''
|    262 | run                         in java.util.concurrent.FutureTask
|   1145 | runWorker . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
|    615 | run                         in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run . . . . . . . . . . . . in java.lang.Thread

谁能告诉我我做错了什么,或者是否有另一种方法来设置目标命名空间?

谢谢,

卡尔

【问题讨论】:

    标签: web-services grails cxf


    【解决方案1】:

    要解决问题,您需要创建一个作为 Web 服务的接口,然后在您的服务类中实现它。

    @WebService
    interface TestServiceInterface {
    
      def serviceMethod() 
    }
    
    
    
    @WebService(name = 'CustomerServiceWsdlEndpoint',
              targetNamespace = 'http://test.cxf.grails.org/',
              serviceName = 'CustomerServiceWsdlEndpoint',
              portName = 'CustomerServiceWsdlPort')
    class TestService implements TestServiceInterface {
    
    static expose = EndpointType.JAX_WS
    
    @WebMethod( operationName="createUpdateUser" )
    @WebResult( name="result" )   
     def serviceMethod() {
     }
    }
    

    欲了解更多信息,请转到link

    【讨论】:

      猜你喜欢
      • 2013-09-22
      • 1970-01-01
      • 2016-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多