代码:import java.util.HashMap;
import java.util.Map;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
@WebService
public class sayhello {
@WebMethod
public JSON add(){
Maptest=new HashMap();
test.put("1", "a1");
test.put("2", "a2");
test.put("3", "a3");
test.put("4", "a4");
test.put("5", "a5");
test.put("6", "a6");
JSONObject jsonObject = JSONObject.fromObject(test);
return jsonObject;
}
public static void main(String[] args) {
System.out.println(System.getProperty("java.endorsed.dirs"));
Endpoint.publish("http://localhost:9001/service/sayhello", new sayhello());
System.out.println("success");
}
}
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/E:/jdk/lib/endorsed/slf4j-jdk14-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/%e7%8e%8b%e8%b4%9d%e8%b4%9d/Workspaces/MyEclipse%208.5/service/WebRoot/WEB-INF/lib/slf4j-jdk14-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.JDK14LoggerFactory]
Exception in thread "main" java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:36)
at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:95)
at javax.xml.ws.spi.Provider.provider(Provider.java:76)
at javax.xml.ws.Endpoint.publish(Endpoint.java:156)
at com.net.cn.sayhello.main(sayhello.java:29)
Caused by: java.lang.NullPointerException
at java.util.ResourceBundle.getBundle(Unknown Source)
at org.apache.cxf.common.i18n.BundleUtils.getBundle(BundleUtils.java:80)
at org.apache.cxf.common.logging.LogUtils.createLogger(LogUtils.java:249)
at org.apache.cxf.common.logging.LogUtils.getL7dLogger(LogUtils.java:201)
at org.apache.cxf.jaxws.spi.ProviderImpl.(ProviderImpl.java:68)
... 10 more