Skip to content

Fix Spring native metadata after the add of spring-data-elasticsearch dependency #117

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

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

antoinebhs
Copy link
Contributor

@antoinebhs antoinebhs commented Mar 4, 2024

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method getProperty(java.lang.String) cannot be found on type org.springframework.boot.web.servlet.context.ApplicationServletEnvironment
   	at org.springframework.expression.spel.ast.MethodReference.findAccessorForMethod(MethodReference.java:225) ~[na:na]
   	at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:135) ~[na:na]
   	at org.springframework.expression.spel.ast.MethodReference$MethodValueRef.getValue(MethodReference.java:380) ~[na:na]
   	at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:96) ~[na:na]
   	at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:119) ~[org.gridsuite.directory.server.DirectoryApplication:6.0.11]
   	at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:309) ~[na:na]
   	at org.springframework.expression.common.CompositeStringExpression.getValue(CompositeStringExpression.java:108) ~[na:na]
   	at org.springframework.expression.common.CompositeStringExpression.getValue(CompositeStringExpression.java:121) ~[na:na]
   	at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity.resolve(SimpleElasticsearchPersistentEntity.java:353) ~[org.gridsuite.directory.server.DirectoryApplication:5.1.2]
   	at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity.resolve(SimpleElasticsearchPersistentEntity.java:335) ~[org.gridsuite.directory.server.DirectoryApplication:5.1.2]
   	at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity.getIndexCoordinates(SimpleElasticsearchPersistentEntity.java:134) ~[org.gridsuite.directory.server.DirectoryApplication:5.1.2]
   	at org.springframework.data.elasticsearch.client.elc.IndicesTemplate.getIndexCoordinatesFor(IndicesTemplate.java:450) ~[na:na]
   	at org.springframework.data.elasticsearch.client.elc.IndicesTemplate.getIndexCoordinates(IndicesTemplate.java:446) ~[na:na]
   	at org.springframework.data.elasticsearch.client.elc.IndicesTemplate.exists(IndicesTemplate.java:169) ~[na:na]
   	at org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.<init>(SimpleElasticsearchRepository.java:83) ~[org.gridsuite.directory.server.DirectoryApplication:5.1.2]
   	at [email protected]/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[org.gridsuite.directory.server.DirectoryApplication:na]
   	at [email protected]/java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[org.gridsuite.directory.server.DirectoryApplication:na]
   	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211) ~[na:na]
   	... 81 common frames omitted

Adding the missing method named in the stacktrace to metadata fix this issue. This issue is mentioned spring-projects/spring-boot#34206 (where they suggest to add RuntimeHints as in this PR) and spring-projects/spring-framework#29548

@antoinebhs antoinebhs force-pushed the fix-spring-native-metadata branch from 154b80a to e27915d Compare March 4, 2024 13:01
After the add of Spel in @value, this error is thrown when starting the service in native:
```Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method getProperty(java.lang.String) cannot be found on type org.springframework.boot.web.servlet.context.ApplicationServletEnvironment
   	at org.springframework.expression.spel.ast.MethodReference.findAccessorForMethod(MethodReference.java:225) ~[na:na]
   	at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:135) ~[na:na]
   	at org.springframework.expression.spel.ast.MethodReference$MethodValueRef.getValue(MethodReference.java:380) ~[na:na]
   	at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:96) ~[na:na]
   	at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:119) ~[org.gridsuite.directory.server.DirectoryApplication:6.0.11]
   	at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:309) ~[na:na]
   	at org.springframework.expression.common.CompositeStringExpression.getValue(CompositeStringExpression.java:108) ~[na:na]
   	at org.springframework.expression.common.CompositeStringExpression.getValue(CompositeStringExpression.java:121) ~[na:na]
   	at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity.resolve(SimpleElasticsearchPersistentEntity.java:353) ~[org.gridsuite.directory.server.DirectoryApplication:5.1.2]
   	at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity.resolve(SimpleElasticsearchPersistentEntity.java:335) ~[org.gridsuite.directory.server.DirectoryApplication:5.1.2]
   	at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity.getIndexCoordinates(SimpleElasticsearchPersistentEntity.java:134) ~[org.gridsuite.directory.server.DirectoryApplication:5.1.2]
   	at org.springframework.data.elasticsearch.client.elc.IndicesTemplate.getIndexCoordinatesFor(IndicesTemplate.java:450) ~[na:na]
   	at org.springframework.data.elasticsearch.client.elc.IndicesTemplate.getIndexCoordinates(IndicesTemplate.java:446) ~[na:na]
   	at org.springframework.data.elasticsearch.client.elc.IndicesTemplate.exists(IndicesTemplate.java:169) ~[na:na]
   	at org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository.<init>(SimpleElasticsearchRepository.java:83) ~[org.gridsuite.directory.server.DirectoryApplication:5.1.2]
   	at [email protected]/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[org.gridsuite.directory.server.DirectoryApplication:na]
   	at [email protected]/java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[org.gridsuite.directory.server.DirectoryApplication:na]
   	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211) ~[na:na]
   	... 81 common frames omitted```
Adding the missing method named in the stacktrace to metadata fix this issue.
@antoinebhs antoinebhs force-pushed the fix-spring-native-metadata branch from e27915d to 14f3eb4 Compare March 4, 2024 13:37
Copy link

sonarqubecloud bot commented Mar 4, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@antoinebhs antoinebhs merged commit bb06425 into main Mar 4, 2024
@antoinebhs antoinebhs deleted the fix-spring-native-metadata branch March 4, 2024 13:43
@antoinebhs antoinebhs changed the title Fix Spring native metadata after the add of Spel in @Value Fix Spring native metadata after the add of spring-data-elasticsearch dependency Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants