Announcement Announcement Module
Collapse
No announcement yet.
problems with web services Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problems with web services

    Hello I'm trying my first web app with spring jax-ws

    I've written this simple code:

    web.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    
        <display-name>Archetype Created Web Application</display-name>
    
        <servlet>
            <servlet-name>spring-ws</servlet-name>
            <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>spring-ws</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
    
    </web-app>
    spring-ws-servlet.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    
        <bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
            <property name="baseAddress" value="http://localhost:8080/"/>
        </bean>
    
    
        <bean id="echoService" class="it.wingstech.gam3.webserver.EchoServiceImpl">
    
        </bean>
    
        <bean id="echoServiceEndpoint" class="it.wingstech.gam3.webserver.EchoServiceEndpoint">
    
        </bean>
    
        
    </beans>
    EchoServiceEndpoint.java
    Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    package it.wingstech.gam3.webserver;
    
    import javax.jws.WebMethod;
    import javax.jws.WebService;
    import javax.jws.soap.SOAPBinding;
    import org.springframework.beans.factory.annotation.Autowired;
    
    /**
     *
     * @author kiuma
     */
    @WebService(serviceName="echoService")
    @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)
    public class EchoServiceEndpoint implements EchoService {
        @Autowired
        private EchoService echoService;
    
        @WebMethod
        @Override
        public String echo(String value)
        {
            return echoService.echo(value);
        }
    }
    Now my problems are the following:
    First it works only with jboss, If I try to run the servlet from Tomcat I have the following exception:
    http://localhost:8080/webserver/echoService?wsdl
    Code:
    avax.servlet.ServletException: Servlet.init() for servlet spring-ws threw exception
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    	java.lang.Thread.run(Thread.java:619)
    
    root cause
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter#0' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is com.sun.xml.internal.ws.server.ServerRtException: Server Runtime Error: java.net.BindException: Address already in use
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	java.security.AccessController.doPrivileged(Native Method)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    	java.lang.Thread.run(Thread.java:619)
    
    root cause
    
    com.sun.xml.internal.ws.server.ServerRtException: Server Runtime Error: java.net.BindException: Address already in use
    	com.sun.xml.internal.ws.transport.http.server.ServerMgr.createContext(ServerMgr.java:97)
    	com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:64)
    	com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:139)
    	org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter.publishEndpoint(SimpleJaxWsServiceExporter.java:67)
    Why can't I run it in tomcat ?

    Then when run the code under jboss the web service wsdl is under this link:
    http://localhost:8080/echoService?wsdl

    Shouldn't it be
    http://localhost:8080/webserver/echoService?wsdl
    (being my servlet name webserver.war) ?

    then:
    I'd like the web service be under the following link:
    http://localhost:8080/ws/echoService?wsdl
    or
    http://localhost:8080/webserver/ws/echoService?wsdl

    but if I try to change
    <property name="baseAddress" value="http://localhost:8080/"/>
    to
    <property name="baseAddress" value="http://localhost:8080/ws/"/>
    it doesn't work, because I have the echo service wsdl under
    http://localhost:8080/ws?wsdl

    Please help! I've tried on #spring irc channel, but without any reply.

    Thanks in advance,
    kiuma

  • #2
    I've been through a lot of hoops with spring-ws and jax, but to be honest I recognize almost none of the stuff you posted. The web.xml looks like it's on the right track, but I'm really not sure about the rest. None the less, I'll make an attempt at solving your problem and I'll provide some examples you can look at if you like.

    The thing I noticed is you want your service to be located at "http://localhost:8080/webserver/ws/echoService?wsdl" but you've listed your serlet-mapping url-pattern as "/*". By default, the MessageDispatcherServlet will listen to requests being sent to "http://server-ip:server-port/war-name/url-pattern". I suggest changing your url-pattern to "/ws/*" if you want to use "http://localhost:8080/webserver/ws/echoService?wsdl".

    I know this does very little to help your overall problem, but maybe it's a start. Check the attached to see how I implemented a echoWS using spring-ws and jaxb

    Comment


    • #3
      undertood some piecs, but now I'm not able to run on jboss

      This morning I've understood some pieces:
      Here it is the code


      The servlet class i not so important, infact the SimpleJaxWsServiceExporter
      creates a new server:

      <bean class="org.springframework.remoting.jaxws.SimpleJa xWsServiceExporter">
      <property name="baseAddress" value="http://localhost:9999/ws/"/>
      </bean>

      this will make my echoService wsdl be available at
      http://localhost:9999/ws/echoService?wsdl

      now this works well under jetty, tomcat, glassfish v2., glassfish v3 (the ones provided with netbeans 6.5.1)

      Problems arise when I try to run the webapp under jboss because the server throws this message:
      Code:
      08:50:13,465 ERROR [MessageDispatcherServlet] Context initialization failed
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter#0' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Endpoint already registered: jboss.ws:context=ws,endpoint=EchoServiceEndpoint
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
              at java.security.AccessController.doPrivileged(Native Method)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
              at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
              at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
              at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
              at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
              at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
              at javax.servlet.GenericServlet.init(GenericServlet.java:212)
              at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
              at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
              at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4071)
              at org.apache.catalina.core.StandardContext.start(StandardContext.java:4375)
      Any idea how to run it under jboss ?

      Thanks in advance,
      kiuma

      Comment


      • #4
        a precisation about jboss

        the jboss ws console gives this reply:

        http://localhost:8080/jbossws/services

        Registered Service Endpoints
        Endpoint Name jboss.ws:context=ws,endpoint=EchoServiceEndpoint
        Endpoint Address http://127.0.0.1:8080/ws?wsdl

        Comment

        Working...
        X