这可以很好地运行它作为Java应用程序:
public class A {
public String getString(){
return "hey";
}
public String getString2(){
Gson gs = new Gson();
String a = gs.toJson("hello");
String b = gs.fromJson(a, String.class);
return b;
}
public static void main(String[] args) {
A a = new A();
System.out.println(a.getString());//returns "hey"
System.out.println(a.getString2());//returns "hello"
}
}
当我将它发布到tomcat并运行客户端时,但:
//client of A with AStub and ACallbackHandler autogenerated by eclipse
public class AClient {
public static void main(String[] args) {
AStub s = new AStub();
System.out.println(s.getString().get_return());
//returns "hey"
System.out.println(s.getString2().get_return());
//fails with org.apache.axis2.AxisFault: com/google/gson/Gson
}
}
有时,当重新发布tomcat服务器时,它会显示ClassNotFoundException
我正在使用Eclipse EE Indigo,Axis2,GSON 1.7.1和tomcat 6
我做错了什么?
答案 0 :(得分:0)
我没有添加外部jar文件! 将它们放在服务器的WebContent / WEB-INF / lib中。