3 Replies Latest reply on May 28, 2009 8:39 AM by Alessio Soldano

    org.jboss.ws.WSException: Cannot obtain java type mapping fo

    Tim Newbie

      Hi All,

      I hope you can help me as I have been knocking me head against a wall for a couple of days now. I can seem to get a simple hello service working for document/literal.

      The problem is this I have a simple SLSB which I am using as a web service:

      package myejbws;
      
      import java.rmi.RemoteException;
      
      import javax.ejb.EJBException;
      import javax.ejb.SessionBean;
      import javax.ejb.SessionContext;
      
      import javax.ejb.CreateException;
      
      /**
       * @ejb.bean name="Hello"
       * display-name="Name for Hello"
       * description="Description for Hello"
       * jndi-name="ejb/Hello"
       * type="Stateless"
       * view-type="all"
       *
       */
      public class HelloBean implements SessionBean {
      
       public void setSessionContext(SessionContext ctx)
       throws EJBException,
       RemoteException {
       System.out.println("HelloBean.setSessionContext");
       }
      
       public void ejbRemove() throws EJBException, RemoteException {
       System.out.println("HelloBean.ejbRemove");
      
       }
      
       public void ejbActivate() throws EJBException, RemoteException {
       System.out.println("HelloBean.ejbActivate");
      
       }
      
       public void ejbPassivate() throws EJBException, RemoteException {
       System.out.println("HelloBean.ejbPassivate");
      
       }
      
       /**
       * Default create method
       *
       * @throws CreateException
       * @ejb.create-method
       */
       public void ejbCreate() throws CreateException {
       System.out.println("HelloBean.ejbCreate");
       }
      
       /**
       *
       * @ejb.interface-method view-type="all"
       * @param name
       * @return
       * @throws EJBException
       * @throws RemoteException
       */
       public String sayHello(String name) {
       System.out.println("HelloBean.sayHello("+name+")");
       return "Hello " +name+" from HelloBean";
       }
      


      I have used the SWTool with the following config:
      
      <?xml version="1.0" encoding="UTF-8"?>
      
      <configuration xmlns="www.aware-services.co.uk/ws">
       <java-wsdl>
       <service name="HelloService"
       style="document"
       endpoint="myejbws.HelloEndpoint"/>
       <namespaces target-namespace="www.aware-services.co.uk/ws/hello"
       type-namespace="www.aware-services.co.uk/ws/hello/types"/>
       <mapping files="jaxrpc-mapping.xml"/>
       <webservices ejb-link="Hello"/>
       </java-wsdl>
      </configuration>
      

      If I set the style to rpc all deploys fine and the client works as well.
      However when I change the style to document, create and compile the additional class created by the WSTool, it deploys but I get the following error from the client:

      tim@Monkey:~/workspace/TestWSEJB$ ant run-client
      Buildfile: build.xml

      ejbdoclet:
      [ejbdoclet] 0 [main] INFO XDocletMain.start - Running <utilobject/>
      [ejbdoclet] 214 [main] INFO XDocletMain.start - Running <localinterface/>
      [ejbdoclet] 221 [main] INFO XDocletMain.start - Running <localhomeinterface/>
      [ejbdoclet] 225 [main] INFO XDocletMain.start - Running <remoteinterface/>
      [ejbdoclet] 229 [main] INFO XDocletMain.start - Running <homeinterface/>
      [ejbdoclet] 235 [main] INFO XDocletMain.start - Running <service-endpoint/>
      [ejbdoclet] 239 [main] INFO XDocletMain.start - Running <deploymentdescriptor/>
      [ejbdoclet] 302 [main] INFO XDocletMain.start - Running <jboss/>

      compile:

      run-client:
      [java] Welcome
      [java] Contacting webservice at http://Monkey:8080/hello/Hello?wsdl
      [java] set up service...
      [java] log4j:WARN No appenders could be found for logger (org.jboss.ws.metadata.JSR109ClientMetaDataBuilder).
      [java] log4j:WARN Please initialize the log4j system properly.
      [java] org.jboss.ws.WSException: Cannot obtain java type mapping for: {www.aware-services.co.uk/ws/hello/types}sayHello
      [java] at org.jboss.ws.metadata.JSR109MetaDataBuilder.buildParameterMetaDataDoc(JSR109MetaDataBuilder.java:442)
      [java] at org.jboss.ws.metadata.JSR109MetaDataBuilder.setupOperationsFromWSDL(JSR109MetaDataBuilder.java:193)
      [java] at org.jboss.ws.metadata.JSR109ClientMetaDataBuilder.buildMetaDataInternal(JSR109ClientMetaDataBuilder.java:207)
      [java] at org.jboss.ws.metadata.JSR109ClientMetaDataBuilder.buildMetaData(JSR109ClientMetaDataBuilder.java:122)
      [java] at org.jboss.ws.metadata.JSR109ClientMetaDataBuilder.buildMetaData(JSR109ClientMetaDataBuilder.java:78)
      [java] at org.jboss.ws.jaxrpc.ServiceImpl.<init>(ServiceImpl.java:96)
      [java] at org.jboss.ws.jaxrpc.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:157)
      [java] at org.jboss.ws.jaxrpc.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:128)
      [java] at myclient.HelloWsEjbClient.main(Unknown Source)

      BUILD SUCCESSFUL
      Total time: 4 seconds

      I have looked in the WSDL and the mappings files and they look fine. The WSDL is as follows:
      
      <definitions name="HelloService" targetNamespace="www.aware-services.co.uk/ws/hello">
      
       <types>
      
       <schema targetNamespace="www.aware-services.co.uk/ws/hello/types">
      
       <complexType name="sayHello">
      
       <sequence>
      <element name="String_1" nillable="true" type="string"/>
      </sequence>
      </complexType>
      
       <complexType name="sayHelloResponse">
      
       <sequence>
      <element name="result" nillable="true" type="string"/>
      </sequence>
      </complexType>
      <element name="sayHello" type="tns:sayHello"/>
      <element name="sayHelloResponse" type="tns:sayHelloResponse"/>
      </schema>
      </types>
      
       <message name="HelloEndpoint_sayHello">
      <part element="ns1:sayHello" name="parameters"/>
      </message>
      
       <message name="HelloEndpoint_sayHelloResponse">
      <part element="ns1:sayHelloResponse" name="result"/>
      </message>
      
       <portType name="HelloEndpoint">
      
       <operation name="sayHello">
      <input message="tns:HelloEndpoint_sayHello"/>
      <output message="tns:HelloEndpoint_sayHelloResponse"/>
      </operation>
      </portType>
      
       <binding name="HelloEndpointBinding" type="tns:HelloEndpoint">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
      
       <operation name="sayHello">
      <soap:operation soapAction=""/>
      
       <input>
      <soap:body use="literal"/>
      </input>
      
       <output>
      <soap:body use="literal"/>
      </output>
      </operation>
      </binding>
      
       <service name="HelloService">
      
       <port binding="tns:HelloEndpointBinding" name="HelloEndpointPort">
      <soap:address location="http://Monkey:8080/hello/Hello"/>
      </port>
      </service>
      </definitions>
      


      The same thing happens if you use RPC but I pass back a non standard class (such as MyDataObject).

      HeLp!!!! (Please)

      Tim