• Post Reply Bookmark Topic Watch Topic
  • New Topic

Jackson unrecognized field  RSS feed

 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I previously posted this but I may have included too much information so I'm going to try to be more concise. I am really struggling with this so any help is much appreciated.

I'm trying to debug the following error:

avax.servlet.ServletException: com.sun.jersey.api.client.ClientHandlerException: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "portaluserOwnerId" (Class com.voxportal.web.asset.LineOfServiceBean), not marked as ignorable
at [Source: java.io.ByteArrayInputStream@3ee58007; line: 1, column: 648] (through reference chain: com.voxportal.web.asset.AssetSearchBean["assetBeans"]->com.voxportal.web.asset.AssetBean["lineOfServiceBean"]->com.voxportal.web.asset.LineOfServiceBean["portaluserOwnerId"])

Obviously this message is referencing field portaluserOwnerId in LineOfServiceBean (code is below).

To me the message implies that portaluserOwnerId needs to defined somewhere else. I believe that somewhere else is VoxLineOfService.java (also included below). It looks to me like VoxLineOfService has the definitions to actually read the field from the PostgreSql database.




 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note - I have tried marking the field as ignorable. this works in terms of getting rid of the error message but then it appears that the database field is never read.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe it is because of the space after the name in this line:
 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it was a good idea (space after the name) but after removing it, the problem remains the same
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
… and I presume the column name is spelt correctly now.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And is that field set from a parameter in every constructor?
 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have looked at that column name 20 times and it looks correct to me. Here's the actual Postgres table definition:

 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question "And is that field set from a parameter in every constructor? " --> I'm not sure what the question means but it sounds like you might be on to something.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does every constructor have a parameter which sets up that particular field? Is it possible for a constructor to complete with that field still initialised to its default value of null?

Does that help?
 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried creating the following constructor in LineOfServiceBean.java - it created just fine but the problem remains.

 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't want more constructors. You want as few constructors as possible.
None of the constructors you showed (1 in the first class, 3 in the second class) appears to initialise the owner ID. Try adding the owner ID to the constructors as a parameter, so the object cannot be initialised without owner ID. And I think it is correctly spelt.
 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added portaluserOwnerId to the constructor below in LineOServiceBean.java and to the call in AssetBean. Still no luck though



 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that. Tried my hardest.
 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really appreciate your efforts.
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the relevant section of code where you are using ObjectMapper. It probably looks something like this:

Also, post the JSON string that you're trying to convert to a LineOfServiceBean. This will give everyone a better idea of what's going on.
 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, thanks for all your thoughts and ideas. Although one particular thing didn't solve it, I was able to get VoxLineOfService to read the PORTALUSER_OWNER_
ID field from the ASSETLINEOFSERVICES table and stick it in portaluserOwnerId. I can tell this because the System.out in the export routine displays the correct value.

The bad news is that the LineOfServiceBean isn't getting the value. My System.outs in this code are showing NULL.

So, I'm getting closer. If anyone has any ideas on this issue, I'd love to hear them. I've burned many hours trying to narrow it down so I can figure it out.



 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you don't think this is a JSON mapping issue? http://jackson.codehaus.org/1.6.0/javadoc/org/codehaus/jackson/map/exc/UnrecognizedPropertyException.html says this particular exception extends JsonMappingException, so I have to wonder what JSON string is being mapped to a Java object which, from the error message, seems like it should be a LineOfServiceBean, not a VoxLineOfService. Is there no reference to an ObjectMapper anywhere in your code? Or do you think this line of investigation is way out in left field?
 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldn't find a reference to an ObjectMapper but I may not know what I'm looking for. this system is large (9000 files) so it is a challenge to find things (I search the world over!)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!