Hi all
I have following program....
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
@WebService
public class Calculator {
@WebMethod
public int add(int a, int b) {
return a+b;
}
public static void main(
String[] args){
// create and publish an endpoint
Calculator calculator = new Calculator();
Endpoint endpoint = Endpoint.publish("http://localhost:8080/calculator", calculator);
}
}
then I ran
apt to compile and generate required wrapper classes
* apt -d sample com/Calculator.java
I got following warnings, but I ignored that:
warning: Annotation types without processors: [javax.xml.bind.annotation.XmlRoot
Element, javax.xml.bind.annotation.XmlAccessorType, javax.xml.bind.annotation.Xm
lType, javax.xml.bind.annotation.XmlElement]
then I triedd tp publish it by using following command
*
java -cp sample com.Calculator
I got the following exception
Exception in
thread "main"
com.sun.xml.internal.ws.server.ServerRtException: Ser
ver Runtime Error: java.net.BindException: Address already in use: bind
at com.sun.xml.internal.ws.transport.http.server.ServerMgr.createContext
(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(Un
known Source)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(Un
known Source)
at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(Unk
nown Source)
at javax.xml.ws.Endpoint.publish(Unknown Source)
at com.Calculator.main(Calculator.java:19)
Caused by: java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at sun.net.httpserver.ServerImpl.<init>(Unknown Source)
at sun.net.httpserver.HttpServerImpl.<init>(Unknown Source)
at sun.net.httpserver.DefaultHttpServerProvider.createHttpServer(Unknown
Source)
at com.sun.net.httpserver.HttpServer.create(Unknown Source)
... 6 more
Please can you tell me what is the problem with my code as above.......
Thanks in advance.