Hello,
i tried to create a @DataLdapTest
, as seen here.
This test runs fine on the JVM, but when run with gradle nativeTest
, this fails with:
JUnit Jupiter:DataLdapTests:saveAndLoad()
MethodSource [className = 'example.ldap.odm.DataLdapTests', methodName = 'saveAndLoad', methodParameterTypes = '']
=> org.springframework.ldap.odm.core.impl.InvalidEntryException: Can't get Id field from Entry Person{dn=cn=John Doe,ou=company1,c=Sweden,dc=spring,dc=io, fullName='John Doe', lastName='Doe', description='Test user', country='Sweden', company='company1', phone='+46 555-123123'}
org.springframework.ldap.odm.core.impl.DefaultObjectDirectoryMapper.getId(DefaultObjectDirectoryMapper.java:422)
org.springframework.ldap.core.LdapTemplate.create(LdapTemplate.java:1780)
example.ldap.odm.DataLdapTests.saveAndLoad(DataLdapTests.java:28)
java.base@17.0.5/java.lang.reflect.Method.invoke(Method.java:568)
org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
[...]
Caused by: org.springframework.ldap.odm.core.impl.MetaDataException: All Entry classes must define a field with the interface org.springframework.ldap.odm.annotations.Id annotation, error in class class example.ldap.odm.Person
org.springframework.ldap.odm.core.impl.ObjectMetaData.<init>(ObjectMetaData.java:150)
org.springframework.ldap.odm.core.impl.DefaultObjectDirectoryMapper.addManagedClass(DefaultObjectDirectoryMapper.java:151)
org.springframework.ldap.odm.core.impl.DefaultObjectDirectoryMapper.getEntityData(DefaultObjectDirectoryMapper.java:108)
org.springframework.ldap.odm.core.impl.DefaultObjectDirectoryMapper.getIdField(DefaultObjectDirectoryMapper.java:428)
org.springframework.ldap.odm.core.impl.DefaultObjectDirectoryMapper.getId(DefaultObjectDirectoryMapper.java:420)
[...]
I'm not sure if this is a bug in Boot or in SF.
Comment From: sdeleuze
After a first quick look, does not look like a Framework issue.
Since this use case seems similar to http client ones, could you try to add a @RegisterReflectionForBinding(Person.class)
annotation to the sample ?
cc @jzheaux since that's related to https://github.com/spring-projects/spring-ldap/.
Comment From: mhalbritter
Oh sorry, i was under the impression that the LDAP code is in SF, sorry about that.
Since this use case seems similar to http client ones, could you try to add a @RegisterReflectionForBinding(Person.class) annotation to the sample
The strange thing is that this is running fine in native image when starting the application, but it fails in JUnit tests.
Comment From: mhalbritter
I'll close this issue and reopen it on the spring-ldap tracker.