Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: IllegalArgumentException: No matching constant for [-1] after upgrading from M4 to RC

  1. #11

    Default

    I am creating the request like this..:

    Code:
            HttpHeaders requestHeaders = new HttpHeaders();
            List<MediaType> acceptableMediaTypesXml = new ArrayList<MediaType>();
            acceptableMediaTypesXml.add(MediaType.APPLICATION_XML);
            requestHeaders.set("WsUsername", "username");
            requestHeaders.set("WsPassword", "password");
            requestHeaders.setAcceptEncoding(ContentCodingType.GZIP);
            if (ticket != null)
            {
                requestHeaders.set("Ticket", ticket);
            }
            requestHeaders.set("TerminalID", UnoMobilApplication.getTerminalId());
            restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory());     // since default doesn't work...
            requestHeaders.setAccept(acceptableMediaTypesXml);
            HttpEntity<?> requestEntity = new HttpEntity<String>(id, requestHeaders);
            ResponseEntity<DeliveryList> responseEntity = restTemplate.exchange(url + "deliveries/" + id, HttpMethod.GET, requestEntity, DeliveryList.class);
            return responseEntity.getBody();

    BTJ
    Someone wrote:
    "I understand that if you play a Windows CD backwards you hear strange Satanic messages"
    To which someone replied:
    "It's even worse than that; play it forwards and it installs Windows"

  2. #12
    Join Date
    Nov 2010
    Posts
    175

    Default

    Thanks for the information on how you are constructing the Rest Template request. I've created a new issue to track this [1], so it can be addressed in the next release.

    [1] https://jira.springsource.org/browse/ANDROID-81
    Roy Clarkson
    Spring Mobile Projects Lead

  3. #13
    Join Date
    Nov 2010
    Posts
    175

    Default

    Can you try the latest build snapshot? I've made some changes in SimpleHttpClient to fix an issue with basic auth, and I'm curious if you are still experiencing this. What is the HTTP status code returned in the response?
    Roy Clarkson
    Spring Mobile Projects Lead

  4. #14
    Join Date
    Nov 2012
    Posts
    1

    Default

    Hello there.

    I am getting this error now as well.. I have been using the 1.0.0 RELEASE and now with the spring-android-rest-template-1.0.1.BUILD-20121023.140702-8.

    Well, if I start from the top, I am using the rest template to get content from two different servers.. one server using regular http, and the other using https..

    I noticed that on some devices (even newer devices as Samsung Galaxy S3), it seems as though making multiple calls through HTTPS is very slow.. ie. making 2-3 calls in a row would result in a ~3 second delay between each call (but not on all devices). So I went to google and found a post saying that using the HttpComponentsClientHttp over HTTPS could result in poor performance. Also, I was reading that from gingerbread and up i should use the SimpleClientHttp.. Or just leave it out entirely to let the framework decide based on android version.

    So, what happens now is that using either SimpleClient or "nothing" I get this error "IllegalArgumentException: No matching constant for [-1]", on my device that i did not have before. I believe it happens right before executing the second HTTPS call. The first one seems to come through just fine. However, it seems there are no issues with regular http calls (at least I have two HTTP calls before the two HTTPS calls).

    Also notice it is different on different devices:

    Using HttpComponentsClientHttp
    Galaxy Nexus (Android 4.1.2) -> No performance Issues, works great
    Galaxy S3 (Android 4.1.1) -> Performance issue (~3 second delay between calls) but works.

    Using SimpleClientHttp
    Galaxy Nexus -> Fails with IllegalArgumentException in second Https call.
    Galaxy S3 -> not tested.

    Code:
    Code:
                   // is working but has performance issues on some devices
                   // RestTemplate template = new RestTemplate(true, new HttpComponentsClientHttpRequestFactory());
    
                   RestTemplate template = new RestTemplate(true);
    
    		HttpHeaders headers = getHeaders()
    		
    		if(cookies != null) {
    			addCookieHeaders(headers, cookies);
    		}
    		
    		HttpEntity<?> entity = null;
    		
    		if(json != null && json.length() > 0) {
    			entity = new HttpEntity<Object>(json, headers);
    		}
    		else {
    			entity = new HttpEntity<Object>(headers);
    		}
    		
    		ResponseEntity<String> result = null;
    		
    		try {
    			// Fire!
    			result = template.exchange(
    				url,
    				method, 
    				entity, 
    				String.class);
    		}
    		catch(HttpClientErrorException ex) {
    		}
    		catch(HttpServerErrorException ex) {
    		}
    		catch(Exception ex) {
    		}
    		
    		return result;
    Any help would be appreciated..
    Thank you very much.
    David
    Last edited by davidj.dk; Nov 5th, 2012 at 04:40 AM.

  5. #15
    Join Date
    Nov 2010
    Posts
    175

    Default

    I've been trying to reproduce this exception with no luck so far. I'm using a modified version of the twitter search sample app. I changed the url to use https instead, and I added several repeated restTemplate.exchange() calls. I've tested both http clients on a Galaxy Nexus (4.1.1), Nexus One (2.3.6), and Nexus 7 (4.2.1) without seeing an exception. Do you have any additional information that can help reproduce this issue?
    Roy Clarkson
    Spring Mobile Projects Lead

  6. #16
    Join Date
    Jun 2010
    Posts
    1

    Default

    Hello,

    i added a new comment to the jira issue https://jira.springsource.org/browse/ANDROID-81 how this error can be reproduced. I hope this helps to find the error.

    Thanks and Regards
    Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •