Wrapper class package.jaxws.methodName is not found. Have you run APT to generate them?

Problem

In JAX-WS development, when following service endpoint is deploying,

File : HelloWorld.java

 
package com.mkyong.ws;
//Service Endpoint Interface
@WebService
public interface HelloWorld{
 
	@WebMethod String getHelloWorldAsString();
}

File : HelloWorldImpl.java

 
//Service Implementation
package com.mkyong.ws;
@WebService(endpointInterface = "com.mkyong.ws.HelloWorld")
public class HelloWorldImpl implements HelloWorld{
 
	@Override
	public String getHelloWorldAsString() {
		//...
	}
 
}

It hits following error message immediately?


Exception in thread "main" com.sun.xml.internal.ws.model.RuntimeModelerException: 
	runtime modeler error: 

        Wrapper class com.mkyong.ws.jaxws.GetHelloWorldAsString is not found. 
        Have you run APT to generate them?

	at com.sun.xml.internal.ws.model.RuntimeModeler.getClass(RuntimeModeler.java:256)
	//...

Solution

The service endpoint interface is not annotated with any @SOAPBinding, so, it uses the default document style to publish it. For human readability, you can rewrite it as following :

 
//Service Endpoint Interface
@WebService
@SOAPBinding(style = Style.DOCUMENT, use=Use.LITERAL)
public interface HelloWorld{
 
	@WebMethod String getHelloWorldAsString();
}

In document style, you need to use “wsgen” tool to generate all the necessary JAX-WS portable artifacts (mapping classes, wsdl or xsd schema) for the service publication.

wsgen command

The wsgen command is required to read the service endpoint implementation class :


wsgen -keep -cp . com.mkyong.ws.HelloWorldImpl

It generates two classes for a single getHelloWorldAsString() method, under package.jaxws folder.

  1. GetHelloWorldAsString.java
  2. GetHelloWorldAsStringResponse.java

Copy those classes to correct folder, in this case, it’s “com.mkyong.ws.jaxws“. Try publish it again.

Reference

  1. wsgen tool documentation

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
6 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
5 Comment authors
RajaBahniman RoyUmanath MSatishGezzer Recent comment authors
newest oldest most voted
Umanath M
Guest
Umanath M

please add “import javax.jws.soap.SOAPBinding.Use;” in interface HelloWorld to avoid Use.LITERAL an enum annotation value must be an enum constant

trackback
JAX-WS Hello World Example – Document Style

[…] this article. You need to use “wsgen” tool to generate necessary JAX-WS portable artifacts. Let move […]

Gezzer
Guest
Gezzer

Thanks!
SO MUCH!!!

Satish
Guest
Satish

I was reading the document style web service and I did not get this error.. I am using jdk 7. For me with out the artifacts, document style is running fine..

I got a bit confused.. Please clarify.

Bahniman Roy
Guest
Bahniman Roy

It appears that the error is JRE dependent. I swapped the JRE and the wrapper classes were auto generated – below is an excerpt from the log when Endpoint.publish(…) is invoked.

INFO: Dynamically creating request wrapper ….

Raja
Guest
Raja

Hi I am facing “com.sun.xml.internal.ws.model.RuntimeModelerException: class: .com.mytest.ws.HelloWorld could not be found” , when i run the publisher file. Below is my HelloWorld webservice interface code: @WebService @SOAPBinding(style = Style.RPC,use= SOAPBinding.Use.LITERAL) public interface HelloWorld { @WebMethod public String getHelloWorldAsString(String name); } Below is my HelloWorldImpl code @WebService(endpointInterface = “.com.mytest.ws.HelloWorld”) public class HellowWorldImpl implements HelloWorld { @Override public String getHelloWorldAsString(String name){ return “com.mytest.ws.HelloWorld!”+name; } } Below is my publisher code public class HelloWorldPublisher { public static void main(String []args){ Endpoint.publish(“http://localhost:7779/ws/hello”,new HellowWorldImpl()); } } PS::I have tride using wsgen as you mentioned in this blog. But its not working. its suggesting llike below.… Read more »