spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
Apache License 2.0
2.74k stars 355 forks source link

IllegalArgumentException: Parameter of type org.springframework.beans.factory.config.TypedStringValue is not supported with xml bean definitions #1687

Closed deodorel closed 1 year ago

deodorel commented 2 years ago

Hello, I am trying to convert a project to spring native, and i have a lot of bean definitions in xml. I have enabled xml support,however when the files are parsed by the aot, i am getting this error:

Caused by: java.lang.IllegalArgumentException: Parameter of type org.springframework.beans.factory.config.TypedStringValue is not supported at org.springframework.aot.context.bootstrap.generator.bean.support.ParameterWriter.writeParameterValue(ParameterWriter.java:175) at org.springframework.aot.context.bootstrap.generator.bean.support.ParameterWriter.writeParameterValue(ParameterWriter.java:81) at org.springframework.aot.context.bootstrap.generator.bean.support.ParameterWriter.writeParameterValue(ParameterWriter.java:70)

The definition in question is: `
<bean id="fixedBackOffPolicy" class="org.springframework.retry.backoff.FixedBackOffPolicy">

  <property name="backOffPeriod" value="1000">
    </property>
</bean>

`

I looked into the code of the ParameterWriter, but it's not clear to me what a TypedStringValue is.

If i remove the property definition this bean is cleared, however i can't see how can i specify properties if you can't do a simple string -> long mapping. Any suggestions?

Thanks!

mhalbritter commented 2 years ago

If you'd like us to spend some time investigating, please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem.

deodorel commented 2 years ago

Hello, thank you for your reply. I will try to prepare a simple example.

deodorel commented 2 years ago

demo.zip

i just ran mvn clean spring-boot:build-image

you will see the aot error. I noticed that the constructor injection works, while the property one / via setter does not.

zliu9125 commented 1 year ago

Same issue. By doing mvn package, which will call aot plugin, to Spring project that with xml-based bean injection may triggers IllegalArgumentException: Parameter of type org.springframework.beans.factory.config.TypedStringValue is not supported with xml bean definitions error unexpectly .

Also check sample project, in which there is no xml-based bean injection invoked.

Are there any plans to fix this or workaround action to tackle with? thanks

sdeleuze commented 1 year ago

This is likely going to be supported with Spring Framework 6, see https://github.com/spring-projects/spring-framework/issues/29074 related issue, so I would advise to switch when released and will close this issue as declined on Spring Native side.