org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from 'java.util.Locale' to 'java.lang.String'

Spring JIRA | Robert Stiller | 6 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Hi, i got the following exception when trying to save a java.util.Locale property: (Code is under the stacktrace) {code} java.lang.IllegalArgumentException: can't serialize class java.util.Locale at org.bson.BSONEncoder._putObjectField(BSONEncoder.java:205) at org.bson.BSONEncoder.putObject(BSONEncoder.java:121) at org.bson.BSONEncoder.putObject(BSONEncoder.java:67) at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:215) at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:180) at com.mongodb.DBCollection.insert(DBCollection.java:72) at com.mongodb.DBCollection.save(DBCollection.java:537) at com.mongodb.DBCollection.save(DBCollection.java:517) at org.springframework.data.document.mongodb.MongoTemplate$10.doInCollection(MongoTemplate.java:710) at org.springframework.data.document.mongodb.MongoTemplate.execute(MongoTemplate.java:282) at org.springframework.data.document.mongodb.MongoTemplate.saveDBObject(MongoTemplate.java:707) at org.springframework.data.document.mongodb.MongoTemplate.doSave(MongoTemplate.java:607) at org.springframework.data.document.mongodb.MongoTemplate.save(MongoTemplate.java:597) at org.springframework.data.document.mongodb.repository.SimpleMongoRepository.save(SimpleMongoRepository.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:355) at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.invoke(RepositoryFactorySupport.java:336) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy16.save(Unknown Source) at example.repo.RepositoryTest.test(RepositoryTest.java:66) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) {code} {code} package example.repo; import java.io.Serializable; import java.util.HashMap; import java.util.Locale; import java.util.Map; import org.springframework.data.annotation.Id; import org.springframework.data.document.mongodb.mapping.Document; import com.google.code.morphia.annotations.Entity; @Document(collection = "examples") @Entity public class Example implements Serializable { private static final long serialVersionUID = 2827176530940493389L; @Id protected String id; protected Locale country; protected Map<Locale, String> names = new HashMap<Locale, String>(); public Locale getCountry() { return country; } public String getId() { return id; } public Map<Locale, String> getNames() { return names; } public void setCountry(Locale newCountry) { country = newCountry; } public void setId(String newId) { id = newId; } public void setNames(Map<Locale, String> newNames) { names = newNames; } } {code} {code} package example.repo; import org.springframework.data.document.mongodb.repository.MongoRepository; import org.springframework.data.document.mongodb.repository.QueryDslPredicateExecutor; public interface ExampleService extends MongoRepository<Example, String>, QueryDslPredicateExecutor<Example> { } {code} {code} package example.repo; import java.util.Locale; import javax.inject.Inject; import junit.framework.Assert; import junit.framework.TestCase; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.data.document.mongodb.MongoTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "classpath:/testApplicationContext.xml") public class RepositoryTest extends TestCase { @Inject protected MongoTemplate template; @Inject protected ExampleService exampleService; public ExampleService getExampleService() { return exampleService; } public MongoTemplate getTemplate() { return template; } public void setExampleService(ExampleService newExampleService) { exampleService = newExampleService; } public void setTemplate(MongoTemplate newTemplate) { template = newTemplate; } @Before @Override public void setUp() throws Exception { template.dropCollection("examples"); template.createCollection("examples"); super.setUp(); } @After @Override public void tearDown() throws Exception { template.dropCollection("examples"); super.tearDown(); } @Test public void test() { Example example = new Example(); example.setCountry(Locale.GERMANY); example.getNames().put(Locale.GERMANY, "Deutschland"); example.getNames().put(Locale.US, "Germany"); example = exampleService.save(example); Assert.assertEquals(example, exampleService.findAll().get(0)); } } {code} {code} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:spring-data="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd"> <spring-data:mongo host="127.0.0.1" port="27017" id="mongo"/> <bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate"> <constructor-arg ref="mongo"/> <constructor-arg value="testdb"/> <constructor-arg> <spring-data:mapping-converter/> </constructor-arg> </bean> <spring-data:repositories base-package="example.repo" mongo-template-ref="mongoTemplate"> </spring-data:repositories> <context:annotation-config/> </beans> {code} {code} package example.repo; import java.util.Locale; import org.springframework.core.convert.converter.Converter; public class LocaleToStringConverter implements Converter<Locale, String> { public String convert(Locale source) { return source.toString(); } } {code} {code} package example.repo; import java.util.Locale; import org.springframework.core.convert.converter.Converter; import org.springframework.util.StringUtils; public class StringToLocaleConverter implements Converter<String, Locale> { public Locale convert(String source) { return StringUtils.parseLocaleString(source); } } {code} {code} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:spring-data="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd"> <spring-data:mongo host="127.0.0.1" port="27017" id="mongo"/> <bean id="mappingContext" class="org.springframework.data.document.mongodb.mapping.MongoMappingContext"/> <bean id="mongoConverter" class="org.springframework.data.document.mongodb.convert.MappingMongoConverter"> <constructor-arg ref="mappingContext"/> <property name="converters"> <set> <bean class="example.repo.LocaleToStringConverter"/> <bean class="example.repo.StringToLocaleConverter"/> </set> </property> </bean> <bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate"> <constructor-arg ref="mongo"/> <constructor-arg value="testdb"/> <constructor-arg ref="mongoConverter"/> </bean> <spring-data:repositories base-package="example.repo" mongo-template-ref="mongoTemplate"> </spring-data:repositories> <context:annotation-config/> </beans> {code} I guess the converters are not used correctly since there is a "native" support for java.util.Locale objects if using the Converter-Framework of Spring. (org.springframework.core.convert.support.StringToLocaleConverter). Another exception occures when reading a map with a Locale as key-type: (Code is under the stacktrace) To save the map i had to have to register an own Converter (see code) - it seems that the converters are not correctly used at this point too. {code} java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Locale at example.repo.RepositoryTest.test(RepositoryTest.java:70) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) {code} {code} package example.repo; import java.util.Locale; import org.springframework.core.convert.converter.Converter; import org.springframework.data.mapping.MappingBeanHelper; import org.springframework.util.StringUtils; public class StringToLocaleConverter implements Converter<String, Locale> { public Locale convert(String source) { return StringUtils.parseLocaleString(source); } public void init() { MappingBeanHelper.getConversionService().addConverter(this); MappingBeanHelper.getConversionService().addConverterFactory(new StringToLocaleConverterFactory()); } } {code} {code} package example.repo; import java.util.Locale; import org.springframework.core.convert.converter.Converter; import org.springframework.data.mapping.MappingBeanHelper; public class LocaleToStringConverter implements Converter<Locale, String> { public String convert(Locale source) { return source.toString(); } public void init() { MappingBeanHelper.getConversionService().addConverter(this); } } {code} {code} package example.repo; import java.io.Serializable; import java.util.HashMap; import java.util.Locale; import java.util.Map; import org.springframework.data.annotation.Id; import org.springframework.data.document.mongodb.mapping.Document; import com.google.code.morphia.annotations.Entity; @Document(collection = "examples") @Entity public class Example implements Serializable { private static final long serialVersionUID = 2827176530940493389L; @Id protected String id; // protected Locale country; protected Map<Locale, String> names = new HashMap<Locale, String>(); // public Locale getCountry() { // return country; // } @Override public boolean equals(Object obj) { Example ex = (Example) obj; return id.equals(ex.id) && names.equals(ex.names); } public String getId() { return id; } public Map<Locale, String> getNames() { return names; } // public void setCountry(Locale newCountry) { // country = newCountry; // } public void setId(String newId) { id = newId; } public void setNames(Map<Locale, String> newNames) { names = newNames; } } {code} {code} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:spring-data="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd"> <spring-data:mongo host="127.0.0.1" port="27017" id="mongo"/> <bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate"> <constructor-arg ref="mongo"/> <constructor-arg value="testdb"/> <constructor-arg> <spring-data:mapping-converter/> </constructor-arg> </bean> <spring-data:repositories base-package="example.repo" mongo-template-ref="mongoTemplate"> </spring-data:repositories> <bean class="example.repo.LocaleToStringConverter" init-method="init" depends-on="mongoTemplate"/> <bean class="example.repo.StringToLocaleConverter" init-method="init" depends-on="mongoTemplate"/> <context:annotation-config/> </beans> {code} {code} package example.repo; import java.util.Locale; import java.util.Map; import javax.inject.Inject; import junit.framework.Assert; import junit.framework.TestCase; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.data.document.mongodb.MongoTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "classpath:/testApplicationContext.xml") public class RepositoryTest extends TestCase { @Inject protected MongoTemplate template; @Inject protected ExampleService exampleService; public ExampleService getExampleService() { return exampleService; } public MongoTemplate getTemplate() { return template; } public void setExampleService(ExampleService newExampleService) { exampleService = newExampleService; } public void setTemplate(MongoTemplate newTemplate) { template = newTemplate; } @Before @Override public void setUp() throws Exception { template.dropCollection("examples"); template.createCollection("examples"); super.setUp(); } @After @Override public void tearDown() throws Exception { template.dropCollection("examples"); super.tearDown(); } @Test public void test() { Example example = new Example(); // example.setCountry(Locale.GERMANY); example.getNames().put(Locale.GERMANY, "Deutschland"); example.getNames().put(Locale.US, "Germany"); example = exampleService.save(example); for (Map.Entry<Locale, String> entry : exampleService.findAll().get(0).getNames().entrySet()) { System.out.println(entry.getKey().getCountry()); System.out.println(entry.getValue()); } Assert.assertEquals(example, exampleService.findAll().get(0)); } } {code} {code} If i hadn't registered my own converter the following exception were thrown (even with "native" Converter Support from Spring-Converter-Framework for java.util.Locale): org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from 'java.util.Locale' to 'java.lang.String' at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:181) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:133) at org.springframework.data.document.mongodb.convert.MappingMongoConverter.writeMapInternal(MappingMongoConverter.java:511) at org.springframework.data.document.mongodb.convert.MappingMongoConverter.writePropertyInternal(MappingMongoConverter.java:480) at org.springframework.data.document.mongodb.convert.MappingMongoConverter$4.doWithPersistentProperty(MappingMongoConverter.java:372) at org.springframework.data.mapping.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:189) at org.springframework.data.document.mongodb.convert.MappingMongoConverter.write(MappingMongoConverter.java:358) at org.springframework.data.document.mongodb.convert.MappingMongoConverter.write(MappingMongoConverter.java:323) at org.springframework.data.document.mongodb.MongoTemplate.doSave(MongoTemplate.java:604) at org.springframework.data.document.mongodb.MongoTemplate.save(MongoTemplate.java:597) at org.springframework.data.document.mongodb.repository.SimpleMongoRepository.save(SimpleMongoRepository.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:355) at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.invoke(RepositoryFactorySupport.java:336) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy16.save(Unknown Source) at example.repo.RepositoryTest.test(RepositoryTest.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) {code} I hope these information help you a little bit when trying to fix this.

    Spring JIRA | 6 years ago | Robert Stiller
    org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from 'java.util.Locale' to 'java.lang.String'
  2. 0

    Hi, i got the following exception when trying to save a java.util.Locale property: (Code is under the stacktrace) {code} java.lang.IllegalArgumentException: can't serialize class java.util.Locale at org.bson.BSONEncoder._putObjectField(BSONEncoder.java:205) at org.bson.BSONEncoder.putObject(BSONEncoder.java:121) at org.bson.BSONEncoder.putObject(BSONEncoder.java:67) at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:215) at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:180) at com.mongodb.DBCollection.insert(DBCollection.java:72) at com.mongodb.DBCollection.save(DBCollection.java:537) at com.mongodb.DBCollection.save(DBCollection.java:517) at org.springframework.data.document.mongodb.MongoTemplate$10.doInCollection(MongoTemplate.java:710) at org.springframework.data.document.mongodb.MongoTemplate.execute(MongoTemplate.java:282) at org.springframework.data.document.mongodb.MongoTemplate.saveDBObject(MongoTemplate.java:707) at org.springframework.data.document.mongodb.MongoTemplate.doSave(MongoTemplate.java:607) at org.springframework.data.document.mongodb.MongoTemplate.save(MongoTemplate.java:597) at org.springframework.data.document.mongodb.repository.SimpleMongoRepository.save(SimpleMongoRepository.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:355) at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.invoke(RepositoryFactorySupport.java:336) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy16.save(Unknown Source) at example.repo.RepositoryTest.test(RepositoryTest.java:66) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) {code} {code} package example.repo; import java.io.Serializable; import java.util.HashMap; import java.util.Locale; import java.util.Map; import org.springframework.data.annotation.Id; import org.springframework.data.document.mongodb.mapping.Document; import com.google.code.morphia.annotations.Entity; @Document(collection = "examples") @Entity public class Example implements Serializable { private static final long serialVersionUID = 2827176530940493389L; @Id protected String id; protected Locale country; protected Map<Locale, String> names = new HashMap<Locale, String>(); public Locale getCountry() { return country; } public String getId() { return id; } public Map<Locale, String> getNames() { return names; } public void setCountry(Locale newCountry) { country = newCountry; } public void setId(String newId) { id = newId; } public void setNames(Map<Locale, String> newNames) { names = newNames; } } {code} {code} package example.repo; import org.springframework.data.document.mongodb.repository.MongoRepository; import org.springframework.data.document.mongodb.repository.QueryDslPredicateExecutor; public interface ExampleService extends MongoRepository<Example, String>, QueryDslPredicateExecutor<Example> { } {code} {code} package example.repo; import java.util.Locale; import javax.inject.Inject; import junit.framework.Assert; import junit.framework.TestCase; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.data.document.mongodb.MongoTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "classpath:/testApplicationContext.xml") public class RepositoryTest extends TestCase { @Inject protected MongoTemplate template; @Inject protected ExampleService exampleService; public ExampleService getExampleService() { return exampleService; } public MongoTemplate getTemplate() { return template; } public void setExampleService(ExampleService newExampleService) { exampleService = newExampleService; } public void setTemplate(MongoTemplate newTemplate) { template = newTemplate; } @Before @Override public void setUp() throws Exception { template.dropCollection("examples"); template.createCollection("examples"); super.setUp(); } @After @Override public void tearDown() throws Exception { template.dropCollection("examples"); super.tearDown(); } @Test public void test() { Example example = new Example(); example.setCountry(Locale.GERMANY); example.getNames().put(Locale.GERMANY, "Deutschland"); example.getNames().put(Locale.US, "Germany"); example = exampleService.save(example); Assert.assertEquals(example, exampleService.findAll().get(0)); } } {code} {code} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:spring-data="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd"> <spring-data:mongo host="127.0.0.1" port="27017" id="mongo"/> <bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate"> <constructor-arg ref="mongo"/> <constructor-arg value="testdb"/> <constructor-arg> <spring-data:mapping-converter/> </constructor-arg> </bean> <spring-data:repositories base-package="example.repo" mongo-template-ref="mongoTemplate"> </spring-data:repositories> <context:annotation-config/> </beans> {code} {code} package example.repo; import java.util.Locale; import org.springframework.core.convert.converter.Converter; public class LocaleToStringConverter implements Converter<Locale, String> { public String convert(Locale source) { return source.toString(); } } {code} {code} package example.repo; import java.util.Locale; import org.springframework.core.convert.converter.Converter; import org.springframework.util.StringUtils; public class StringToLocaleConverter implements Converter<String, Locale> { public Locale convert(String source) { return StringUtils.parseLocaleString(source); } } {code} {code} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:spring-data="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd"> <spring-data:mongo host="127.0.0.1" port="27017" id="mongo"/> <bean id="mappingContext" class="org.springframework.data.document.mongodb.mapping.MongoMappingContext"/> <bean id="mongoConverter" class="org.springframework.data.document.mongodb.convert.MappingMongoConverter"> <constructor-arg ref="mappingContext"/> <property name="converters"> <set> <bean class="example.repo.LocaleToStringConverter"/> <bean class="example.repo.StringToLocaleConverter"/> </set> </property> </bean> <bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate"> <constructor-arg ref="mongo"/> <constructor-arg value="testdb"/> <constructor-arg ref="mongoConverter"/> </bean> <spring-data:repositories base-package="example.repo" mongo-template-ref="mongoTemplate"> </spring-data:repositories> <context:annotation-config/> </beans> {code} I guess the converters are not used correctly since there is a "native" support for java.util.Locale objects if using the Converter-Framework of Spring. (org.springframework.core.convert.support.StringToLocaleConverter). Another exception occures when reading a map with a Locale as key-type: (Code is under the stacktrace) To save the map i had to have to register an own Converter (see code) - it seems that the converters are not correctly used at this point too. {code} java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Locale at example.repo.RepositoryTest.test(RepositoryTest.java:70) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) {code} {code} package example.repo; import java.util.Locale; import org.springframework.core.convert.converter.Converter; import org.springframework.data.mapping.MappingBeanHelper; import org.springframework.util.StringUtils; public class StringToLocaleConverter implements Converter<String, Locale> { public Locale convert(String source) { return StringUtils.parseLocaleString(source); } public void init() { MappingBeanHelper.getConversionService().addConverter(this); MappingBeanHelper.getConversionService().addConverterFactory(new StringToLocaleConverterFactory()); } } {code} {code} package example.repo; import java.util.Locale; import org.springframework.core.convert.converter.Converter; import org.springframework.data.mapping.MappingBeanHelper; public class LocaleToStringConverter implements Converter<Locale, String> { public String convert(Locale source) { return source.toString(); } public void init() { MappingBeanHelper.getConversionService().addConverter(this); } } {code} {code} package example.repo; import java.io.Serializable; import java.util.HashMap; import java.util.Locale; import java.util.Map; import org.springframework.data.annotation.Id; import org.springframework.data.document.mongodb.mapping.Document; import com.google.code.morphia.annotations.Entity; @Document(collection = "examples") @Entity public class Example implements Serializable { private static final long serialVersionUID = 2827176530940493389L; @Id protected String id; // protected Locale country; protected Map<Locale, String> names = new HashMap<Locale, String>(); // public Locale getCountry() { // return country; // } @Override public boolean equals(Object obj) { Example ex = (Example) obj; return id.equals(ex.id) && names.equals(ex.names); } public String getId() { return id; } public Map<Locale, String> getNames() { return names; } // public void setCountry(Locale newCountry) { // country = newCountry; // } public void setId(String newId) { id = newId; } public void setNames(Map<Locale, String> newNames) { names = newNames; } } {code} {code} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:spring-data="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd"> <spring-data:mongo host="127.0.0.1" port="27017" id="mongo"/> <bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate"> <constructor-arg ref="mongo"/> <constructor-arg value="testdb"/> <constructor-arg> <spring-data:mapping-converter/> </constructor-arg> </bean> <spring-data:repositories base-package="example.repo" mongo-template-ref="mongoTemplate"> </spring-data:repositories> <bean class="example.repo.LocaleToStringConverter" init-method="init" depends-on="mongoTemplate"/> <bean class="example.repo.StringToLocaleConverter" init-method="init" depends-on="mongoTemplate"/> <context:annotation-config/> </beans> {code} {code} package example.repo; import java.util.Locale; import java.util.Map; import javax.inject.Inject; import junit.framework.Assert; import junit.framework.TestCase; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.data.document.mongodb.MongoTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "classpath:/testApplicationContext.xml") public class RepositoryTest extends TestCase { @Inject protected MongoTemplate template; @Inject protected ExampleService exampleService; public ExampleService getExampleService() { return exampleService; } public MongoTemplate getTemplate() { return template; } public void setExampleService(ExampleService newExampleService) { exampleService = newExampleService; } public void setTemplate(MongoTemplate newTemplate) { template = newTemplate; } @Before @Override public void setUp() throws Exception { template.dropCollection("examples"); template.createCollection("examples"); super.setUp(); } @After @Override public void tearDown() throws Exception { template.dropCollection("examples"); super.tearDown(); } @Test public void test() { Example example = new Example(); // example.setCountry(Locale.GERMANY); example.getNames().put(Locale.GERMANY, "Deutschland"); example.getNames().put(Locale.US, "Germany"); example = exampleService.save(example); for (Map.Entry<Locale, String> entry : exampleService.findAll().get(0).getNames().entrySet()) { System.out.println(entry.getKey().getCountry()); System.out.println(entry.getValue()); } Assert.assertEquals(example, exampleService.findAll().get(0)); } } {code} {code} If i hadn't registered my own converter the following exception were thrown (even with "native" Converter Support from Spring-Converter-Framework for java.util.Locale): org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from 'java.util.Locale' to 'java.lang.String' at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:181) at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:133) at org.springframework.data.document.mongodb.convert.MappingMongoConverter.writeMapInternal(MappingMongoConverter.java:511) at org.springframework.data.document.mongodb.convert.MappingMongoConverter.writePropertyInternal(MappingMongoConverter.java:480) at org.springframework.data.document.mongodb.convert.MappingMongoConverter$4.doWithPersistentProperty(MappingMongoConverter.java:372) at org.springframework.data.mapping.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:189) at org.springframework.data.document.mongodb.convert.MappingMongoConverter.write(MappingMongoConverter.java:358) at org.springframework.data.document.mongodb.convert.MappingMongoConverter.write(MappingMongoConverter.java:323) at org.springframework.data.document.mongodb.MongoTemplate.doSave(MongoTemplate.java:604) at org.springframework.data.document.mongodb.MongoTemplate.save(MongoTemplate.java:597) at org.springframework.data.document.mongodb.repository.SimpleMongoRepository.save(SimpleMongoRepository.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:355) at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.invoke(RepositoryFactorySupport.java:336) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy16.save(Unknown Source) at example.repo.RepositoryTest.test(RepositoryTest.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) {code} I hope these information help you a little bit when trying to fix this.

    Spring JIRA | 6 years ago | Robert Stiller
    org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from 'java.util.Locale' to 'java.lang.String'
  3. 0

    Entity report does not work

    GitHub | 2 years ago | Mark-de-Haan
    org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.util.HashMap<?, ?> to type java.lang.String
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Configurar Grails con MySql | groovy | Iteramos.com

    iteramos.com | 1 year ago
    org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.Class<?> to type java.lang.String
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.springframework.core.convert.ConverterNotFoundException

    No converter found capable of converting from 'java.util.Locale' to 'java.lang.String'

    at org.springframework.core.convert.support.GenericConversionService.convert()
  2. Spring Core
    GenericConversionService.convert
    1. org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:181)
    2. org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:133)
    2 frames
  3. org.springframework.data
    MappingMongoConverter$4.doWithPersistentProperty
    1. org.springframework.data.document.mongodb.convert.MappingMongoConverter.writeMapInternal(MappingMongoConverter.java:511)
    2. org.springframework.data.document.mongodb.convert.MappingMongoConverter.writePropertyInternal(MappingMongoConverter.java:480)
    3. org.springframework.data.document.mongodb.convert.MappingMongoConverter$4.doWithPersistentProperty(MappingMongoConverter.java:372)
    3 frames
  4. Spring Data Core
    BasicPersistentEntity.doWithProperties
    1. org.springframework.data.mapping.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:189)
    1 frame
  5. org.springframework.data
    SimpleMongoRepository.save
    1. org.springframework.data.document.mongodb.convert.MappingMongoConverter.write(MappingMongoConverter.java:358)
    2. org.springframework.data.document.mongodb.convert.MappingMongoConverter.write(MappingMongoConverter.java:323)
    3. org.springframework.data.document.mongodb.MongoTemplate.doSave(MongoTemplate.java:604)
    4. org.springframework.data.document.mongodb.MongoTemplate.save(MongoTemplate.java:597)
    5. org.springframework.data.document.mongodb.repository.SimpleMongoRepository.save(SimpleMongoRepository.java:68)
    5 frames
  6. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    4. java.lang.reflect.Method.invoke(Unknown Source)
    4 frames
  7. Spring Data Core
    RepositoryFactorySupport$QueryExecuterMethodInterceptor.invoke
    1. org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:355)
    2. org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.invoke(RepositoryFactorySupport.java:336)
    2 frames
  8. Spring AOP
    JdkDynamicAopProxy.invoke
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    2 frames
  9. Unknown
    $Proxy16.save
    1. $Proxy16.save(Unknown Source)
    1 frame
  10. example.repo
    RepositoryTest.test
    1. example.repo.RepositoryTest.test(RepositoryTest.java:67)
    1 frame
  11. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    4. java.lang.reflect.Method.invoke(Unknown Source)
    4 frames
  12. JUnit
    RunBefores.evaluate
    1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    5. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    5 frames
  13. Spring TestContext
    RunBeforeTestMethodCallbacks.evaluate
    1. org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    1 frame
  14. JUnit
    RunAfters.evaluate
    1. org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    1 frame
  15. Spring TestContext
    SpringJUnit4ClassRunner.runChild
    1. org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
    2. org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    3. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
    3 frames
  16. JUnit
    ParentRunner$2.evaluate
    1. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    2. org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    3. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    4. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    5. org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    6. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    6 frames
  17. Spring TestContext
    RunAfterTestClassCallbacks.evaluate
    1. org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    2. org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    2 frames
  18. JUnit
    ParentRunner.run
    1. org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    1 frame
  19. Spring TestContext
    SpringJUnit4ClassRunner.run
    1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
    1 frame
  20. JUnit4 Runner
    JUnit4TestReference.run
    1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    1 frame
  21. JUnit3 Runner
    RemoteTestRunner.main
    1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    5 frames