我目前正在开发一个 jsp Web 应用程序,它维护两个其他 Web 服务的两个客户端。我正在使用 apache-tomcat 6.0.26、Oracle (Sun) java 1.6 和 Netbeans 6.9 (IDE)。我的问题是,当从标准 Java SE 应用程序调用这两个 Web 服务时,一切正常。但是,如果我尝试从使用这两个 Web 服务的 Web 服务调用 Web 服务方法,我会得到:
NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
我使用一个包装类来处理 Web 服务的 RPC:
public class RecommenderEngineContainer {
public ArrayList<Long> getRecommendationResults(long user_id, int nummOfRecs) {
if(user_id < 0 || nummOfRecs < 0 || nummOfRecs > 100)
return null;
ArrayList<Long> recommendedProducts = (ArrayList<Long>) getRecommendation(user_id, nummOfRecs);
return recommendedProducts;
}
private static java.util.List<java.lang.Long> getRecommendation(long arg0, int arg1) {
ws.recommendationengine.RECOMMENDATIONENGINEWSService service = new ws.recommendationengine.RECOMMENDATIONENGINEWSService();
ws.recommendationengine.RECOMMENDATIONENGINEWS port = service.getRECOMMENDATIONENGINEWSPort();
return port.getRecommendation(arg0, arg1);
}
}
JAX-WS webservice的代码如下:
public class RECOMMENDATION_ENGINE_WS {
private MyConnector dbManager;
private Connection dbCon = null;
private String DIRECTORY_PATH;
private String data_model_file;
private String dbTableUserPrefs = "user_preferences";
private String dbTableSimModel = "item_similarities";
private static SingletonItemSimilarityModel myHModel;
public RECOMMENDATION_ENGINE_WS() {
Context context = null;
try {
context = (Context) new InitialContext().lookup("java:comp/env");
this.DIRECTORY_PATH = (String) context.lookup("RECOM_ENGINE_DIR_PATH");
this.data_model_file = (String) context.lookup("USER_HISTORY_FILE_NAME");
}catch(NamingException e) {
System.err.println(e.getMessage());
}
}
public ArrayList<Long> getRecommendation(long userId, int NumOfRecommendations) {
List<RecommendedItem> recommendations = this.myHModel.getRecommendations(userId, NumOfRecommendations);
ArrayList<Long> result = new ArrayList<Long>();
Iterator itr = recommendations.iterator();
while(itr.hasNext()) {
RecommendedItem recItem = (RecommendedItem) itr.next();
result.add(new Long(recItem.getItemID()));
}
return result;
}
}
NoSuchMethod Exception stact 跟踪从调用 ArrayList RecommendedProducts = (ArrayList) getRecommendation(user_id, nummOfRecs);
为什么会这样?由于异常来自的代码是自动生成的,我该怎么做才能克服它?为什么这只发生在 Web 应用程序中而不是 Java SE 应用程序中?它与我当前的设置有什么关系吗?
感谢您的时间。