2012-06-11 123 views
0

我正在處理公開Web服務的Java Web應用程序。這個Web服務在同一臺Tomcat服務器上對另外兩個Java Web服務進行遠程調用。如果我嘗試從另外兩個服務調用方法,則會得到一堆導致自動生成的代碼中出現NoSuchMethodError的錯誤。我使用Netbeans 6.9,sun java 1.6和apache tomcat 6.0.26。我單獨測試了Web服務,它們工作正常。從web服務方法tomcat6 web服務調用nodfounderror

謝謝你的時間。

讓我更具體

我與RecommendationManager Web服務的RecommendationWeb Web應用程序:

@WebService() 
public class RecommendationManager { 
    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; 
    } 
} 

,並與ETL_WS Web服務的ETL_Procedures Web應用程序:

@WebService() 
public class ETL_WS { 
    public ArrayList<Long> getCorrespondingActiveCouponsForRecommendation(ArrayList<Long> itemCategories, int numOfRecoms) { 
    int sumOfAllRecommendedCategories = 0; 
    Iterator itr = itemCategories.iterator(); 
    ArrayList<Coupon> coupons = new ArrayList<Coupon>(); 
    ArrayList<Long> recommendedCoupons = new ArrayList<Long>(); 
    HashMap productOccurences = new HashMap(); 
    while(itr.hasNext()) { 
     Long item = (Long) itr.next(); 
     int val = 0; 
     ArrayList<Coupon> temp = (ArrayList<Coupon>) couponMap.getCoupon(item); 
     if(temp != null) { 
      Iterator itr_a = temp.iterator(); 
      while(itr_a.hasNext()) { 
       val += 1; 
       sumOfAllRecommendedCategories += 1; 
       Coupon tmp_coupon = (Coupon) itr_a.next(); 
       if(tmp_coupon.isActive()) 
        coupons.add(tmp_coupon); 
      } 
      productOccurences.put(item, new Integer(val)); 
     } 
    } 
    long currentCat = coupons.get(0).getItem_id(); 
    int categoryRecs = 0; 
    Integer currentOccurence = (Integer) productOccurences.get(new Long(currentCat)); 
    int maxCategoryItems = (currentOccurence.intValue()/sumOfAllRecommendedCategories); 
    int tempRecItems = 0; 
    int listIndex = 0; 
    while(tempRecItems < numOfRecoms && listIndex < coupons.size()) { 
     if(categoryRecs < maxCategoryItems && currentCat == coupons.get(listIndex).getItem_id()) { 
      recommendedCoupons.add(coupons.get(listIndex).getItem_id()); 
      listIndex += 1; 
      tempRecItems += 1; 
      categoryRecs += 1; 
     }else if(categoryRecs < maxCategoryItems && currentCat != coupons.get(listIndex).getItem_id()) { 
      recommendedCoupons.add(coupons.get(listIndex).getItem_id()); 
      currentCat = coupons.get(listIndex).getItem_id(); 
      currentOccurence = (Integer) productOccurences.get(new Long(currentCat)); 
      maxCategoryItems = (currentOccurence.intValue()/sumOfAllRecommendedCategories); 
      categoryRecs = 1; 
      listIndex += 1; 
      tempRecItems += 1; 
     }else { 
      recommendedCoupons.add(coupons.get(listIndex).getItem_id()); 
      currentCat = coupons.get(listIndex).getItem_id(); 
      currentOccurence = (Integer) productOccurences.get(new Long(currentCat)); 
      maxCategoryItems = (currentOccurence.intValue()/sumOfAllRecommendedCategories); 
      categoryRecs = 1; 
      listIndex += 1; 
      tempRecItems += 1; 
     } 
    } 

    return recommendedCoupons; 
} 
} 

這兩種方法在INTERFACE_LAYER Web服務的Recommended_Interface Web應用程序中調用:

@WebService() 
public class INTERFACE_LAYER { 
    public ArrayList<Long> requestRecommendation(long userID, int noOfRecoms) { 
    ArrayList<Long> recommendedCoupons = null; 
    ArrayList<Long> recommendedItems = (ArrayList<Long>) getRecommendation(userID, noOfRecoms); 
     recommendedCoupons = (ArrayList<Long>) getCorrespondingActiveCouponsForRecommendation(recommendedItems, noOfRecoms); 
    return recommendedCoupons; 
} 

private static java.util.List<java.lang.Long> getRecommendation(long arg0, int arg1) { 
    ws.recommender.RecommendationManagerService service = new ws.recommender.RecommendationManagerService(); 
    ws.recommender.RecommendationManager port = service.getRecommendationManagerPort(); 
    return port.getRecommendation(arg0, arg1); 
} 

private static java.util.List<java.lang.Long> getCorrespondingActiveCouponsForRecommendation(java.util.List<java.lang.Long> arg0, int arg1) { 
    ws.etl.ETLWSService service = new ws.etl.ETLWSService(); 
    ws.etl.ETLWS port = service.getETLWSPort(); 
    return port.getCorrespondingActiveCouponsForRecommendation(arg0, arg1); 
} 
} 
+1

您可能需要發佈更多的細節(即日誌)以獲得有意義的答案! – Davos555

回答

0

不工作的原因是Web服務方法ArrayList的返回值。當我將其更改爲字符串時,它工作。