Announcement Announcement Module
Collapse
No announcement yet.
@Configurable at web bundle and service bundle Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Configurable at web bundle and service bundle

    I have two bundles in my project: test.web and test.service. Both of them had spring-configured enabled for @Configurable. When the service project tried to instantiate an @Configurable object, autowiring failed. The service bundle seemed to have inherited the context of the web bundle which didn't contain any autowire candidates. When spring-configured was disabled in the web bundle, @Configurable worked fine in the service bundle. I have attached a sample project to demonstrate the problem.

    To recreate the problem, make sure
    Code:
    	<context:spring-configured />
    is enabled in net.test.web/src/main/webapp/META-INF/spring/applicationContext.xml. Build and deploy the par with dm Server version 2.0.2.CI-547. Note that earlier versions wouldn't show the symptons because of DMS-2490. After the par is successfully deployed, start a web browser and navigate to http://localhost:8080/test/create.htm. Autowiring fails with exception
    Code:
    [2010-05-08 21:32:14.837] http-8080-2                  o.a.c.core.ContainerBase.[Catalina].[localhost].[/test].[test]    Servlet.service() for servlet test threw exception org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [java.lang.Double] 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.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:896)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:765)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:680)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:475)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:280)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1055)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:374)
    	at org.springframework.beans.factory.wiring.BeanConfigurerSupport.configureBean(BeanConfigurerSupport.java:140)
    	at org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect.configureBean(AnnotationBeanConfigurerAspect.aj:59)
    	at org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect.ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(AbstractDependencyInjectionAspect.aj:89)
    	at net.test.service.impl.Apple.<init>(Apple.java:17)
    	at net.test.service.impl.CreateObject.createObject(CreateObject.java:12)
    	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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    Commenting out spring-configured would resolve the issue, at the same timing, disabling @Configurable.

    This problem also appeared in dm Server version 1.0.
    Last edited by candy.chiu.ad; May 10th, 2010, 12:22 AM.

  • #2
    I created another test project which includes 3 bundles: test.serviceapple, test.servicepear, test.web. Both service bundles used @Configurable and had spring-configured enabled. The web bundle didn't enable spring-configured. It turned out that all spring-configured bundles shared the last spring-configured bundle's context. For example, if test.servicepear was scanned and deployed by the dm server before test.serviceapple, test.servicepear would see test.serviceapple's context when new is called on an @Configurable class within test.servicepear.

    This also explains the observation in my original post about service bundles picking the context of the web bundle since web bundle was the last bundle spring-configured in the original example.

    I have included another test project to demonstrate this problem. Navigate to http://localhost:8080/test/createApple.htm and http://localhost:8080/test/createPear.htm after the par is deployed sucessfully. One of the links would fail with the same exception in the previous post, and the other would return without exception depending on the order in which the bundles are deployed. This example can only be run in dm Server version 1.0. The same issue should exist in version 2.0.
    Last edited by candy.chiu.ad; May 10th, 2010, 12:24 AM.

    Comment


    • #3
      This issue has been previously raised at here. There is a fix provided in a forum post. It seems that the solution needs to be integrated into the spring.aspects bundle? If not, could anyone provide clearer direction as to how to fix this problem? Thanks.

      Comment


      • #4
        The problem described in DMS-2490 has been fixed in 2.0.2.RELEASE.

        Comment

        Working...
        X