Announcement Announcement Module
Collapse

JavaConfig forum decommissioned in favor of Core Container

As described at

http://static.springsource.org/sprin...fig/README.TXT

key features of the Spring JavaConfig project have been migrated into the core Spring Framework as of version 3.0.

Please see the Spring 3.0 documentation on @Configuration and @Bean support:

http://static.springsource.org/sprin...tml#beans-java

For any questions related to @Configuration classes and @Bean methods in Spring 3.0, please post in the dedicated 'Core Container' forum at

http://forum.springsource.org/forumdisplay.php?f=26
See more
See less
circular references Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • circular references

    Hi All,

    Great work with JavaConfig it has allowed myself and my team to solve a lot of problems with our project that would difficult or impossible to do otherwise.

    We are currently in the process of moving all of configuration from spring xml to spring java config but I am getting this error:

    Code:
    org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'userService': Requested bean is currently in creation: Is there an unresolvable circular reference?
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:296)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:215)
    	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:168)
    	at org.springframework.config.java.context.TypeSafeBeanFactoryUtils.getBean(TypeSafeBeanFactoryUtils.java:74)
    	at org.springframework.config.java.support.ConfigurationSupport.getBean(ConfigurationSupport.java:76)
    	at com.symark.smc.service.impl.Config.userGroupService(Config.java:94)
    	at com.symark.smc.service.impl.Config$$EnhancerByCGLIB$$548db0a3.CGLIB$appUserGroupService$5(<generated>)
    	at com.symark.smc.service.impl.Config$$EnhancerByCGLIB$$548db0a3$$FastClassByCGLIB$$38617fed.invoke(<generated>)
    	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:167)
    	at org.springframework.config.java.enhancement.cglib.BeanMethodMethodInterceptor$1.invokeOriginalClass(BeanMethodMethodInterceptor.java:65)
    	at org.springframework.config.java.core.MethodBeanWrapper.wrapResult(MethodBeanWrapper.java:118)
    	at org.springframework.config.java.core.StandardBeanMethodProcessor.createNewOrGetCachedSingletonBean(StandardBeanMethodProcessor.java:82)
    	... 137 more
    There are ciruclar references in the configuration but this same configuration worked just fine as spring xml. All I had to do was extend the ApplicationContext and override the AllowRawInjectionDespiteWrapping property and set it to true.

    I have done the samething with JavaConfigWebApplicationContext:

    Code:
    package com.product.web;
    
    import org.springframework.beans.factory.support.DefaultListableBeanFactory;
    import org.springframework.config.java.context.JavaConfigWebApplicationContext;
    public class MyWebApplicationContext extends JavaConfigWebApplicationContext {
    
    	protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory) {
    		beanFactory.setAllowRawInjectionDespiteWrapping(true);
    	}
    }
    And that is the class I am using in my web.xml, but it is erroring any help would be greatly appreicated.

    Thanks,
    Mike

  • #2
    Hi Mike,

    This does look a bit like a bug. To dig deeper, what would help is to have you a) create an issue in JIRA, and b) attach the simplest possible JUnit test case that reproduces the behavior. I'll take it from there.

    Thanks,

    - Chris

    Comment


    • #3
      Hi Chris,

      Thanks for your prompt reply and for all of our efforts on this project.

      I have created a JIRA here: bugs.springframework.org/browse/SJC-206

      Please let me know if there is anything I can do to help since this issue is critial for our conversion.

      Thanks
      Mike

      Comment


      • #4
        Mike,

        As you'll see in the issue, I've resolved the issue as a duplicate of an earlier related issue (SJC-94). While there are some fundamental limitations here that cannot be worked around, I'd like to make sure your conversion still goes well. If what you see in SJC-94 and the test case I've posted doesn't provide what you need, let me know. There are a number of techniques that should be able to help.

        Comment


        • #5
          Hi Chris,

          Thank you again for the quick response and all of your help. I will try the approaches that you suggested in the JIRA (SJC-94) tomorrow morning when I get to work and let you know how it goes.

          -Mike

          Comment


          • #6
            Hi Chris,

            I just wanted to post and let you know that I was able to get around my circular reference porblems by using the auto wiring as you suggested.

            Thanks,
            Mike

            Comment

            Working...
            X