Uploaded image for project: 'Spring Data for Apache Solr'
  1. Spring Data for Apache Solr
  2. DATASOLR-163

mappingContext is not set, fails when using with spring-data-rest-webmvc

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.2 RC1 (Dijkstra)
    • Fix Version/s: 1.4 M1 (Fowler)
    • Component/s: Repository
    • Labels:
    • Sprint:
      53 - Evans SR1

      Description

      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!!

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cstrobl Christoph Strobl
                Reporter:
                aaronlab Aaron LaBella
                Last updater:
                Greg Turnquist
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 1h
                  1h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified