Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] Document getter/setter not the same (collection vs
 List)

IL Bretone

2007-09-19

Replies:


Hello,

I'm trying to compile a class which will become a web service, I'm using
Netbeans 5.5 and when i try to compile the following code:

"
  @WebMethod
  public Document getUserTrainingPlan(@(protected)
userId) {
   
    UserPlan[] availableUserPlans =
AngelSelectQuery.doGetAvailbleUserPlans(userId);
       
    Document doc = new Document();
    Element plans = new Element("plans");
             
    for ( int i = 0; i < availableUserPlans.length; i++) {
      Element plan = new Element("plan").setAttribute("id",
availableUserPlans[i].getPlan().getPlanId());
      plan.addContent(new
Element("creationDate").setText(angel.webapp.utils.Date4Jsp.getDate(availableUserPlans[i].getPlan().getCreationDate())));
      plan.addContent(new
Element("name").setText(availableUserPlans[i].getPlan().getPlanName()));
      plan.addContent(new
Element("creator").setText(availableUserPlans[i].getPlan().getCreator().getGeneralInfo()));
      plan.addContent(new
Element("duration").setText(availableUserPlans[i].getPlan().getDuration()));
          plan.addContent(new
Element("avgSpeed").setText(availableUserPlans[i].getPlan().getAverageSpeed()));
         
      plans.addContent(plan);
       }

      doc.addContent(plans);
       
       // Debug
       try {
          XMLOutputter outp = new XMLOutputter();
          outp.output(doc, System.out);
       } catch (Exception e){
          System.out.println("Erreur xml: " + e.toString());
       }
   
    return doc;
   
  }
"

it gives me the following error:

"error: The type of the getter is java.util.List but that of the setter is
java.util.Collection. They have to be the same.
    this problem is related to the following location:
          at org.jdom.Document.getContent (Unknown Source)
          at org.jdom.Document (Unknown Source)
          at
angel.ws.jaxws.GetUserTrainingPlanResponse._return(GetUserTrainingPlanResponse.java:17)
          at
angel.ws.jaxws.GetUserTrainingPlanResponse(GetUserTrainingPlanResponse.java:14)
    this problem is related to the following location:
          at org.jdom.Document.setContent (Unknown Source)
          at org.jdom.Document (Unknown Source)
          at
angel.ws.jaxws.GetUserTrainingPlanResponse._return(GetUserTrainingPlanResponse.java:17)
          at
angel.ws.jaxws.GetUserTrainingPlanResponse(GetUserTrainingPlanResponse.java:14)
error: The type of the getter is java.util.List but that of the setter is
java.util.Collection. They have to be the same.
    this problem is related to the following location:
          at org.jdom.Element.getContent (Unknown Source)
          at org.jdom.Element (Unknown Source)
          at org.jdom.Document.getRootElement (Unknown Source)
          at org.jdom.Document (Unknown Source)
          at
angel.ws.jaxws.GetUserTrainingPlanResponse._return(GetUserTrainingPlanResponse.java:17)
          at
angel.ws.jaxws.GetUserTrainingPlanResponse(GetUserTrainingPlanResponse.java:14)
    this problem is related to the following location:
          at org.jdom.Element.setContent (Unknown Source)
          at org.jdom.Element (Unknown Source)
          at org.jdom.Document.getRootElement (Unknown Source)
          at org.jdom.Document (Unknown Source)
          at
angel.ws.jaxws.GetUserTrainingPlanResponse._return(GetUserTrainingPlanResponse.java:17)
          at
angel.ws.jaxws.GetUserTrainingPlanResponse(GetUserTrainingPlanResponse.java:14)
error: org.jdom.Namespace does not have a no-arg default constructor.
    this problem is related to the following location:
          at org.jdom.Namespace (Unknown Source)
          at org.jdom.Element.getNamespace (Unknown Source)
          at org.jdom.Element (Unknown Source)
          at org.jdom.Document.getRootElement (Unknown Source)
          at org.jdom.Document (Unknown Source)
          at
angel.ws.jaxws.GetUserTrainingPlanResponse._return(GetUserTrainingPlanResponse.java:17)
          at
angel.ws.jaxws.GetUserTrainingPlanResponse(GetUserTrainingPlanResponse.java:14)
3 errors
error: compilation failed, errors should have been reported
"

What should I do ? I wouldn't like to rewrite jdom ;)

Cheers,
Joel
--
Sent from the JDOM - General mailing list archive at Nabble.com.

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.