Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnrecognizedPropertyException #49

Open
edgartff opened this issue Sep 20, 2017 · 8 comments
Open

UnrecognizedPropertyException #49

edgartff opened this issue Sep 20, 2017 · 8 comments

Comments

@edgartff
Copy link

Hello,

I followed the instructions in the README file in order to make a call to get an Account object and I received the following error. Is this a bug or am I doing something wrong?

2017-09-20 20:31:35,559 ERROR [http-nio-8080-exec-10] GrailsExceptionResolver - UnrecognizedPropertyException occurred when processing request: [GET] /api/test/testSalesforce
Unrecognized field "attributes" (class com.test.Account), not marked as ignorable (6 known properties: "tffAccountNumber", "metaClass", "externalId", "id", "name", "annualRevenue"])
at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@68b2688d; line: 1, column: 16] (through reference chain: com.test.Account["attributes"]). Stacktrace follows:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "attributes" (class com.test.Account), not marked as ignorable (6 known properties: "tffAccountNumber", "metaClass", "externalId", "id", "name", "annualRevenue"])
at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@68b2688d; line: 1, column: 16] (through reference chain: com.test.Account["attributes"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:51)
at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:817)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:954)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1324)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1302)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:249)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:136)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3562)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2648)
at com.force.api.ResourceRepresentation.as(ResourceRepresentation.java:31)
at com.test.TestController$$EQVncaRc.testSalesforce(TestController.groovy:116)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at net.bull.javamelody.JspWrapper.invoke(JspWrapper.java:150)
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:286)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:201)
at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:178)
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
at grails.plugin.springsecurity.rest.RestAuthenticationFilter.doFilter(RestAuthenticationFilter.groovy:139)
at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:53)
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:62)
at grails.plugin.springsecurity.rest.RestLogoutFilter.doFilter(RestLogoutFilter.groovy:80)
at com.AssetFilter.doFilter(AssetFilter.groovy:55)
at com.security.XssFilter.doFilterInternal(XssFilter.groovy:17)
at grails.plugin.databasesession.SessionProxyFilter.doFilterInternal(SessionProxyFilter.java:60)

@jesperfj
Copy link
Owner

Have you tried adding

@JsonIgnoreProperties(ignoreUnknown = true)

As a class annotation on com.test.Account?

@edgartff
Copy link
Author

edgartff commented Sep 25, 2017 via email

@edgartff
Copy link
Author

edgartff commented Sep 25, 2017 via email

@jesperfj
Copy link
Owner

Which API version are you using? I am getting similar (but not necessarily same) errors when running tests with API version 40.

@jesperfj
Copy link
Owner

I am sorry but I can you clarify your question on DTO objects?

@edgartff
Copy link
Author

edgartff commented Sep 26, 2017 via email

@jesperfj
Copy link
Owner

I see.

No. It is explicitly not in scope for this project to maintain class representations of those objects. My hope is to make force-rest-api interoperate seamlessly with other projects that seek to autogenerate and maintain class representations of various Salesforce projects.

@sreekeshd
Copy link

Thanks Jesper. I did try that, and strangely, it still throws an error.

Sent from my iPhone On Sep 25, 2017, at 9:23 AM, Jesper Joergensen <notifications@github.commailto:notifications@github.com> wrote: Have you tried adding @JsonIgnoreProperties(ignoreUnknown = true) As a class annotation on com.test.Account? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<#49 (comment)>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Aa9mQL5S66vZQgJIZcE7jzRXEy4xmJKbks5sl9N2gaJpZM4Pecuj.

@edgartff I faced the same issue, due to the code recommendation suggested by my IDE. My mapper class was fasterxml.jackson but the IDE imported codehaus.jackson which conflicted with the @JsonProperty annotation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants