2

I'm trying to create a WebService with JAX-WS integrated with Spring 3.0.

I've tried to follow many examples that I found, but couldn't get any to work.

I have Maven dependencies, Spring tags, web.xml config, but I'm stuck with the following error when I start my Tomcat7.

Am I missing something? Am I doing something wrong?

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

Here is my WebService class:

@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;
    }

}

Configurations in 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>

Configurations in spring-contexto.xml:

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

<bean id="servicoTerceiroWS" class="br.com.gvt.slm.itsecurity.portalterceirosinterno.webservice.ServicoTerceiroWS"/>
nataliaoliveira
  • 73
  • 3
  • 15

2 Answers2

0

Your code looks like a Spring 2 web service. Have you tried the Spring 3 code as described on the example of Spring manual : http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/remoting.html#remoting-web-services-jaxws-export-servlet ?

gerrytan
  • 40,313
  • 9
  • 84
  • 99
  • I'm trying it now, and let you know the results. Thanks! – nataliaoliveira Jun 06 '13 at 13:25
  • Ok, I'm trying to do "Exporting standalone web services using JAX-WS". I did everything as the manual says, but I'm getting this error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter#0' defined in class path resource [contexto-spring/contexto-spring-geral.xml]: Invocation of init method failed; nested exception is [failed to localize] nestedModelerError(com.sun.xml.ws.util.localization.LocalizableMessage@19b9c4b) Can you help me with that? Looked for solutions but couldn't resolve this. – nataliaoliveira Jun 06 '13 at 14:12
0

you must put this code in spring-contexto.xml

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

Instead of

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