[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

help with a little error

hello,

i have this 3 class
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package service;

/**
 *
 * @author mehdi
 */
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */




import java.io.IOException;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import converter.FlyedpConverter;
import entities.FlysCombination;
import org.codehaus.jettison.json.JSONException;

@Path("/getdatesandprices")
public class FlyesdpResource {



    @GET
    @Path("{Bday},{Bmonth},{Byear},{Blocation},{Eday},{Emonth},{Eyear},{Elocation},{Triptype},{Adtpax},{Ythpax},{Chdpax},{Infantpax}")
     //Triptype : String, Adtpax : String, Ythpax : String, Chdpax : String, Infantpax : String )
    @Produces({"application/xml"})
    public Response get(@PathParam("Bday") String Bday,
            @PathParam("Bmonth") String Bmonth,
            @PathParam("Byear") String Byear,
            @PathParam("Blocation") String Blocation,
            @PathParam("Eday") String Eday,
            @PathParam("Emonth") String Emonth,
            @PathParam("Eyear") String Eyear,
            @PathParam("Elocation") String Elocation,
            @PathParam("Triptype") String Triptype,
            @PathParam("Adtpax") String Adtpax,
            @PathParam("Ythpax") String Ythpax,
            @PathParam("Chdpax") String Chdpax,
            @PathParam("Infantpax") String Infantpax

            ) throws IOException, JSONException





    {
         FlysCombination c = FlysCombination.instance();



         FlysCombination comb =c.getDatesAndPrices(Bday,Bmonth,Byear,Blocation,Eday,Emonth,Eyear,Elocation,Triptype,Adtpax,Ythpax,Chdpax,Infantpax);
        if(comb == null)
            {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
        return Response.ok(comb).build();
    }
}

Open in new window


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

/**
 *
 * @author mehdi
 */
import converter.FlyedpConverter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;


public class FlysCombination {

    public static FlysCombination flycomb=null;

     public static FlysCombination instance()
            {
        if(flycomb == null)
            {
            flycomb=new FlysCombination();
        }
        return flycomb;
    }


	private static String session;
	@SuppressWarnings("rawtypes")
	private static  ArrayList combinations = new ArrayList();


	public FlysCombination()
	{

	}





	@Override
	public String toString() {
		return "FlysCombination [session=" + session + ", goingback="
				+ combinations + "]";
	}





	public FlysCombination(String sessionid, ArrayList combinations) {

		this.session = session;
		this.combinations = combinations;
	}





	public String getSessionid() {
		return session;
	}
	public void setSessionid(String sessionid) {
		this.session = sessionid;
	}
	public ArrayList getGoingthere() {
		return combinations;
	}
	public void setGoingthere(ArrayList goingthere) {
		this.combinations = goingthere;
	}





public String getSession() {
		return session;
	}

public void setSession(String session) {
		this.session = session;
	}








	public static  FlysCombination getDatesAndprices(String Bday,String Bmonth,String Byear,String Blocation,String Eday,String Emonth,String Eyear,String Elocation,String Triptype,String Adtpax, String Ythpax, String Chdpax, String Infantpax ) throws IOException, JSONException

	{{
		


			         FlyedpConverter fly = new FlyedpConverter ("date","fprice","dfprice","rfprice");
			         combinations.add(fly);

			         //System.out.println(combinations);


	          //System.out.println("-----------------------");

				}




	         FlysCombination flycomb =new FlysCombination (session,combinations);


             return(flycomb);
	}




	 public static void main(String[] args) throws IOException, JSONException  {



		 // String sessionid;
		  String Bday,Bmonth,Byear,Blocation,Eday,Emonth,Eyear,Elocation,Triptype;

		  String Adtpax="1"; // nombre d'adulte
		  String Ythpax="0"; // Nombre de jeunes
		  String Chdpax="0"; //Nombre d'enfant
		  String Infantpax="0"; //Nombre de bébé

	      Bday="05";Bmonth="05";Byear="2011";Blocation="TUN";
	      Eday="07";Emonth="05";Eyear="2011";Elocation="ALG";
	      Triptype="R";

	      FlysCombination comb =new  FlysCombination();
	      comb=getDatesAndprices(Bday,Bmonth,Byear,Blocation,Eday,Emonth,Eyear,Elocation,Triptype,Adtpax,Ythpax,Chdpax,Infantpax);

	      System.out.println(comb.toString());




	  }


}

Open in new window



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package converter;

/**
 *
 * @author mehdi
 */

public class FlyedpConverter

{


private String keydate;
private String formatted_price;
private String dformatted_price;
private String rformatted_price;

public FlyedpConverter()
{

}




@Override
public String toString() {
	return "flyedpConverter [keydate=" + keydate + ", formatted_price="
			+ formatted_price + ", dformatted_price=" + dformatted_price
			+ ", rformatted_price=" + rformatted_price + "]";
}




public FlyedpConverter(String keydate,String formatted_price,String dformatted_price,String rformatted_price)
{
	this.keydate=keydate;
	this.formatted_price=formatted_price;
	this.dformatted_price=dformatted_price;
	this.rformatted_price=rformatted_price;
}



public String getKeydate() {
	return keydate;
}
public void setKeydate(String keydate) {
	this.keydate = keydate;
}
public String getFormatted_price() {
	return formatted_price;
}
public void setFormatted_price(String formatted_price) {
	this.formatted_price = formatted_price;
}
public String getDformatted_price() {
	return dformatted_price;
}
public void setDformatted_price(String dformatted_price) {
	this.dformatted_price = dformatted_price;
}
public String getRformatted_price() {
	return rformatted_price;
}
public void setRformatted_price(String rformatted_price) {
	this.rformatted_price = rformatted_price;
}


}

Open in new window


i have a  little problem in the classe FlyesdpResource , in
 FlysCombination comb =c.getDatesAndPrices(Bday,Bmonth,Byear,Blocation,Eday,Emonth,Eyear,Elocation,Triptype,Adtpax,Ythpax,Chdpax,Infantpax);

Open in new window


 1
I think that  it's very stupid but i dont found the error :/
the problem does not come from the web service code... even when i delete it i have error ..
can you help me please ?
0
keviin555
Asked:
keviin555
1 Solution
 
for_yanCommented:
But it is static method and you apply it to instance "c"
0
 
Amitkumar PSr. ConsultantCommented:
The method getDatesAndPrices() is public static. Access it using classname.

You have used the same method in main() method of FlysCombination.
FlysCombination comb =new  FlysCombination();
comb=getDatesAndprices(Bday,Bmonth,Byear,Blocation,Eday,Emonth,Eyear,Elocation,Triptype,Adtpax,Ythpax,Chdpax,Infantpax);

And in FlyesdpResource,
FlysCombination comb =c.getDatesAndPrices(Bday,Bmonth,Byear,Blocation,Eday,Emonth,Eyear,Elocation,Triptype,Adtpax,Ythpax,Chdpax,Infantpax);

Any special reason to do so?

BTW, which IDE are you using? It does not seem to be Eclipse.
0
 
for_yanCommented:
public static  FlysCombination getDatesAndprices(String Bday,String Bmonth,String Byear,String Blocation,String Eday,String Emonth,String Eyear,String Elocation,String Triptype,String Adtpax, String Ythpax, String Chdpax, String Infantpax ) throws IOException, JSONException

It should be called:

FlysCombination.getDatesAndprices(....)

should be applied to class name, not to the instance of the class
FlysCombination comb =c.getDatesAndPrices(Bday,Bmonth,Byear,Blocation,Eday,Emonth,Eyear,Elocation,Triptype,Adtpax,Ythpax,Chdpax,Infantpax);
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
keviin555Author Commented:
Any special reason to do so?
in the main i have just trie it , but i want to use instance() .
i use eclipse to write the java code but then i change to netbeans when i will make the RESTful web service .It's more easy with netbean .

I removed static but still dont work :/

this is the project , can you take a look please ? i thik it work much better with netbean so if you have it trie with it .

http://188.121.50.97/WebService2.zip

Thank you very much
0
 
for_yanCommented:
Well, it still does not work, but I'm sure it is now different reason, as ditinction between static method and instance nmethod is very important both in logic and for the compiler: it was expected it produced an error
0
 
gordon_vt02Commented:
The reason you are getting the symbol not found error is because the declared method name is:

getDatesAndprices(...)

and you are calling

getDatesAndPrices(...)

I'm making the assumption that you meant for the method to be the latter, so just change the definition in FlysCombination so it is completely camel-cased (capitalize the 'P' in prices).
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now