flori flori - 1 year ago 134
Java Question

playframework: WSRequestHolder holder = WS.url(url) -> error: no suitable method found for url(String)

I am having trouble trying to save some data in my application. The relevant part of my code is:

String url = "http://xxx.xxx.x.xxx:xxxx/en";

HashMap<Integer,String> id_name_env = new HashMap<Integer,String>();

WSRequestHolder holder = WS.url(url); //here is the problem ...

holder.setHeader("Cookie", "sessionid="+ session("sessionid"));


ArrayList<Integer> envList = new ArrayList<Integer>();
WSResponse response = holder.get().get(20000);
JsonNode content = response.asJson();
List<String> listaIduri = content.findValuesAsText("id");

for( String id : listaIduri){
id_name_env.put(Integer.parseInt(id), id);

and the error I get is:

error: no suitable method found for url(String)

In Eclipse, it gives a different message:

The method url(WSRequestHolderMagnet) in the type WS is not applicable for the arguments (String)

What am I doing wrong? Is it a problem with the
? Eclipse is suggesting to change the
variable type into a

Answer Source

Probably you are importing play.api.libs.ws.WS and that is to be used by Scala only. In general you can assume that something from play.api.x.y.z is to be used in Scala and it may have a play.x.y.z to be used in Java.

Try to import play.libs.ws.WS instead.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download