I am currently developing a jsp web application that maintains two clients of two other web services. I am using apache-tomcat 6.0.26, Oracle (Sun) java 1.6 and Netbeans 6.9 (IDE). My problem is that when a call the two web services from a standard Java SE application, everything works fine. However, If I attempt to call web service methods from the web service that consumes the two web services, I get a:
NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
I use a wrapper-class that handles the RPCs for the web service:
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);
}
}
And the code of the JAX-WS webservice is as follows:
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;
}
}
The NoSuchMethod Exception stact trace starts from the call
ArrayList recommendedProducts = (ArrayList) getRecommendation(user_id, nummOfRecs);
Why is this happening? Since the code that the exception comes from is auto-generated, what can I do to overcome it? Why is this only happening in a web application and not in a java SE application? Does it have anything to do with my current setup?
Thank you for your time.
Actually I figured out what went wrong. Apparently the JAX-WS framework didn’t work because of the return value ArrayList object. When I changed it as a String object, no problem appeared. Also, I have to mention that I upgraded from Oracle Java 1.6 to 1.7, though I do not think that this was the main reason.