I started my project with this sample https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-data-ldap.
But when I add the dependency spring-boot-starter-data-rest
I have
PersistentEntity must not be null!
error even if I add spring.data.rest.detectionStrategy=annotated
in application.properties
(How to disable the default exposure of Spring Data REST repositories? and https://github.com/spring-projects/spring-ldap/issues/373). I have the same error if i try this @RepositoryRestResource(exported = false)
on the PersonRepository.
Is it a bug or am I missing something?
Thanks
Person.java :
package sample.data.ldap;
import javax.naming.Name;
import org.springframework.ldap.odm.annotations.Attribute;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.annotations.Id;
@Entry(objectClasses = { "person", "top" })
public class Person {
@Id
private Name dn;
@Attribute(name = "telephoneNumber")
private String phone;
@Override
public String toString() {
return String.format("Customer[dn=%s, phone='%s']", this.dn, this.phone);
}
}
PersonRepository.java :
package sample.data.ldap;
import org.springframework.data.ldap.repository.LdapRepository;
public interface PersonRepository extends LdapRepository<Person> {
Person findByPhone(String phone);
}
error :
Caused by: java.lang.IllegalArgumentException: PersistentEntity must not be null!
at org.springframework.util.Assert.notNull(Assert.java:134)
at org.springframework.data.rest.core.mapping.RepositoryAwareResourceMetadata.<init>(RepositoryAwareResourceMetadata.java:52)
at org.springframework.data.rest.core.mapping.RepositoryResourceMappings.populateCache(RepositoryResourceMappings.java:90)
at org.springframework.data.rest.core.mapping.RepositoryResourceMappings.<init>(RepositoryResourceMappings.java:76)
at org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.resourceMappings(RepositoryRestMvcConfiguration.java:619)
at org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$$5f6eca9d.CGLIB$resourceMappings$12(<generated>)
at org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$$5f6eca9d$$FastClassBySpringCGLIB$$aab3a667.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$$5f6eca9d.resourceMappings(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 39 more
pom.xml :
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-ldap</artifactId>
</dependency>
<dependency>
<groupId>com.unboundid</groupId>
<artifactId>unboundid-ldapsdk</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
</dependencies>