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

mappingContext is not set, fails when using with spring-data-rest-webmvc [DATASOLR-163] #285

Closed
spring-projects-issues opened this issue May 13, 2014 · 11 comments
Assignees
Labels
in: repository type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented May 13, 2014

Aaron LaBella opened DATASOLR-163 and commented

I'm trying to have spring-data-solr and spring-data-rest-webmvc work together. Apologies in advance if I'm doing something wrong, or missing some configuration/setting, there doesn't seem to be any great examples on the web of integrating these two components. From what I can see, after setting breakpoints and debugging things in my local environment, the mappingContext is not being set by org.springframework.data.solr.repository.support.SolrRepositoryFactoryBean, which results in the following exception when running queries against my solr-repositories:

java.lang.IllegalArgumentException: Cannot create self link for class com.ibm.cayce.coy.domain.Product! No persistent entity found!
	at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.getSelfLinkFor(PersistentEntityResourceAssembler.java:81)
	at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:64)
	at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.entitiesToResources(AbstractRepositoryRestController.java:229)
	at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.resultToResources(AbstractRepositoryRestController.java:209)
	at org.springframework.data.rest.webmvc.RepositorySearchController.executeQueryMethod(RepositorySearchController.java:222)
	at org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:135)

From my debugging:

org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport:getPersistentEntity() is returning null because the mappingContext is always null.

I'm attaching a simple patch that "fixes" things and makes it work, but, I'm not familiar enough with the code base to know if its the "right" fix. There's probably a better place to call setMappingContext than where I added it, it was mostly just a test to see if that fixes things, and sure enough it does.

Can someone look at this asap and commit a proper fix?
Thanks!!


Affects: 1.2 RC1 (Dijkstra)

Attachments:

Issue Links:

  • DATAREST-387 Add tests for SD Solr Repositories
    ("is depended on by")
  • DATAREST-227 Extract test functions from AbstractWebIntegrationTest for general reuse

1 votes, 4 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented May 17, 2014

Jega A commented

Aaron - I just encountered the exact same issue while trying to use spring-data-solr with spring-data-rest-webmvc. I will check out your patch. Thanks

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented May 19, 2014

Jega A commented

Even after applying this patch I get the same error. In fact the patched class does not seemed to be called at all during execution. Where/when actually does the class org.springframework.data.solr.repository.support/SolrRepositoryFactoryBean.java is being called? Thanks

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 5, 2014

Aaron LaBella commented

I confirmed with Jega that this patch does in-fact work. Can this be committed into the latest snapshot please?

Thanks

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 5, 2014

Christoph Strobl commented

Thank you for opening this - SD Solr has till now not been officially tested with SD Rest. We'll work on that.

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 5, 2014

Jega A commented

I can confirm that the patch that Aaron provided is working. I am currently using a jar file that I patched using Aaron's fix and it is working fine. It would be great to have this fix in the latest snapshot. Thanks

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 6, 2014

Aaron LaBella commented

Thanks Chris ... I appreciate it. Having SD Solr fully tested and working with SD Rest would be awesome. Let me know if I can do anything to help. I also just found that the FacetPage, which works fine when talking to solr is not serialized properly by SD Rest (or whoever serializes it). In other words, the FacetPage does contain the facets, but, the returned JSON does not.

Oh, and for what it's worth, after applying this patch, I did test all the CRUD operations via SD Rest using a SD Solr repository, and everything works pretty much flawlessly, including PATCH/partial updates. So, in general, I think its pretty close to functional.

Thanks!

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 6, 2014

Jega A commented

Aaron - I ran into the same issue of the facets not being returned by the SD Rest service. I have filed a ticket with the SD Rest (https://jira.spring.io/browse/DATAREST-309).
As a workaround I created a service interface and and implementation to the service. I exposed the service implementation as a REST services. Now when I call the service directly (not the Repository) then the facet results are being returned.

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 18, 2014

Aaron LaBella commented

Hi Chris,

Any updates here? Have been able to take a look at the issue and attached fix? Is this something we can get merged/committed/pushed soon?

Thanks

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 22, 2014

Christoph Strobl commented

Hi, I contacted Greg who is into sd-rest. He promised to have a look. I'll try to have one myself later this week

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 14, 2014

Aaron LaBella commented

Chris,

Any updates?
Thanks

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 16, 2014

Greg Turnquist commented

This attached JIRA issue shows a fundamental change to SD Rest's test suite. When that issue is closed, this issue will require a rebase based on change in test tools

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

No branches or pull requests

2 participants