Announcement Announcement Module
Collapse
No announcement yet.
[JavaConfig] BootstrapException: Unable to initialize group definition Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [JavaConfig] BootstrapException: Unable to initialize group definition

    Hi.

    I am trying to convert my xml-based config to Spring Java Configuration. The configuration itself is fairly easy (i've shortened the list of beans and methods massively ).
    Code:
    (at)Configuration
    public class ApplicationConfig {
    
        (at)Bean
        public MyService myService() {
            return new MyServiceImpl();
        }
    }
    This service is within an EJB:

    Code:
    (at)Stateless
    (at)LocalBinding(jndiBinding = MyService.JNDINAME)
    (at)Local(MyService.class)
    public class MyServiceBean implements MyService {
    
        private MyService service;
    
        public MyServiceBean() {}
    
        public Long request(String something) {
            initializeService();
            return service.request(something);
        }
        private void initializeService() {
            JavaConfigApplicationContext ctx = new JavaConfigApplicationContext(ApplicationConfig.class);
            service = ctx.getBean(MyService.class);
        }
    }
    I access this bean from an integration test (JUnitEE):

    Code:
    public class MyServiceTestCase extends TestCase {
    
        protected void setUp() throws Exception {
            super.setUp();
        }
    
        public void testRequest() throws Exception {
                MyService service = (MyService) new InitialContext().lookup(MyService.JNDINAME);
                Long num = service.request("ABC1234");
        }
    I run this test within JBoss 4.2.2. With the old XML config it runs perfectly. Now it doesn't:

    Code:
    java.lang.RuntimeException: org.springframework.beans.factory.access.BootstrapException: Unable to initialize group definition. Group resource name [classpath*: beanRefContext.xml]. factory key [null]; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [my.service.ApplicationConfig$$EnhancerByCGLIB$$92284d66] for bean with name 'applicationConfig' defined in  [.../my-1.17-SNAPSHOT.jar!/beanRefContext.xml]; nested exception is java.lang.ClassNotFoundException: my.service.ApplicationConfig$$EnhancerByCGLIB$$92284d66
    at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler. postConstruct(LifecycleInterceptorHandler.java:113)
    at org.jboss.ejb3.EJBContainer.invokePostConstruct(EJBContainer.java:619)
    ..
    I used autowiring earlier with the XML config. When that didn't work I hard coded it in initializeService() above. Anyway, here's the old EJB:
    Code:
    (at)Stateless
    (at)LocalBinding(jndiBinding = MyService.JNDINAME)
    (at)Local(MyService.class)
    (at)Interceptors(SpringBeanAutowiringInterceptor.class)
    public class MyServiceBean implements MyService {
    
        (at)Autowired
        private MyService service;
    
        public MyServiceBean() {}
    
        public Long request(String something) {
            return service.request(something);
        }
    }
    I actually had to use beanRefContext.xml to get the BeanFactory to define the beans even when using JavaConfig:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans ... >
        <bean id="applicationConfig" class="my.service.ApplicationConfig"/>
        <bean id="configurationPostProcessor" class="org.springframework.config.java.process.ConfigurationPostProcessor"/>
    </beans>
    Here's the old XML file:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans ... >
    
    	<bean name="myService" class="my.service.MyServiceImpl" />
    
    </beans>
Working...
X