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

"Projection type must be an interface" #85

Closed
kopax opened this issue Jan 16, 2017 · 4 comments
Closed

"Projection type must be an interface" #85

kopax opened this issue Jan 16, 2017 · 4 comments
Assignees
Labels
Milestone

Comments

@kopax
Copy link

kopax commented Jan 16, 2017

I have tried to create Projection and exclude some field but I have the following error :

"Projection type must be an interface" 

Could this be related to spring-data-mybatis ?

@easybest
Copy link
Owner

can you show me your test case code?

@easybest easybest self-assigned this Feb 1, 2017
@easybest easybest added the bug label Feb 1, 2017
@easybest easybest added this to the 1.0.8 milestone Feb 1, 2017
@kopax
Copy link
Author

kopax commented Feb 2, 2017

I have created a repo https://github.com/kopax/spring-data-mybatis-testing

You need to checkout the "projection" branch

$ git clone git@github.com:kopax/spring-data-mybatis-testing.git
$ git checkout projection
$ ./gradlew build --info && java -jar build/libs/spring-data-mybatis-testing-0.1.0.war
$ curl http://localhost:8080/siteContents
{"timestamp":1486030282864,"status":500,"error":"Internal Server Error","exception":"org.springframework.http.converter.HttpMessageNotWritableException","message":"Could not write content: Projection type must be an interface! (through reference chain: org.springframework.hateoas.Resources[\"_embedded\"]->java.util.Collections$UnmodifiableMap[\"siteContents\"]->java.util.ArrayList[0]->org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module$ProjectionResource[\"content\"]->com.sun.proxy.$Proxy118[\"siteFunction\"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Projection type must be an interface! (through reference chain: org.springframework.hateoas.Resources[\"_embedded\"]->java.util.Collections$UnmodifiableMap[\"siteContents\"]->java.util.ArrayList[0]->org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module$ProjectionResource[\"content\"]->com.sun.proxy.$Proxy118[\"siteFunction\"])","path":"/siteContents"}

I was not able to load the context to query my endpoints this is why I wasn't able to provide a sscce.org

@easybest
Copy link
Owner

easybest commented Feb 2, 2017

@easybest easybest closed this as completed Feb 2, 2017
@kopax
Copy link
Author

kopax commented Feb 2, 2017

I have tested in my project where I have a more complex object structure, The error is still the same :

I have updated the test case on branch extendxml

$ git clone git@github.com:kopax/spring-data-mybatis-testing.git
$ git checkout projection
$ ./gradlew build --info && java -jar build/libs/spring-data-mybatis-testing-0.1.0.war
$ curl http://localhost:8080/siteServices

Expect

HTTP 200

Result

2017-02-02 23:41:46.665  WARN 10352 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: Projection type must be an interface! (through reference chain: org.springframework.hateoas.Resources["_embedded"]->java.util.Collections$UnmodifiableMap["siteServices"]->java.util.ArrayList[0]->org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module$ProjectionResource["content"]->com.sun.proxy.$Proxy102["translateMessage"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Projection type must be an interface! (through reference chain: org.springframework.hateoas.Resources["_embedded"]->java.util.Collections$UnmodifiableMap["siteServices"]->java.util.ArrayList[0]->org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module$ProjectionResource["content"]->com.sun.proxy.$Proxy102["translateMessage"])

I am using an interface TranslateMessageInterface for creating "translateMessage" which allow me to keep the logic of it in I18nId.java

It appeart that this line is an issue for the projection

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

No branches or pull requests

2 participants