gpt4 book ai didi

web-services - 在 Grails CXF 服务中使用 @WebService 引发的异常

转载 作者:行者123 更新时间:2023-12-02 15:55:28 24 4
gpt4 key购买 nike

我正在尝试在 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 服务接口(interface),然后在您的服务类中实现它。

@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

关于web-services - 在 Grails CXF 服务中使用 @WebService 引发的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34087424/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com