-
Notifications
You must be signed in to change notification settings - Fork 37.7k
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
StringToClassConverter missing [SPR-6406] #11072
Comments
Martin Vanek commented After creating extremely dummy StringToClassConverter...
}
|
Keith Donald commented Hmmm, I would expect even though there is no StringToClass converter the BeanWrapper's default ClassEditor would kick in here as a fallback for compatibility reasons. |
Juergen Hoeller commented Martin, what's the stacktrace of that ConverterNotFoundException? There should be a custom ClassEditor registered which is supposed to take precedence... Are you running in a standard ApplicationContext there, with the full refresh phase having passed - i.e. not in a plain BeanFactory or the like? Juergen |
Martin Vanek commented Sorry for being late. Here is exception and it says, that Exception is thrown in WebApplicationContext. It is in context hierarchy, so it has a parent context. 2009-11-26 18:00:42,354|main |ERROR||org.mortbay.log: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ContentNegotiatingViewResolver' defined in class path resource [spring/rora-webroot.xml]: Cannot create inner bean 'org.springframework.web.servlet.view.xml.MarshallingView#1b5459e' of type [org.springframework.web.servlet.view.xml.MarshallingView] while setting bean property 'defaultViews' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.view.xml.MarshallingView#1b5459e' defined in class path resource [spring/rora-webroot.xml]: Cannot resolve reference to bean 'marshaller' while setting bean property 'marshaller'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'marshaller': Initialization of bean failed; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value [com.rora.web.model.User] from type [java.util.ArrayList] to type [[Ljava.lang.Class;]; reason = 'No converter found capable of converting from [java.lang.String] to [java.lang.Class]'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from [java.lang.String] to [java.lang.Class]: |
Martin Vanek commented Ugh! In latest snapshot org.springframework.core.convert.support.DefaultConversionService was deleted so now i'm stuck completely |
Juergen Hoeller commented You should be able to use a ConversionServiceFactoryBean (in the same package) instead. This is basically the replacement for DefaultConversionService, aligned with FormattingConversionServiceFactoryBean now. Juergen |
Keith Donald commented This is most likely happening since the string->class converter lookup occurs under the control of the conversion service as part of the collection to array converter first matched by BeanWrapper. We would indeed need a string->class converter registered then. |
Martin Vanek commented Last snapshot works for me like magic. Even with MVC validation, conversion, formatting. No custom formatter is needed anymore. Thank you guys! <bean id="AnnotationMethodHandlerAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="webBindingInitializer">
<bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="validator" ref="ValidatorFactory"/>
<property name="conversionService" ref="FormattingConversionService"/>
</bean>
</property>
</bean>
<bean id="FormattingConversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />
<bean id="ValidatorFactory" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" /> |
Juergen Hoeller commented Alright - good to hear that it works for you now! Juergen |
Martin Vanek opened SPR-6406 and commented
When new ConversionService is used,
<bean id="conversionService" class="org.springframework.core.convert.support.DefaultConversionService">
this will fail
<oxm:jaxb2-marshaller id="marshaller">
<oxm:class-to-be-bound name="com.rora.web.model.User"/>
</oxm:jaxb2-marshaller>
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from [java.lang.String] to [java.lang.Class]
Probably due to nonexisting StringToClassConverter or such... (and no registration of it in DefaultConversionService)
Affects: 3.0 RC2
The text was updated successfully, but these errors were encountered: