So I got some advice on how to do this here
http://forum.springsource.org/showthread.php?p=350974#post350974
Here are my classes/interfaces
Here is my spring applicationContext.xml setup
Here is my service class.
Ive got a struts2 mvc setup and its accessing the getEvents( ) sevice method.
I also have sessionFactory being injected into my service class. originally this was how i was originally populating the data.
Now when I run the program and eventtRepository is injected into my Services class, I get this error.
2998 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'services' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy15 implementing data.test.IEventsRepository,data.test.IAbstractHibernateRepository,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'data.EventRepository' for property 'eventtRepository'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy15 implementing data.test.IEventsRepository,data.test.IAbstractHibernateRepository,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [data.EventRepository] for property 'eventtRepository': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy15 implementing data.test.IEventsRepository,data.test.IAbstractHibernateRepository,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'data.EventRepository' for property 'eventtRepository'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy15 implementing data.test.IEventsRepository,data.test.IAbstractHibernateRepository,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [data.EventRepository] for property 'eventtRepository': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:462)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:499)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:493)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1371)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1330)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 26 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy15 implementing data.test.IEventsRepository,data.test.IAbstractHibernateRepository,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [data.EventRepository] for property 'eventtRepository': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
... 32 more
Mar 15, 2011 9:11:17 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'services' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy15 implementing data.test.IEventsRepository,data.test.IAbstractHibernateRepository,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'data.EventRepository' for property 'eventtRepository'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy15 implementing data.test.IEventsRepository,data.test.IAbstractHibernateRepository,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [data.EventRepository] for property 'eventtRepository': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy15 implementing data.test.IEventsRepository,data.test.IAbstractHibernateRepository,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'data.EventRepository' for property 'eventtRepository'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy15 implementing data.test.IEventsRepository,data.test.IAbstractHibernateRepository,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [data.EventRepository] for property 'eventtRepository': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:462)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:499)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:493)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1371)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1330)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 26 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy15 implementing data.test.IEventsRepository,data.test.IAbstractHibernateRepository,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [data.EventRepository] for property 'eventtRepository': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
... 32 more
_______________________________________________________________________________________
Ive tried using a Main class with a main method such as:
My EventRepository is fetched and it prints out the events in the mysql database.
If I use ClassPathXmlApplicationContext in my service class's getEvents( ) method directly, then I dont get the same error as
I mentioned above, and my service class works fine.
Any idea on what I need to do to allow myself to directly inject my EventRepository directly into my service class without using
the ClassPathXmlApplicationContext.
Anyone know what I'm doing wrong?
thanks.