Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JAX-WS: Using argument in method from another class annotation

Status
Not open for further replies.

Ascalonian

Programmer
Jan 4, 2008
264
0
0
US
I am creating a web service for work. I am breaking it down into 3 separate Maven projects:

[ul]
[li]SOA (stores the request and response objects used in web methods)[/li]
[li]Services (this stores the classes that actually do the processing of the data)[/li]
[li]WebServices (This stores the endpoint interface and generated jaxws folder)
[/ul]

In the SOA project, I have a simple POJO that is used to pass in the needed values to the web method

Code:
public class RequestObject {
    private String firstName = null;
    private String lastName = null;

    // Setters and Getters below...
}

Then I try to reference this class in the WebServices project. I include the SOA generated JAR as a dependency in Maven. This does work and pulls in the files correctly.

Interface:
Code:
@WebService
public interface WebServiceInf {
    @WebMethod
    @WebResult(name="WebMethodResult")
    String createSomething(@WebParam(name="requestObject")RequestObject request);
}

Web Service:
Code:
import com.mine.data.RequestObject;

@WebServiceInterface(endpointInterface="com.mine.WebServiceInf")
public class WebServiceImpl implements WebServiceInf {
    @Override
    public String createSomething(RequestObject request) {
        return "I was created!";
    }
}

The issue I am running into is when I use the wsgen tool. It works fine if I place the RequestObject inside the WebService project. But, once I placed that class into the SOA project, it throws the following error:

Code:
Problem encountered during annotation processing; see stacktrace below for more information. java.lang.NullPointerException
        at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.isLegalType(WebServiceVisitor.java:770)
        at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.isLegalParameter(WebServiceVisitor.java:670)
        at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.isLegalMethod(WebServiceVisitor.java:637)
        at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.methodsAreLegal(WebServiceVisitor.java:575)
        at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.isLegalSEI(WebServiceVisitor.java:567)
        at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.shouldProcessWebService(WebServiceVisitor.java:300)
        at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.visitInterfaceDeclaration(WebServiceVisitor.java:94)
        at com.sun.tools.apt.mirror.declaration.InterfaceDeclarationImpl.accept(InterfaceDeclarationImpl.java:32)
        at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.inspectEndpointInterface(WebServiceVisitor.java:395)
        at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.visitClassDeclaration(WebServiceVisitor.java:128)
        at com.sun.tools.apt.mirror.declaration.ClassDeclarationImpl.accept(ClassDeclarationImpl.java:95)
        at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceAP.buildModel(WebServiceAP.java:315)
        at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceAP.process(WebServiceAP.java:256)
        at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(AnnotationProcessors.java:60)
        at com.sun.tools.apt.comp.Apt.main(Apt.java:454)
        at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:258)
        at com.sun.tools.apt.main.Main.compile(Main.java:1102)
        at com.sun.tools.apt.main.Main.compile(Main.java:964)
        at com.sun.tools.apt.Main.processing(Main.java:95)
        at com.sun.tools.apt.Main.process(Main.java:85)
        at com.sun.tools.apt.Main.process(Main.java:67)
        at com.sun.tools.internal.ws.wscompile.WsgenTool.buildModel(WsgenTool.java:204)
        at com.sun.tools.internal.ws.wscompile.WsgenTool.run(WsgenTool.java:112)
        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:105)
        at com.sun.tools.internal.ws.WsGen.main(WsGen.java:41) error: compilation failed, errors should have been reported

So this looks like I need a certain annotation to tell the WebService project that the RequestObject is in another project/JAR.

What annotation would I use to do this? Thank you so very much for the help!
 
This is how I am calling the **wsgen**. I am executing this command from the **WebServices** root folder:

Code:
wsgen -keep -cp target/classes/ -s src/main/java -d target/classes/ com.mine.WebServiceImpl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top