Announcement Announcement Module
Collapse
No announcement yet.
Unable to pass list [Rest, XML, Android] Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to pass list [Rest, XML, Android]

    Hello Everyone

    I'm trying to create an android application that would connect on a server to get and post information about Events and the Users that can create the events.

    I implemented a function on the server that finds all the users in the database, and that sends them with webservices. But when I try to get back that information on my Android application, the application crashes.
    Because I work with lists, I tried to work with DTO, but the result is still the same.

    I'll put some code to show you how I work

    Code:
    @XmlRootElement(name="user")
    @Entity
    @Table(name = "SA_USER")
    public class User extends BaseEntity implements Serializable {
    
    	private static final long serialVersionUID = -8386881380312242149L;
    	
    	@Column(name = "FIRST_NAME", nullable = false, length = 32)
    	@Index(name = "INDEX_SA_USER_NAME", columnNames = {"FIRST_NAME", "LAST_NAME"})
    	private String firstName;
    	
    	@Column(name = "LAST_NAME", nullable = false, length = 32)
    	private String lastName;
    	
    	@Column(name = "USER_NAME", nullable = false, unique = true, length = 64)
    	@IndexColumn(name = "INDEX_SA_USER_USER_NAME")
    	private String userName;
    	
    	@Column(name = "PASSWORD", length = 64)
    	private String password;
    	
    	@Column(name = "EMAIL", nullable = false, unique = true, length = 128)
    	private String email;
    	
    	@Column(name = "PHONE_NUMBER", nullable = true, length = 20)
    	private String phoneNumber;
    	
    	@Column(name = "MOBILE", nullable = true, length = 20)
    	private String mobile;
    	
    	@ManyToOne(cascade = CascadeType.ALL)
    	@JoinColumn(name = "GRADE_ID", nullable = false)
    	private Grade grade;
    That's some code from my User class (I work with Hibernate)
    I am able to insert and retrieve correctly information in my Database.
    When I want to pass several Users to a client via REST, I use this method :

    Code:
    @RequestMapping(value="/user/all", method = RequestMethod.GET, headers="Accept=application/xml, application/json")
    	public @ResponseBody UserList getAllUsers() {
    		LOGGER.debug("findAllUsers!!");
    		UserList list = new UserList();
    		list.setUsers(this.teacherService.findAllUsers());
    		return list;
    	}
    The UserList code is the following :

    Code:
    @XmlRootElement(name="userList")
    public class UserList {
    	private List<User> users;
    	
    	public List<User> getUsers() {
    		return users;
    	}
    	
    	public void setUsers(List<User> users) {
    		this.users = users;
    	}
    }


    That's for the server side.

    I tried to get the userlist with the following code on the client (Android) side :

    Code:
    try {
            	userList = restTemplate.getForObject(URL, UserList.class);
            }
        	catch (RestClientException e) {
            	Toast.makeText(getApplicationContext(), "La connexion a �chou�e!", Toast.LENGTH_LONG).show();
            }
    my UserList on client side looks like this :
    Code:
    @Root(name = "userList")
    public class UserList {
    	@ElementList(inline = true)
    	private List<User> users;
    	
    	public List<User> getUsers() {
    		return users;
    	}
    	
    	public void setUsers(List<User> users) {
    		this.users = users;
    	}
    }
    my User class on the client side looks like this :

    Code:
    @Root
    public class User {
    
    	@Element
    	private Long id;
    	@Element
    	private Long version;
    	@Element
    	private String firstName;
    	@Element
    	private String lastName;
    	@Element
    	private String userName;
    	@Element
    	private String password;
    	@Element
    	private String email;
    	@Element
    	private String phoneNumber;
    	@Element
    	private String mobile;
    	@Element
    	private Grade grade;
    to implement all this, I used the spring documentation.

    But, when I try to get the users, The app crashes. I tried to connect to the server using this FireFox add-on ( https://addons.mozilla.org/en-US/fir...on/restclient/ ) and with that add-on, I'm able to get all my users correctly


    I hope what I wrote is somewhat understandable
    If someone has an idea, it would be very great!

    Thank you in advance!

  • #2
    Hi Stef102, can you please provide the exception details, and also a sample of the format of the xml response? My guess is that the Simple XML library is throwing the exception because of a deserialization issue.

    Comment


    • #3
      Hello,

      Thank you for your reply! I had a closer look to my XML file, and managed to solve my problem. It was the fact that the objects passed in the XML file were of type "users" instead of "user". At first, I tought it was normal, because the list was named "users", but, when I corrected that, it solved the problem.

      I hope that this can be usefull for other newbies like I am
      Do I have to add something like "Answered" in the title of the subject, or is it OK like this?

      Thanks again

      Comment


      • #4
        Great! I'm glad you found the issue. These forums do not have a method to mark an accepted answer. But it's always helpful to others to communicate how you resolve issues, so they can benefit from it. Thanks!

        Comment


        • #5
          Ok, thanks again for the answer!

          Anyway, I will stay subscribed to this thread, so if there's any question left, i will see it

          Comment


          • #6
            Hi clark ,

            As u mentioned in the thread , i am getting the exception because of deserialization issue.
            ant the exception is :

            Caused by: org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.List out of START_OBJECT.

            any idea ?

            thanks,
            Arun

            Comment


            • #7
              As I mentioned earlier in this thread, it is difficult to diagnose deserialization without more information. Obviously, Jackson is having problems with something. Take a look at your android log and stacktrace to see if they help provide any additional information as to where the specific issue is. Hope that helps.

              Comment


              • #8
                what is the exact meaning of deserialization? please explain

                Comment


                • #9
                  I think the issue may be that you are trying to deserialize json into a List<>. Try creating a wrapper bean with a property that holds your list and deserialize to that bean instead. Deserialization is simply the process of converting json data into a java bean. This is handled by RestTemplate and Jackson, in this case.

                  Comment


                  • #10
                    I have the same probleman.

                    I created two simple projects to demonstrate how the problem occurs.
                    http://www.megaupload.com/?d=54ZTRQ0W

                    By clicking the button two (second), you will see that everything is fine, but clicking a button one (first), there is the problem in question.


                    Note that the return (json) is different in both cases, if a (problematic) is the return
                    {"category": {"name": "Cagetory 1"}}

                    and the second return (json) is:
                    {"category ":[{" name": "Cagetory 1 "},{" name": "Cagetory 2"}]}


                    This is stacktrace
                    Code:
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343): FATAL EXCEPTION: AsyncTask #2
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343): java.lang.RuntimeException: An error occured while executing doInBackground()
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at java.lang.Thread.run(Thread.java:1096)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343): Caused by: org.springframework.web.client.ResourceAccessException: I/O error: Can not deserialize instance of java.util.List out of START_OBJECT token
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):  at [Source: org.apache.http.conn.EofSensorInputStream@44f7f238; line: 1, column: 2] (through reference chain: com.impact.client.tablet.dat.request.CategoryRest["category"]); nested exception is org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.List out of START_OBJECT token
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):  at [Source: org.apache.http.conn.EofSensorInputStream@44f7f238; line: 1, column: 2] (through reference chain: com.impact.client.tablet.dat.request.CategoryRest["category"])
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:477)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:425)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:303)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at com.impact.client.tablet.dat.request.CategoryRequest.oneCategory(CategoryRequest.java:20)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at com.impact.client.tablet.dat.busca.OneCategoryDAT.doInBackground(OneCategoryDAT.java:22)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at com.impact.client.tablet.dat.busca.OneCategoryDAT.doInBackground(OneCategoryDAT.java:1)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     ... 4 more
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343): Caused by: org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.List out of START_OBJECT token
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):  at [Source: org.apache.http.conn.EofSensorInputStream@44f7f238; line: 1, column: 2] (through reference chain: com.impact.client.tablet.dat.request.CategoryRest["category"])
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDeserializationContext.java:198)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.codehaus.jackson.map.deser.CollectionDeserializer.handleNonArray(CollectionDeserializer.java:149)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.codehaus.jackson.map.deser.CollectionDeserializer.deserialize(CollectionDeserializer.java:107)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.codehaus.jackson.map.deser.CollectionDeserializer.deserialize(CollectionDeserializer.java:97)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.codehaus.jackson.map.deser.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:252)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:356)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:494)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:350)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2395)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1655)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.readInternal(MappingJacksonHttpMessageConverter.java:146)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:148)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:68)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:470)
                    11-10 04:58:15.449: ERROR/AndroidRuntime(343):     ... 11 more
                    11-10 04:58:15.749: WARN/ActivityManager(67):   Force finishing activity com.impact.client/.tablet.controller.cardapio.CardapioLayoutActivity
                    11-10 04:58:19.639: ERROR/WindowManager(343): Activity com.impact.client.tablet.controller.cardapio.CardapioLayoutActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f66fb0 that was originally added here
                    11-10 04:58:19.639: ERROR/WindowManager(343): android.view.WindowLeaked: Activity com.impact.client.tablet.controller.cardapio.CardapioLayoutActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f66fb0 that was originally added here
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at android.view.ViewRoot.<init>(ViewRoot.java:247)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at android.app.Dialog.show(Dialog.java:241)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at com.impact.client.tablet.controller.cardapio.AAsyncActivityImplDefault.showProgressDialog(AAsyncActivityImplDefault.java:36)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at com.impact.client.tablet.controller.cardapio.AAsyncActivityImplDefault.showLoadingProgressDialog(AAsyncActivityImplDefault.java:26)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at com.impact.client.tablet.controller.cardapio.AAsyncActivity.showLoadingProgressDialog(AAsyncActivity.java:15)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at com.impact.client.tablet.dat.ADownloadTask.onPreExecute(ADownloadTask.java:32)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at android.os.AsyncTask.execute(AsyncTask.java:391)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at com.impact.client.tablet.controller.cardapio.CardapioLayoutModel.oneCategory(CardapioLayoutModel.java:24)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at com.impact.client.tablet.controller.cardapio.CardapioLayoutActivity$1.onClick(CardapioLayoutActivity.java:39)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at android.view.View.performClick(View.java:2408)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at android.view.View$PerformClick.run(View.java:8816)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at android.os.Handler.handleCallback(Handler.java:587)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at android.os.Handler.dispatchMessage(Handler.java:92)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at android.os.Looper.loop(Looper.java:123)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at android.app.ActivityThread.main(ActivityThread.java:4627)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at java.lang.reflect.Method.invokeNative(Native Method)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at java.lang.reflect.Method.invoke(Method.java:521)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
                    11-10 04:58:19.639: ERROR/WindowManager(343):     at dalvik.system.NativeStart.main(Native Method)
                    Last edited by netstart; Nov 10th, 2011, 12:15 PM.

                    Comment


                    • #11
                      If i use this below source, to proces this json return ({"category":{"name":"Cagetory 1"}}) , i have problem too.


                      Source

                      Code:
                      	GsonHttpMessageConverter messageConverter = new GsonHttpMessageConverter();
                      	messageConverter.setSupportedMediaTypes(Collections
                      		.singletonList(MediaType.APPLICATION_JSON));
                      	List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
                      	messageConverters.add(messageConverter);
                      	restTemplate.setMessageConverters(messageConverters);
                      
                      	// Perform the HTTP GET request to the Google search API
                      	CategoryRest response = restTemplate.postForObject(url, null,
                      		CategoryRest.class);
                      	categorias = response.getCategory();
                      StackTrace
                      Code:
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973): FATAL EXCEPTION: AsyncTask #1
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973): java.lang.RuntimeException: An error occured while executing doInBackground()
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at java.lang.Thread.run(Thread.java:1096)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973): Caused by: java.lang.NullPointerException
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at org.apache.harmony.luni.lang.reflect.ListOfTypes.length(ListOfTypes.java:47)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at org.apache.harmony.luni.lang.reflect.ImplForType.toString(ImplForType.java:83)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at java.lang.StringBuilder.append(StringBuilder.java:203)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExceptionWrapper.java:57)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.google.gson.JsonDeserializationVisitor.invokeCustomDeserializer(JsonDeserializationVisitor.java:92)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler(JsonObjectDeserializationVisitor.java:117)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.google.gson.ReflectingFieldNavigator.visitFieldsReflectively(ReflectingFieldNavigator.java:63)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:120)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializationContextDefault.java:76)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializationContextDefault.java:54)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.google.gson.Gson.fromJson(Gson.java:551)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.google.gson.Gson.fromJson(Gson.java:498)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.google.gson.Gson.fromJson(Gson.java:441)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at org.springframework.http.converter.json.GsonHttpMessageConverter.readInternal(GsonHttpMessageConverter.java:140)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:148)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:68)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:470)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:425)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:303)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.impact.client.tablet.dat.request.CategoryRequest.oneCategory(CategoryRequest.java:48)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.impact.client.tablet.dat.busca.OneCategoryDAT.doInBackground(OneCategoryDAT.java:22)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at com.impact.client.tablet.dat.busca.OneCategoryDAT.doInBackground(OneCategoryDAT.java:1)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
                      11-10 18:07:48.974: ERROR/AndroidRuntime(973):     ... 4 more
                      11-10 18:07:49.034: WARN/ActivityManager(58):   Force finishing activity com.impact.client/.tablet.controller.cardapio.CardapioLayoutActivity
                      11-10 18:07:52.754: ERROR/WindowManager(973): Activity com.impact.client.tablet.controller.cardapio.CardapioLayoutActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f668c8 that was originally added here
                      11-10 18:07:52.754: ERROR/WindowManager(973): android.view.WindowLeaked: Activity com.impact.client.tablet.controller.cardapio.CardapioLayoutActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f668c8 that was originally added here
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at android.view.ViewRoot.<init>(ViewRoot.java:247)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at android.app.Dialog.show(Dialog.java:241)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at com.impact.client.tablet.controller.cardapio.AAsyncActivityImplDefault.showProgressDialog(AAsyncActivityImplDefault.java:36)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at com.impact.client.tablet.controller.cardapio.AAsyncActivityImplDefault.showLoadingProgressDialog(AAsyncActivityImplDefault.java:26)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at com.impact.client.tablet.controller.cardapio.AAsyncActivity.showLoadingProgressDialog(AAsyncActivity.java:15)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at com.impact.client.tablet.dat.ADownloadTask.onPreExecute(ADownloadTask.java:32)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at android.os.AsyncTask.execute(AsyncTask.java:391)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at com.impact.client.tablet.controller.cardapio.CardapioLayoutModel.oneCategory(CardapioLayoutModel.java:22)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at com.impact.client.tablet.controller.cardapio.CardapioLayoutActivity$1.onClick(CardapioLayoutActivity.java:36)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at android.view.View.performClick(View.java:2408)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at android.view.View$PerformClick.run(View.java:8816)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at android.os.Handler.handleCallback(Handler.java:587)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at android.os.Handler.dispatchMessage(Handler.java:92)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at android.os.Looper.loop(Looper.java:123)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at android.app.ActivityThread.main(ActivityThread.java:4627)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at java.lang.reflect.Method.invokeNative(Native Method)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at java.lang.reflect.Method.invoke(Method.java:521)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
                      11-10 18:07:52.754: ERROR/WindowManager(973):     at dalvik.system.NativeStart.main(Native Method)
                      Last edited by netstart; Nov 10th, 2011, 12:13 PM.

                      Comment


                      • #12
                        If i use below source, Category is intanciate, but your properties is null.
                        I believe that this behavior may be related.

                        Code:
                        List<Category> categorias;
                        	/*
                        	 * This request return: {"category":{"name":"Cagetory 1"}}
                        	 */
                        
                        	RestTemplate restTemplate = new RestTemplate();
                        	HttpHeaders requestHeaders = new HttpHeaders();
                        	List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
                        	acceptableMediaTypes.add(MediaType.APPLICATION_JSON);
                        	requestHeaders.setAccept(acceptableMediaTypes);
                        	HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
                        
                        	ResponseEntity<Category> responseEntity = restTemplate.postForEntity(url,
                        		requestEntity, Category.class);
                        	Category cat = responseEntity.getBody(); //cat is intanciate, but your properties is null
                        	categorias = new ArrayList<Category>();
                        	categorias.add(cat);

                        Comment


                        • #13
                          The information in this JIRA may be helpful for JSON mapping with Jackson.

                          https://jira.springsource.org/browse/ANDROID-45

                          Comment

                          Working...
                          X