| View previous topic :: View next topic |
| Author |
Message |
sikeh
Joined: 15 Jan 2010 Posts: 5
|
Posted: Fri Jan 15, 2010 11:53 pm Post subject: Is Cinnamon Compatible with Spring 3 ? |
|
|
Hi all,
I'm new to Cinnamon, my spring conf looks like the following:
| Code: |
<bean id="someService" class="example.SomeClass"> <cinnamon:export-service service-interface="example.SomeInterface"/>
</bean>
|
Which works fine under Spring 2.5.6, but after I upgrade to Spring 3, the container can't create the bean anymore.
Any idea?
Regards,
Sike |
|
| Back to top |
|
 |
Jens Halm Site Admin
Joined: 21 Sep 2007 Posts: 1499 Location: Cologne Germany
|
Posted: Sat Jan 16, 2010 12:38 am Post subject: |
|
|
Hm, usually Spring people are quite good in keeping backwards compatibility so I'm a bit surprised. Does the container throw any Exceptions as an indication of what it does not like? I haven't worked with Spring 3 myself so far. _________________ Jens Halm
Spicefactory |
|
| Back to top |
|
 |
sikeh
Joined: 15 Jan 2010 Posts: 5
|
Posted: Sat Jan 16, 2010 10:26 am Post subject: |
|
|
Hi Jens,
for instance, I have
| Code: |
<bean id="importService" class="com.ucs.dca.service.ImportServiceImpl">
</bean>
<bean id="bookingService" class="com.ucs.dca.service.BookingServiceImpl">
<cinnamon:export-service service-interface="com.ucs.dca.service.BookingService"/>
</bean>
|
And it throws
| Code: |
10:23:54,780 [ERROR][ContextLoader]: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'importService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.ucs.dca.service.BookingService com.ucs.dca.service.ImportServiceImpl.bookingService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.ucs.dca.service.BookingService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1055)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:556)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
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:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
|
|
|
| Back to top |
|
 |
Jens Halm Site Admin
Joined: 21 Sep 2007 Posts: 1499 Location: Cologne Germany
|
Posted: Sat Jan 16, 2010 2:24 pm Post subject: |
|
|
Now this looks weird. The message implies that the BookingService is not available at all. I'm inclined to think that this is probably not Cinnamon-related. Could it be that they changed something in the way how and when a bean qualifies for auto-wiring?
It would be interesting to see what happens if you switch back to directly referencing the bean instead of autowiring:
| Code: | <bean id="importService" class="com.ucs.dca.service.ImportServiceImpl">
<property name="bookingService" ref="bookingService"/>
</bean>
<bean id="bookingService" class="com.ucs.dca.service.BookingServiceImpl">
<cinnamon:export-service service-interface="com.ucs.dca.service.BookingService"/>
</bean> |
If that would work then the problem is not related to Cinnamon. _________________ Jens Halm
Spicefactory |
|
| Back to top |
|
 |
sikeh
Joined: 15 Jan 2010 Posts: 5
|
Posted: Mon Jan 18, 2010 9:21 am Post subject: |
|
|
Hi Jens,
I think it's the problem of <cinnamon:export-service /> tag, if I comment this out, beans are created and injected properly under Spring 3.
Regards,
Sike |
|
| Back to top |
|
 |
Jens Halm Site Admin
Joined: 21 Sep 2007 Posts: 1499 Location: Cologne Germany
|
Posted: Mon Jan 18, 2010 1:36 pm Post subject: |
|
|
Then it must be swallowing exceptions. Or they changed something in the way custom namespace handlers are registered. Silent failure is very rare with Spring, so it really looks weird. I'll be looking into it, but it may take some time. _________________ Jens Halm
Spicefactory |
|
| Back to top |
|
 |
sikeh
Joined: 15 Jan 2010 Posts: 5
|
Posted: Mon Mar 08, 2010 7:57 pm Post subject: |
|
|
any updates on this?
Regards,
Sike |
|
| Back to top |
|
 |
wensg
Joined: 10 Mar 2010 Posts: 2
|
Posted: Thu Mar 11, 2010 10:23 am Post subject: |
|
|
I ran into the same problem when using spring 3. Apparently the AbstractBeanDefinitionParser from spring changed so that it now also registers a bean alias based on the name attribute of the element it is parsing. The 'cinnamon:export-service' tag in the following definition
<bean id="pmt-metamodelLoader" class="org.spicefactory.pimento.metamodel.impl.DefaultMetamodelLoader" lazy-init="true">
<cinnamon:export-service service-interface="org.spicefactory.pimento.metamodel.impl.MetamodelLoader"/>
</bean>
creates a bean of type "org.spicefactory.cinnamon.config.spring.SpringServiceConfig" with alias "pmt-metamodelLoader".
I was able to work around this by explicitly declaring the serviceconfig bean:
<bean id="pmt-metamodelLoader" class="org.spicefactory.pimento.metamodel.impl.DefaultMetamodelLoader" lazy-init="true"/>
<bean class="org.spicefactory.cinnamon.config.spring.SpringServiceConfig">
<constructor-arg type="java.lang.String" value="pmt-metamodelLoader"/>
<constructor-arg type="java.lang.String"><null/></constructor-arg>
<constructor-arg type="java.lang.Class" value="org.spicefactory.pimento.metamodel.impl.MetamodelLoader"/>
<constructor-arg type="java.lang.Class" value="org.spicefactory.pimento.metamodel.impl.DefaultMetamodelLoader"/>
<constructor-arg type="java.util.List"><null/></constructor-arg>
<constructor-arg type="boolean" value="true"/>
<constructor-arg type="java.lang.String"><null/></constructor-arg>
</bean> |
|
| Back to top |
|
 |
Jens Halm Site Admin
Joined: 21 Sep 2007 Posts: 1499 Location: Cologne Germany
|
Posted: Thu Mar 11, 2010 11:23 am Post subject: |
|
|
| Quote: | I ran into the same problem when using spring 3. Apparently the AbstractBeanDefinitionParser from spring changed so that it now also registers a bean alias based on the name attribute of the element it is parsing. The 'cinnamon:export-service' tag in the following definition
<bean id="pmt-metamodelLoader" class="org.spicefactory.pimento.metamodel.impl.DefaultMetamodelLoader" lazy-init="true">
<cinnamon:export-service service-interface="org.spicefactory.pimento.metamodel.impl.MetamodelLoader"/>
</bean>
creates a bean of type "org.spicefactory.cinnamon.config.spring.SpringServiceConfig" with alias "pmt-metamodelLoader". |
This sounds weird. Why should it do that? As I understand that issue that would kind of break all existing custom tags that are nested within a bean tag. Hopefully this is just a bug?
Thanks for the input though. Otherwise you did not have any issues with Spring 3 and Cinnamon? _________________ Jens Halm
Spicefactory |
|
| Back to top |
|
 |
sikeh
Joined: 15 Jan 2010 Posts: 5
|
Posted: Tue Mar 16, 2010 9:34 am Post subject: |
|
|
thanks for your help, wensg : )
however I still have a question, seems like you are using pimento, but I'm not, how should I configurate serviceconfig bean in this case?
Regards,
Sike |
|
| Back to top |
|
 |
|