users@glassfish.java.net

JAX-WS & JAXB

From: Daniel H. Cavalcanti <dhcavalcanti_at_gmail.com>
Date: Thu, 26 Jun 2008 16:12:27 -0400

Hi...

I have a JAX-WS whose return type is a JAXB pojo generated from a schema.
I can deploy the project fine, but when I try to test it through
glassfish tester web page, I get problems. Similarly, if I try to
generate the client stubs to write unit tests, I get the following error:

 wsimport -s src -d build -p client
http://bentevi:8080/Supersonic/SupersonicService?WSDL
parsing WSDL...


[ERROR] undefined element declaration 'ns1:shopping-list'
  line 60 of http://bentevi:8080/Supersonic/SupersonicService?xsd=2

Exception in thread "main" java.lang.NullPointerException
        at
com.sun.tools.internal.xjc.reader.internalizer.SCDBasedBindingSet.apply(SCDBasedBindingSet.java:201)
        at
com.sun.tools.internal.xjc.ModelLoader.createXSOM(ModelLoader.java:502)
        at
com.sun.tools.internal.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:216)
        at
com.sun.tools.internal.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:69)
        at
com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:120)
        at
com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2173)
        at
com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:173)
        at
com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:119)
        at
com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:170)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:100)
        at com.sun.tools.internal.ws.WsImport.main(WsImport.java:38)

Here is the web service classes...

@Stateless()
@WebService(serviceName="Supersonic")
public class SupersonicService
    extends SupersonicBean {
   
    @WebMethod(operationName = "authenticate")
    @Override
    public void authenticate(
        @WebParam(name = "username") String username,
        @WebParam(name = "password") String password
    ) throws UserNotFoundException, InvalidUserPasswordException,
SupersonicException {
        super.authenticate(username, password);
    }
   
    @WebMethod(operationName = "getUserModel")
    @Override
    public User getUserModel(
        @WebParam(name = "username") String username,
        @WebParam(name = "password") String password
    ) throws UserNotFoundException, InvalidUserPasswordException,
SupersonicException {
        return super.getUserModel(username, password);
    }
   
}

@Stateless
public class SupersonicBean
    implements SupersonicLocal {
   
    public void authenticate(String username, String password)
    throws UserNotFoundException, InvalidUserPasswordException,
SupersonicException {
       ...
    }
   
    public User getUserModel(String username, String password)
    throws UserNotFoundException, InvalidUserPasswordException,
SupersonicException {
       ...
    }
   
}

@Local
public interface SupersonicLocal {
   
    public void authenticate(String username, String password)
    throws UserNotFoundException, InvalidUserPasswordException,
SupersonicException;
   
    public User getUserModel(String username, String password)
    throws UserNotFoundException, InvalidUserPasswordException,
SupersonicException;
   
}

Finally, here is the related JAXB generated POJO

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {shoppingList"})
@XmlRootElement(name = "user")
public class User {

    @XmlElement(name = "shopping-list")
    protected List<ShoppingList> shoppingList;
    @XmlAttribute(required = true)
    protected String username;
    @XmlAttribute(required = true)
    protected String name;
    @XmlAttribute(required = true)
    protected String email;

    // Getter/setter methods...
  
}


Any ideas what I should do to fix the problem?

thanks,