这是一个示例类
public class NewClass {
public String hello1(String txt) {
String a = "Hello " + txt + " !";
return a;
}
}
这是一个示例网络服务
@WebService(serviceName = "NewWebService2")
public class NewWebService2 {
private NewClass newess;
/**
* This is a sample web service operation
*/
@WebMethod(operationName = "hello")
public String hello(@WebParam(name = "name") String txt) {
return "Hello " + txt + " !";
}
@WebMethod(operationName = "hello11")
public String hello11(@WebParam(name = "name") String txt) {
String ess=newess.hello1(txt);
return ess;
}
}
第一种方法hello
完全有效,但第二种方法hello11
不起作用。我不明白这个问题。服务器显示此消息:
SEVERE: java.lang.NullPointerException
at newpackage.NewWebService2.hello11(NewWebService2.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.glassfish.webservices.InstanceResolverImpl$1.invoke(InstanceResolverImpl.java:143)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:149)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:94)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:961)
.
.
.
请我需要了解这个问题以及如何解决它。