I’m working my way through the Java EE 6 tutorial and I’m on the section about web services. I’m trying to get the helloservice running, because I’m going to need to do something similar in the near future. However, while it builds and deploys with no errors, when I try to use it, I get 404 errors from GlassFish. I’ve looked in the GlassFish logs and found nothing indicating any problems. Here’s the code from the service:
package helloservice.endpoint;
import javax.jws.WebService;
import javax.jws.WebMethod;
@WebService
public class Hello {
private String message = "Hello, ";
public void Hello() {
}
@WebMethod
public String sayHello(String name) {
return message + name + ".";
}
}
Based on what I’ve read, @WebService should expose the class with the service name HelloService (base class name + “Service”). However, when I go to:
http://localhost:8080/helloservice/HelloService?wsdl
I get a 404 error. I’ve worked through all the prior examples, so I know that GlassFish is running and that it is responding on port 8080 for other applications I’ve deployed. I can see in the admin console that helloservice is deployed and running. “asadmin list-domains” shows that my domain1 (my only domain) is running. I thought perhaps the default for the @WebService annotation was wrong, so I set an explicit value using @WebService(serviceName = “Foobar”) but that didn’t make a difference when I tried checking the wsdl (replacing HelloService with Foobar).
I’ve seen some other people have had a similar problem, but I have not seen any solutions posted. Can anyone explain what might be wrong, or how to fix it?
Ensure that you are using the Glassfish full profile and not the Glassfish web profile. After your war is deployed, start the Glassfish Administration Console, click on “Applications”. Your “Engines” column should look something like:
[ejb,jpa,web,webservices,weld]
If webservices isn’t there, your Glassfish implementation isn’t seeing your SOAP service.