2013-06-05 51 views
2

我想创建一个与Spring 3.0集成的JAX-WS的WebService。WebService Spring错误(JAX-WS与Spring 3.0)

我试着按照我发现的很多例子,但没有得到任何工作。

我有Maven的依赖关系,Spring标签,web.xml配置,但当我启动我的Tomcat7时遇到以下错误。

我错过了什么吗?难道我做错了什么?

SEVERE: Exception sending context initialized event to listener instance of class o 

rg.springframework.web.context.ContextLoaderListener 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.sun.xml.ws.transport.http.servlet.SpringBinding#0' defined in class path resource [contexto-spring/contexto-spring-geral.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'br.com.gvt.slm.itsecurity.portalterceirosinterno.webservice.ServicoTerceiroWS' to required type 'com.sun.xml.ws.api.server.WSEndpoint' for property 'service'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [br.com.gvt.slm.itsecurity.portalterceirosinterno.webservice.ServicoTerceiroWS] to required type [com.sun.xml.ws.api.server.WSEndpoint] for property 'service': no matching editors or conversion strategy found 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469) 
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) 
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) 
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) 
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895) 
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871) 
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615) 
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:649) 
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1581) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) 
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'br.com.gvt.slm.itsecurity.portalterceirosinterno.webservice.ServicoTerceiroWS' to required type 'com.sun.xml.ws.api.server.WSEndpoint' for property 'service'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [br.com.gvt.slm.itsecurity.portalterceirosinterno.webservice.ServicoTerceiroWS] to required type [com.sun.xml.ws.api.server.WSEndpoint] for property 'service': no matching editors or conversion strategy found 
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485) 
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516) 
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:510) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1406) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1365) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) 
    ... 25 more 
Caused by: java.lang.IllegalStateException: Cannot convert value of type [br.com.gvt.slm.itsecurity.portalterceirosinterno.webservice.ServicoTerceiroWS] to required type [com.sun.xml.ws.api.server.WSEndpoint] for property 'service': no matching editors or conversion strategy found 
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:241) 
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470) 
    ... 31 more 

这里是我的WebService类:

@WebService 
public class ServicoTerceiroWS extends SpringBeanAutowiringSupport { 

    @Autowired 
    private IControladorUsuario controladorUsuario; 

    @WebMethod 
    public boolean verificarCodigoSeguranca(String matricula, String codigoEnviado) throws NegocioException { 
     try { 
      boolean valido = false; 
      String codigoBanco = controladorUsuario.obterCodigoPorUsuario(matricula); 
      if (codigoBanco.equals(codigoEnviado)) { 
       valido = true; 
      } 
      return valido; 
     } catch (Exception e) { 
      throw new NegocioException(e); 
     } 
    } 

    public IControladorUsuario getControladorUsuario() { 
     return controladorUsuario; 
    } 

    public void setControladorUsuario(IControladorUsuario controladorUsuario) { 
     this.controladorUsuario = controladorUsuario; 
    } 

} 

配置在web.xml:

<servlet> 
    <servlet-name>jaxws-servlet</servlet-name> 
    <servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>jaxws-servlet</servlet-name> 
    <url-pattern>/webservice</url-pattern> 
    </servlet-mapping> 

配置在弹簧contexto.xml:

<wss:binding url="/webservice" service="#servicoTerceiroWS" /> 

<bean id="servicoTerceiroWS" class="br.com.gvt.slm.itsecurity.portalterceirosinterno.webservice.ServicoTerceiroWS"/> 

回答

0

您的代码看起来像一个Spring 2 Web服务。您是否按照Spring手册的示例中所述尝试了Spring 3代码:http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/remoting.html#remoting-web-services-jaxws-export-servlet

+0

我现在尝试,并让你知道结果。谢谢! – nataliaoliveira

+0

好吧,我正在尝试“使用JAX-WS导出独立的Web服务”。我做了所有的手册说,但我得到这个错误: org.springframework.beans.factory.BeanCreationException:在类路径资源中定义名称'org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter#0'创建bean时出错[contexto-spring/contexto-spring-geral.xml]:调用init方法失败;嵌套的异常是[失败本地化] nestedModelerError([email protected]) 你能帮我吗?寻找解决方案,但无法解决这个问题。 – nataliaoliveira

0

你必须把这个代码在弹簧contexto.xml

<wss:binding url="/webservice"> 
    <wss:service> 
     <ws:service bean="#servicoTerceiroWS" /> 
    </wss:service> 
    </wss:binding> 

而不是

<wss:binding url="/webservice" service="#servicoTerceiroWS" />