Getting Unsupported cookie spec: ignoreCookies

394 views
Skip to first unread message

Devashish Pandey

unread,
Feb 27, 2015, 1:25:57 PM2/27/15
to rest-a...@googlegroups.com
What steps will reproduce the problem?
1. Write a simple case, say testing 404
@Test
	public void testStatusNotFound() {
		given().log().all().with().authentication().basic("Blah","BlahhalB").
		expect().statusCode(404).when().
		get("/notfound");
	}

baseURI is already set. My service is up and running

2. Run this in Eclipse as JUnit test
3. Get the following exception :- java.lang.IllegalStateException: Unsupported cookie spec: ignoreCookies.

Full stacktrace attached. Below is just an excerpt : 

java.lang.IllegalStateException: Unsupported cookie spec: ignoreCookies
	at org.apache.http.cookie.CookieSpecRegistry.getCookieSpec(CookieSpecRegistry.java:114)
	at org.apache.http.client.protocol.RequestAddCookies.process(RequestAddCookies.java:168)


What version of the product are you using? On what operating system?
rest-assured 2.4.0 /Windows 8.1 /Eclipse Kepler with Maven/ Tomcat 8.0.15/ Jersey

Please provide any additional information below.

I get the same exception with POST as well, and also when I disable basic auth.

What could I be doing wrong ?
RestAssuredCookieIssue.txt

Johan Haleby

unread,
Feb 27, 2015, 1:27:55 PM2/27/15
to rest-a...@googlegroups.com
Hmm never seen this before. I suppose you're using the latest version of REST Assured?

Could you log the response as well and paste it here?

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Devashish Pandey

unread,
Feb 28, 2015, 1:28:48 AM2/28/15
to rest-a...@googlegroups.com
From the log, after logging both request and response :-

Request method: GET
Proxy: <none>
Request params: <none>
Query params: <none>
Form params: <none>
Path params: <none>
Multiparts: <none>
Headers: Accept=*/*
Cookies: <none>
Body: <none>
2015-02-28 11:46:01,709 [main] DEBUG org.apache.http.impl.conn.SingleClientConnManager [] - Get connection for route HttpRoute[{}->http://myservice.in]
2015-02-28 11:46:02,013 [main] DEBUG org.apache.http.client.protocol.RequestAddCookies [] - CookieSpec selected: ignoreCookies
2015-02-28 11:46:02,013 [main] DEBUG org.apache.http.impl.conn.DefaultClientConnection [] - Connection shut down
2015-02-28 11:46:02,013 [main] DEBUG org.apache.http.impl.conn.SingleClientConnManager [] - Releasing connection org.apache.http.impl.conn.SingleClientConnManager$ConnAdapter@7b5ce015


So no response! I had been tailing the tomcat access logs, and I see no incoming requests over there as well. The same stuff DOES work via Postman or even in a browser.

Johan Haleby

unread,
Feb 28, 2015, 12:49:53 PM2/28/15
to rest-a...@googlegroups.com
You to put "log().all()" after "expect" or "then" to log the response. Please try that.

Devashish Pandey

unread,
Feb 28, 2015, 1:24:57 PM2/28/15
to rest-a...@googlegroups.com
The above was logged with the following code :-

public void testStatusNotFound() {
		given().log().all().with().authentication().basic("Blah","BlahhalB").
		expect().statusCode(404).when().
		get("/notfound").then().log().all();
	}

Johan Haleby

unread,
Feb 28, 2015, 3:32:41 PM2/28/15
to rest-a...@googlegroups.com
I don't believe what you've showed is the response log. You've only showed us the request log. You need to put "log().all()" after expect. For example:
public void testStatusNotFound() {
		given().log().all().with().authentication().basic("Blah","BlahhalB").
		expect().log().all().statusCode(404).when().
		get("/notfound").then().log().all();
	}

Devashish Pandey

unread,
Feb 28, 2015, 3:43:56 PM2/28/15
to rest-a...@googlegroups.com
Done that as well, but no change in the logs :(

Devashish Pandey

unread,
Feb 28, 2015, 3:45:09 PM2/28/15
to rest-a...@googlegroups.com
if you want then I can share a screenshot as well.

Johan Haleby

unread,
Mar 1, 2015, 2:24:59 AM3/1/15
to rest-a...@googlegroups.com
Hmm so you don't get a response at all!? It's important that you place "log().all()" before any (response) expectations otherwise it may not work. You can also try RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(). 

/Johan

Devashish Pandey

unread,
Mar 1, 2015, 4:19:42 AM3/1/15
to rest-a...@googlegroups.com
As I said earlier, I don't even see a request hitting the server in my tomcat's access log, so the request isn't being  sent either.
I'll tried what you wrote above as well, but no changes in the log.

Johan Haleby

unread,
Mar 1, 2015, 8:52:04 AM3/1/15
to rest-a...@googlegroups.com
Oh I see. So the request just hangs?

Devashish Pandey

unread,
Mar 1, 2015, 9:02:07 AM3/1/15
to rest-a...@googlegroups.com

I see <terminated> in junit runner inside eclipse. So I guess it simply exits, post this exception and doesn't appear to be hung up

Johan Haleby

unread,
Mar 2, 2015, 2:16:56 AM3/2/15
to rest-a...@googlegroups.com
Ok. I really can't make much sense of what's causing this. Perhaps you can use wireshark to really figure out what's happening on the wire? In wireshark you could also compare the rest assured request with the postman request and see what's different (if the latter worked).

/Johan

Devashish Pandey

unread,
Mar 5, 2015, 3:38:41 AM3/5/15
to rest-a...@googlegroups.com
It was due to wrong version of HTTPclient getting picked up. Some stuff in my project was fetching HTTPClient 4.0.1 (support for ignoreCookies is abset in this version) as a dependency, and somehow rest-assured was using that.
I isolated rest-assured part  from the rest and now it's fine. 

On Monday, March 2, 2015 at 12:46:56 PM UTC+5:30, Johan Haleby wrote:
Ok. I really can't make much sense of what's causing this. Perhaps you can use wireshark to really figure out what's happening on the wire? In wireshark you could also compare the rest assured request with the postman request and see what's differenwast (if the latter worked).

/Johan

Johan Haleby

unread,
Mar 5, 2015, 6:08:48 AM3/5/15
to rest-a...@googlegroups.com
Ok I'm glad your managed to sort it out. Classpath issues can really be a pain. I can recommend JHades if you run into similar problems again.

Devashish Pandey

unread,
Mar 5, 2015, 9:43:25 AM3/5/15
to rest-a...@googlegroups.com
Thanks for the help Johan. :)
Reply all
Reply to author
Forward
0 new messages