Announcement Announcement Module
Collapse
No announcement yet.
standalone JAX-WS and JDK6 HTTP server Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • standalone JAX-WS and JDK6 HTTP server

    Hi,

    I'm trying to expose a Web Service using JAX-WS.
    As my application must be light I want to use the JDK6's embedded HTTP server.

    I followed the Spring documentation and write a very simple sample, but it doesn't work

    Here is what i'm doing:

    Code:
    <context:annotation-config />
    
    <context:component-scan base-package="server.services" 
    
    <bean id="serverServiceExporter" class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
        <property name="baseAddress" value="http://localhost:8080/" />
    </bean>

    Code:
    package server.services;
    
    public interface ServerService {
        void test();
    }
    Code:
    package server.services;
    
    import javax.jws.WebMethod;
    import javax.jws.WebService;
    
    @WebService(serviceName = "ServerService")
    public class ServerServiceEndPoint {
        @WebMethod
        public void test() {
            System.err.println("Test");
        }
    }
    The I run a test and wait a moment.

    Code:
    @ContextConfiguration(
        locations =
            {
                "classpath:/server/server-remote.beans.xml"
            }
    )
    @RunWith(SpringJUnit4ClassRunner.class)
    public class ServerServiceTest
    {
        @Test
        public void testTest()
            throws IOException
        {
            try
            {
                Thread.sleep(60000);
            }
            catch (InterruptedException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    What I do not understand is that my browser ("http://localhost:8080/") displays nothing, it seems that the JDK6 HTTP server is not running.

    Why ???

    Is the HTTP server need to be started manually like that (it doesn't work anymore) ?
    Code:
    <bean id="httpServer" class="org.springframework.remoting.support.SimpleHttpServerFactoryBean">
        <property name="hostname" value="localhost" />
        <property name="port" value="8080" />
    </bean>
    I've also tried to declare my end point bean in my XML configuration file:
    Code:
    <bean id="serverServiceEndPoint" class="com.thales.imp.server.services.ServerServiceEndPoint" />
    Then I obtain this error :
    Code:
    Error creating bean with name 'serverServiceExporter' defined in class path resource [server/server-remote.beans.xml]: Initialization of bean failed; nested exception is com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class server.services.jaxws.Test is not found. Have you run APT to generate them?
    ...
    ...
    So, what am I doing wrong ?

    Thanks,

    Bouba

  • #2
    I too am experiencing this issue with a similar simple setup.

    Comment


    • #3
      SimpleHttpServerFactoryBean

      I believe you need to set the context map for the HttpServer. I have a similar setup but use a Hessian service instead of JAX-WS. In addition to the hostname and port properties, you'll need a "contexts" property. Something that looks like this:

      <property name="contexts">
      <map>
      <entry key="/myservice">
      <ref bean="hessian.service.myservice" />
      </entry>
      </map>
      </property>

      where "hessian.service.myservice" is the bean name to my "org.springframework.remoting.caucho.SimpleHessian ServiceExporter" bean. It looks like you may have some other JAX-WS bean issues, but that's at least how I got the HTTP server to bind to my service.

      Hope that helps,
      Gary

      Comment


      • #4
        Hi,

        In fact we abandoned the web services and expose our services using RMI instead.

        Hope your response will be useful for somebody else. :-)

        Thanks !

        Comment


        • #5
          Regardless of whether I use SimpleJaxWsServiceExporter or SimpleHttpServerJaxWsServiceExporter (>= 2.5.5) I get the same error when following the manual.

          applicationContext.xml:
          Code:
          <context:annotation-config />
          <bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
              <property name="baseAddress" value="URL here" />
          </bean>
          <bean id="webServiceEndpoint" class="test.WebServiceEndpoint" />
          Main.java:
          Code:
          package test;
          
          import org.springframework.context.ApplicationContext;
          import org.springframework.context.support.ClassPathXmlApplicationContext;
          
          public class Main {
          	private static final ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
          	public static void main(String[] args) {
          		System.out.println("Main reached");
          	}
          }
          WebServiceEndpoint.java:
          Code:
          package test;
          
          import javax.jws.WebMethod;
          import javax.jws.WebService;
          
          @WebService(serviceName = "WebServiceTest")
          public class WebServiceEndpoint {
          	@WebMethod
          	public String helloWorld() {
          		return "Hello World";
          	}
          }
          I get the following output:
          Code:
          Jul 9, 2008 11:02:28 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
          INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@8fce95: display name [org.springframework.context.support.ClassPathXmlApplicationContext@8fce95]; startup date [Wed Jul 09 11:02:28 CDT 2008]; root of context hierarchy
          Jul 9, 2008 11:02:28 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
          INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
          Jul 9, 2008 11:02:29 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
          INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@8fce95]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1a116c9
          Jul 9, 2008 11:02:29 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
          INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1a116c9: defining beans [org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter#0,webServiceEndpoint]; root of factory hierarchy
          Jul 9, 2008 11:02:29 AM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
          INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1a116c9: defining beans [org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter#0,webServiceEndpoint]; root of factory hierarchy
          java.lang.ExceptionInInitializerError
          Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter#0' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is Server Runtime Error: class: test.jaxws.HelloWorld could not be found
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1337)
          	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:221)
          	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:729)
          	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
          	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
          	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
          	at test.Main.<clinit>(Main.java:7)
          Caused by: Server Runtime Error: class: test.jaxws.HelloWorld could not be found
          	at com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(Unknown Source)
          	at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(Unknown Source)
          	at org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter.publishEndpoint(SimpleJaxWsServiceExporter.java:67)
          	at org.springframework.remoting.jaxws.AbstractJaxWsServiceExporter.publishEndpoints(AbstractJaxWsServiceExporter.java:125)
          	at org.springframework.remoting.jaxws.AbstractJaxWsServiceExporter.afterPropertiesSet(AbstractJaxWsServiceExporter.java:104)
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
          	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
          	... 15 more
          Caused by: class: test.jaxws.HelloWorld could not be found
          	at com.sun.xml.internal.ws.modeler.RuntimeModeler.getClass(Unknown Source)
          	at com.sun.xml.internal.ws.modeler.RuntimeModeler.processDocWrappedMethod(Unknown Source)
          	at com.sun.xml.internal.ws.modeler.RuntimeModeler.processMethod(Unknown Source)
          	at com.sun.xml.internal.ws.modeler.RuntimeModeler.processClass(Unknown Source)
          	at com.sun.xml.internal.ws.modeler.RuntimeModeler.buildRuntimeModel(Unknown Source)
          	at com.sun.xml.internal.ws.server.RuntimeEndpointInfo.createSEIModel(Unknown Source)
          	at com.sun.xml.internal.ws.server.RuntimeEndpointInfo.init(Unknown Source)
          	at com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(Unknown Source)
          	... 22 more
          Exception in thread "main"
          According to the documentation, this should work perfectly. It seems like there is an issue w/ the reflectionI need to use JAX-WS here. I will make it Hessian for the time being. Is there anything I am doing wrong or is this worthy of a JIRA issue? Is this a JDK6 issue w/ the Endpoint class? That's where my debugging stops.

          Comment


          • #6
            Found the issue. It is expecting it to be wrapped. So, either wrap it or do what I did and add the following annotation to your endpoint:

            @SOAPBinding(parameterStyle=ParameterStyle.BARE)

            Hope this helps someone...

            Comment


            • #7
              I'm trying to build some standalone web services using JAX-WS and the JDK 1.6 HTTP server. We are using JBoss as application server and I followed also the manual and I get the following error:

              Code:
              2009-07-27 15:16:50,282 INFO  [STDOUT] 15:16:50,266 ERROR [ContextLoader] 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.xml]: Invocation of init method failed; nested exception is com.sun.xml.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class de.idv.bpm.server.services.jaxws.Welcome is not found. Have you run APT to generate them?
              	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)

              Comment


              • #8
                Originally posted by cretz View Post
                Found the issue. It is expecting it to be wrapped. So, either wrap it or do what I did and add the following annotation to your endpoint:

                @SOAPBinding(parameterStyle=ParameterStyle.BARE)

                Hope this helps someone...
                Yes, thank you very much!
                Where did you get this information from?

                Ariald: I encountered the same exception and the code snippet provided by cretz solved it for me.

                Kind regards,
                CNail

                Comment


                • #9
                  Hi

                  I am using Web services in built in jdk 1.6 http server.
                  my services are working fine jboss 4.0.5.
                  But services are failing in jboss 4.2.3


                  org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.remoting.jaxws.SimpleJaxWsSer viceExporter#0' defined in class path resource [springservices.xml]: Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: Unsupported binding: null

                  I am getting error as :
                  17:55:44,735 ERROR [STDERR] Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.remoting.jaxws.SimpleJaxWsSer viceExporter#0' defined in class path resource [springservices.xml]: Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: Unsupported binding: null
                  17:55:44,735 ERROR [STDERR] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1338)
                  17:55:44,735 ERROR [STDERR] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:473)
                  17:55:44,735 ERROR [STDERR] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
                  17:55:44,735 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
                  17:55:44,735 ERROR [STDERR] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
                  17:55:44,735 ERROR [STDERR] at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
                  17:55:44,735 ERROR [STDERR] at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
                  17:55:44,735 ERROR [STDERR] at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
                  17:55:44,735 ERROR [STDERR] at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
                  17:55:44,735 ERROR [STDERR] at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
                  17:55:44,735 ERROR [STDERR] at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:429)
                  17:55:44,735 ERROR [STDERR] at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:728)
                  17:55:44,735 ERROR [STDERR] at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:380)
                  17:55:44,735 ERROR [STDERR] at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:139)
                  17:55:44,735 ERROR [STDERR] at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:83)
                  17:55:44,735 ERROR [STDERR] at com.wipro.base.factory.ServiceFactory.<clinit>(Ser viceFactory.java:8)
                  17:55:44,735 ERROR [STDERR] ... 138 more
                  17:55:44,735 ERROR [STDERR] Caused by: javax.xml.ws.WebServiceException: Unsupported binding: null
                  17:55:44,735 ERROR [STDERR] at org.jboss.ws.core.jaxws.binding.BindingProviderImp l.initBinding(BindingProviderImpl.java:83)
                  17:55:44,735 ERROR [STDERR] at org.jboss.ws.core.CommonBindingProvider.<init>(Com monBindingProvider.java:66)
                  17:55:44,735 ERROR [STDERR] at org.jboss.ws.core.jaxws.binding.BindingProviderImp l.<init>(BindingProviderImpl.java:61)
                  17:55:44,735 ERROR [STDERR] at org.jboss.ws.core.jaxws.spi.EndpointImpl.<init>(En dpointImpl.java:81)
                  17:55:44,735 ERROR [STDERR] at org.jboss.ws.core.jaxws.spi.ProviderImpl.createEnd point(ProviderImpl.java:71)
                  17:55:44,735 ERROR [STDERR] at javax.xml.ws.Endpoint.create(Endpoint.java:101)
                  17:55:44,735 ERROR [STDERR] at javax.xml.ws.Endpoint.create(Endpoint.java:80)
                  17:55:44,735 ERROR [STDERR] at org.springframework.remoting.jaxws.AbstractJaxWsSe rviceExporter.publishEndpoints(AbstractJaxWsServic eExporter.java:118)
                  17:55:44,735 ERROR [STDERR] at org.springframework.remoting.jaxws.AbstractJaxWsSe rviceExporter.afterPropertiesSet(AbstractJaxWsServ iceExporter.java:104)
                  17:55:44,735 ERROR [STDERR] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1369)
                  17:55:44,735 ERROR [STDERR] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1335)
                  17:55:44,735 ERROR [STDERR] ... 153 more


                  Can I have clarification on this

                  Comment


                  • #10
                    Hi

                    I want to whether web services developed by spring on jdk1.6 Http Server will work fine with Jboss 4.3 EAP server.


                    Thanks
                    Nagesh

                    Comment


                    • #11
                      well.. here is what I tried which worked on JBOSS-4.2.3

                      following is the list classes/config files that worked on JBOSS-4.2.3 and Spring3.

                      a. @Webservice annotation on top of the interface that you declare as endpointInterface. for example

                      @WebService
                      public interface TestServiceEndpoint {
                      @WebMethod
                      public String checkName(String name);
                      }

                      b. the service implementation class should look as follows
                      @WebService(serviceName="FirstEchoService", endpointInterface = "com.spring.TestServiceEndpoint")
                      public class TestServiceEndpointImpl implements TestServiceEndpoint{

                      @WebMethod
                      public String checkName(String name) {
                      return "Hi, " + name + " welcome to your first Web service";
                      }

                      }

                      c. inside your spring-context.xml write following tag for binding
                      <bean class="org.springframework.remoting.jaxws.SimpleJa xWsServiceExporter">
                      <property name="baseAddress" value="http://localhost:8080/" />
                      <property name="bindingType" value="http://schemas.xmlsoap.org/wsdl/soap/http" />
                      </bean>

                      d. web .xml

                      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
                      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
                      id="WebApp_ID" version="2.5">
                      <display-name>Experian Web service</display-name>
                      <description>Simple Spring based Web service Application</description>

                      <context-param>
                      <param-name>contextConfigLocation</param-name>
                      <param-value>/WEB-INF/wasp-spring-context.xml</param-value>
                      </context-param>

                      <listener>
                      <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
                      </listener>

                      <servlet>
                      <servlet-name>spring-webservice</servlet-name>
                      <servlet-class>
                      org.springframework.ws.transport.http.MessageDispa tcherServlet</servlet-class>
                      </servlet>

                      <servlet-mapping>
                      <servlet-name>spring-webservice</servlet-name>
                      <url-pattern>/*</url-pattern>
                      </servlet-mapping>

                      <session-config>
                      <session-timeout>50</session-timeout>
                      </session-config>

                      </web-app>

                      e. do not forget to add following JARs of spring in $JBOSS-HOME$->server->default->lib folder

                      org.springframework.asm-3.0.4.RELEASE.jar
                      org.springframework.beans-3.0.4.RELEASE.jar
                      org.springframework.context-3.0.4.RELEASE.jar
                      org.springframework.context.support-3.0.4.RELEASE.jar
                      org.springframework.core-3.0.4.RELEASE.jar
                      org.springframework.expression-3.0.4.RELEASE.jar
                      org.springframework.web-3.0.4.RELEASE.jar

                      Comment

                      Working...
                      X