Hi,
i have implemented my own conversationService to add a own StringToObject-Converter.
Now i get a Exception. Has anybody a idea whats wrong?
If i remove the addConverter(myownConverter) within the Constructor of my conversationService the applikation runs fine.
I believe the error is inside my Converter.
Second Question:
Does anybody know how i inject the converter with my service? Can i use the @Autowire?
Because my exception was very long an my message to long (over 10000 chars), I cut it a little bit.
Thanks for help,
alex
The Coding:
===========
weblow-config.xml
conversationServiceCode:... <!-- Configures the Spring Web Flow JSF integration --> <faces:flow-builder-services id="facesFlowBuilderServices" conversion-service="conversionService"/> <bean id="conversionService" class="de.myapp.web.springframework.myappConversationService" /> ...
my Converter StringToUnterkunftTypCode:package de.myapp.web.springframework; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.binding.convert.service.DefaultConversionService; import de.myapp.bean.impl.UnterkunftTypImpl; import de.myapp.web.springframework.converter.StringToUnterkunftTyp; public class myappConversationService extends DefaultConversionService { private final static Log LOGGER = LogFactory .getLog(myappConversationService.class); public myappConversationService() { super(); // add my own converter here. addConverter(new StringToUnterkunftTyp()); // add my own Aliases //addAlias("unterkunftTyp", UnterkunftTypImpl.class); } }
exception:Code:package de.myapp.web.springframework.converter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.binding.convert.converters.InvalidFormatException; import org.springframework.binding.convert.converters.StringToObject; import org.springframework.util.StringUtils; import de.myapp.bean.UnterkunftTyp; import de.myapp.bean.impl.UnterkunftTypImpl; import de.myapp.service.UnterkunftTypService; public class StringToUnterkunftTyp extends StringToObject { private transient UnterkunftTypService unterkunftTypService; public StringToUnterkunftTyp() { super(UnterkunftTypImpl.class); } /* (non-Javadoc) * @see org.springframework.binding.convert.converters.StringToObject#toObject(java.lang.String, java.lang.Class) */ @Override public Object toObject(String string, Class targetClass) throws Exception { if (!StringUtils.hasText(string)) { return null; } try { return unterkunftTypService.getUnterkunftTypById(new Integer(string)); } catch (Exception e) { throw new InvalidFormatException(string, "unterkunftTyp", e); } } public String toString(Object target) throws Exception { UnterkunftTyp unterkunftTyp = (UnterkunftTyp) target; if (unterkunftTyp == null) { return ""; } return unterkunftTyp.getOid().toString(); } /** * @param unterkunftTypService the unterkunftTypService to set */ public void setUnterkunftTypService(UnterkunftTypService unterkunftTypService) { this.unterkunftTypService = unterkunftTypService; } }
Code:ERROR: org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0' defined in ServletContext resource [/WEB-INF/config/webmvc-config.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowController' defined in ServletContext resource [/WEB-INF/config/webmvc-config.xml]: Cannot resolve reference to bean 'flowExecutor' while setting bean property 'flowExecutor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowExecutor': Cannot resolve reference to bean 'flowRegistry' while setting bean property 'flowDefinitionLocator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowRegistry': Cannot resolve reference to bean 'facesFlowBuilderServices' while setting bean property 'flowBuilderServices'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'facesFlowBuilderServices': Cannot resolve reference to bean 'conversionService' while setting bean property 'conversionService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'conversionService' defined in ServletContext resource [/WEB-INF/config/webflow-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [de.myapp.web.springframework.myappConversationService]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: de.myapp.web.springframework.myappConversationService.addConverter(Lorg/springframework/binding/convert/converters/Converter;)V at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) ... ... Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'conversionService' defined in ServletContext resource [/WEB-INF/config/webflow-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [de.myapp.web.springframework.myappConversationService]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: de.myapp.web.springframework.myappConversationService.addConverter(Lorg/springframework/binding/convert/converters/Converter;)V at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:881) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:837) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) ... 91 more Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [de.myapp.web.springframework.myappConversationService]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: de.myapp.web.springframework.myappConversationService.addConverter(Lorg/springframework/binding/convert/converters/Converter;)V at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:111) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:875) ... 102 more Caused by: java.lang.NoSuchMethodError: de.myapp.web.springframework.myappConversationService.addConverter(Lorg/springframework/binding/convert/converters/Converter;)V at de.myapp.web.springframework.myappConversationService.<init>(myappConversationService.java:19) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:96) ... 104 more 20.08.2008 17:29:58 org.apache.catalina.core.StandardContext start


Reply With Quote