2 Replies Latest reply on Jan 9, 2007 6:34 AM by Thomas Diesler

    Problem deploying a simple web service

    Marco Sigismondi Newbie

      I'm studying web services, and I developed this simple one:

      WebServiceBean.java

      /**
       * @ejb.bean
       * name="WebService"
       * jndi-name="ejb/publishingsystem/dipartimento/WebService"
       * type = "Stateless"
       * display-name = "WebService"
       * description = "WebService Session EJB"
       * view-type="service-endpoint"
       *
       * @ejb.interface
       * service-endpoint-class="publishingsystem.dipartimento.interfaces.WebServiceEndpoint"
       *
       * @wsee.port-component
       * name="WebServiceEndpointPort"
       *
       */
      public class WebServiceBean implements SessionBean {
       private Dipartimento dip;
      
       /**
       * Hello world business interface method.
       *
       * @ejb.interface-method view-type = "service-endpoint"
       */
       public java.lang.String sayHello(String name)
       {
       return("Hello " + name);
       }
      
      
       public WebServiceBean() { super(); }
      
       public void setSessionContext(SessionContext ctx)
       throws EJBException, RemoteException {}
      
       public void ejbRemove() throws EJBException, RemoteException {}
       public void ejbActivate() throws EJBException, RemoteException {}
       public void ejbPassivate() throws EJBException, RemoteException {}
      
       /**
       * Default create method
       *
       * @throws CreateException
       * @ejb.create-method
       */
       public void ejbCreate() throws CreateException {}
      
      }
      


      I used wstools with this configuration file:

      <configuration xmlns="http://www.jboss.org/jbossws-tools">
       <java-wsdl>
       <service name="WebService" style="rpc" endpoint="publishingsystem.dipartimento.interfaces.WebServiceEndpoint"/>
       <namespaces target-namespace="http://www.unibo.it/dip"
       type-namespace="http://www.unibo.it/dip/types"/>
       <mapping file="jaxrpc-mapping.xml"/>
       <webservices ejb-link="WebServiceBean"/>
       </java-wsdl>
      </configuration>
      


      ...and I obtained the following files:

      WebService.wsdl
      <?xml version="1.0" encoding="UTF-8"?>
      <definitions name='WebService' targetNamespace='http://www.unibo.it/dip' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://www.unibo.it/dip' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
       <types/>
       <message name='WebServiceEndpoint_sayHello'>
       <part name='String_1' type='xsd:string'/>
       </message>
       <message name='WebServiceEndpoint_sayHelloResponse'>
       <part name='result' type='xsd:string'/>
       </message>
       <portType name='WebServiceEndpoint'>
       <operation name='sayHello' parameterOrder='String_1'>
       <input message='tns:WebServiceEndpoint_sayHello'/>
       <output message='tns:WebServiceEndpoint_sayHelloResponse'/>
       </operation>
       </portType>
       <binding name='WebServiceEndpointBinding' type='tns:WebServiceEndpoint'>
       <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
       <operation name='sayHello'>
       <soap:operation soapAction=''/>
       <input>
       <soap:body namespace='http://www.unibo.it/dip' use='literal'/>
       </input>
       <output>
       <soap:body namespace='http://www.unibo.it/dip' use='literal'/>
       </output>
       </operation>
       </binding>
       <service name='WebService'>
       <port binding='tns:WebServiceEndpointBinding' name='WebServiceEndpointPort'>
       <soap:address location='REPLACE_WITH_ACTUAL_URL'/>
       </port>
       </service>
      </definitions>


      webservices.xml
      <webservices version='1.1' xmlns='http://java.sun.com/xml/ns/j2ee' xmlns:impl='http://www.unibo.it/dip' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd'>
       <webservice-description>
       <webservice-description-name>WebService</webservice-description-name>
       <wsdl-file>META-INF/wsdl/WebService.wsdl</wsdl-file>
       <jaxrpc-mapping-file>META-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
       <port-component>
       <port-component-name>WebServiceEndpointPort</port-component-name>
       <wsdl-port>impl:WebServiceEndpointPort</wsdl-port>
       <service-endpoint-interface>publishingsystem.dipartimento.interfaces.WebServiceEndpoint</service-endpoint-interface>
       <service-impl-bean>
       <ejb-link>WebServiceBean</ejb-link>
       </service-impl-bean>
       </port-component>
       </webservice-description>
      </webservices>


      jaxrpc-mapping.xml

      <?xml version='1.0' encoding='UTF-8'?><java-wsdl-mapping version='1.1' 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://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd'>
       <package-mapping>
       <package-type>publishingsystem.dipartimento.interfaces</package-type>
       <namespaceURI>http://www.unibo.it/dip/types</namespaceURI>
       </package-mapping>
       <service-interface-mapping>
       <service-interface>publishingsystem.dipartimento.interfaces.WebService</service-interface>
       <wsdl-service-name xmlns:serviceNS='http://www.unibo.it/dip'>serviceNS:WebService</wsdl-service-name>
       <port-mapping>
       <port-name>WebServiceEndpointPort</port-name>
       <java-port-name>WebServiceEndpointPort</java-port-name>
       </port-mapping>
       </service-interface-mapping>
       <service-endpoint-interface-mapping>
       <service-endpoint-interface>publishingsystem.dipartimento.interfaces.WebServiceEndpoint</service-endpoint-interface>
       <wsdl-port-type xmlns:portTypeNS='http://www.unibo.it/dip'>portTypeNS:WebServiceEndpoint</wsdl-port-type>
       <wsdl-binding xmlns:bindingNS='http://www.unibo.it/dip'>bindingNS:WebServiceEndpointBinding</wsdl-binding>
       <service-endpoint-method-mapping>
       <java-method-name>sayHello</java-method-name>
       <wsdl-operation>sayHello</wsdl-operation>
       <method-param-parts-mapping>
       <param-position>0</param-position>
       <param-type>java.lang.String</param-type>
       <wsdl-message-mapping>
       <wsdl-message xmlns:wsdlMsgNS='http://www.unibo.it/dip'>wsdlMsgNS:WebServiceEndpoint_sayHello</wsdl-message>
       <wsdl-message-part-name>String_1</wsdl-message-part-name>
       <parameter-mode>IN</parameter-mode>
       </wsdl-message-mapping>
       </method-param-parts-mapping>
       <wsdl-return-value-mapping>
       <method-return-value>java.lang.String</method-return-value>
       <wsdl-message xmlns:wsdlMsgNS='http://www.unibo.it/dip'>wsdlMsgNS:WebServiceEndpoint_sayHelloResponse</wsdl-message>
       <wsdl-message-part-name>result</wsdl-message-part-name>
       </wsdl-return-value-mapping>
       </service-endpoint-method-mapping>
       </service-endpoint-interface-mapping>
      </java-wsdl-mapping>



      I created the jar package (with these 3 files in META-INF) and I tried to deploy it in JBoss, but it returns the following error:

      17:48:01,781 INFO [EjbModule] Deploying WebService
      17:48:03,890 ERROR [MainDeployer] Could not create deployment: file:/C:/Programmi/jboss-4.0.5.GA/server/default/deploy/PublishingSystem.DipartimentoEJB.jar
      org.jboss.ws.WSException: Cannot obtain UnifiedBeanMetaData for: WebServiceBean
       at org.jboss.ws.deployment.JSR109ServerMetaDataBuilder.buildMetaData(JSR109ServerMetaDataBuilder.java:152)
       at org.jboss.ws.deployment.ServiceEndpointDeployer.create(ServiceEndpointDeployer.java:85)
       at org.jboss.ws.integration.jboss.DeployerInterceptor.create(DeployerInterceptor.java:80)
       at org.jboss.ws.integration.jboss.DeployerInterceptorEJB.create(DeployerInterceptorEJB.java:44)
       at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.create(SubDeployerInterceptorSupport.java:180)
       at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:91)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy26.create(Unknown Source)
       at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
       at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy8.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)



      What does it mean? What's wrong with my code? Did I forget something writing the web service?

      Thanks a lot.

        • 1. Re: Problem deploying a simple web service
          Marco Sigismondi Newbie

          Sorry, it was my fault in the wstools config file. I had to write WebService instead of WebServiceBean.

          Now I can see my web service in http://localhost:8080/jbossws/services


          I have another problem: if I deploy only the .jar file (containing also other EJBs), all works. But if I deploy the ear file (containing the .jar file and also a .war file with jsps, servlets, etc.), JBoss says:

          18:39:28,390 INFO [EjbModule] Deploying WebService
          18:39:28,984 INFO [TomcatDeployer] deploy, ctxPath=/PublishingSystem, warUrl=.../tmp/deploy/PublishingSystem.DipartimentoApp.ear-PublishingSystem.DipartimentoEJB.jar-ws47226.war/
          18:39:29,578 ERROR [MainDeployer] Could not create deployment: file:/C:/Programmi/jboss-4.0.5.GA/server/default/tmp/deploy/tmp47225PublishingSystem.DipartimentoApp.ear-contents/PublishingSystem.DipartimentoWeb.war
          java.lang.IllegalArgumentException: Cannot find wsdl in deployment: META-INF/wsdl/WebService.wsdl
           at org.jboss.ws.metadata.ServiceMetaData.getWsdlDefinitions(ServiceMetaData.java:270)
           at org.jboss.ws.deployment.JSR109ServerMetaDataBuilder.buildMetaData(JSR109ServerMetaDataBuilder.java:94)
           at org.jboss.ws.deployment.ServiceEndpointDeployer.create(ServiceEndpointDeployer.java:78)
           at org.jboss.ws.integration.jboss.DeployerInterceptor.create(DeployerInterceptor.java:80)
           at org.jboss.ws.integration.jboss.DeployerInterceptorJSE.create(DeployerInterceptorJSE.java:74)
           at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.create(SubDeployerInterceptorSupport.java:180)
           at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:91)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
           at $Proxy39.create(Unknown Source)
           at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969)
           at org.jboss.deployment.MainDeployer.create(MainDeployer.java:959)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
           at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
           at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
           at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
           at $Proxy8.deploy(Unknown Source)
           at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
           at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
           at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
           at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
           at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
          


          Why? I tried to insert the 3 wstools-generated files (webservices.xml, jaxrpc-mapping.xml, WebService.wsdl) even inside the .war and inside the .ear, but it doesn't work.

          In which package should I put these 3 files? How can I do to use the web service deploying the entire .ear?

          Thanks.