org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooBar' defined in class path resource [spring/foo-context.xml]: Initialization of bean failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 10

Spring JIRA | Tom Ziemer | 6 years ago
  1. 0

    Sometimes, mostly after app-server restarts or simple ear-redeployments we encounter a bean creation issue: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooBar' defined in class path resource [spring/foo-context.xml]: Initialization of bean failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 10 The project consists of around 500 beans, 20% prototypes. Only some singletons are advised, using <aop:config> - Prototypes are injecting using org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean. If the issue occurs it always affects the first request and only the first request - all following requests pass. We were unable to reproduce the issue on a small-scale project. Nevertheless, we were able to trace the issue down to AspectJ and filed a bug: http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg12764.html https://bugs.eclipse.org/bugs/show_bug.cgi?id=337855 As a workaround, we replaced AspectJ with SpringAOP, which appears to be working well. While this certainly seems to be an AspectJ issue, the stacktrace below shows, that AbstractAdvisorAutoProxyCreator is also involved. This is rather surprising for me, since, as I said, only a few singletons are advised, yet it looks like AbstractAdvisorAutoProxyCreator is called during the ObjectFactoryCreatingFactoryBean.getObject() method which creates my AOP-free prototypes. Is this really intended and necessary? Full stacktrace: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooBar' defined in class path resource [spring/foo-context.xml]: Initialization of bean failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 10 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.doGetBean(AbstractBeanFactory.java:310) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean$TargetBeanObjectFactory.getObject(ObjectFactoryCreatingFactoryBean.java:146) at foo.bar.baz.a.b.c.foo(C.java:99) at foo.bar.baz.service.X.Y(Z.java:161) at foo.bar.baz.servlet.K.bar(M.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3587) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) java.lang.ArrayIndexOutOfBoundsException: 10 at java.util.ArrayList.add(ArrayList.java:352) at org.aspectj.weaver.ReferenceType.addDependentType(ReferenceType.java:115) at org.aspectj.weaver.ReferenceType.<init>(ReferenceType.java:95) at org.aspectj.weaver.TypeFactory.createParameterizedType(TypeFactory.java:43) at org.aspectj.weaver.reflect.JavaLangTypeToResolvedTypeConverter.fromType(JavaLangTypeToResolvedTypeConverter.java:88) at org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate.getSuperclass(Java15ReflectionBasedReferenceTypeDelegate.java:148) at org.aspectj.weaver.ReferenceType.getSuperclass(ReferenceType.java:906) at org.aspectj.weaver.patterns.KindedPointcut.fastMatch(KindedPointcut.java:144) at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.couldMatchJoinPointsInType(PointcutExpressionImpl.java:82) at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:238) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254) at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean$TargetBeanObjectFactory.getObject(ObjectFactoryCreatingFactoryBean.java:146) at foo.bar.baz.a.b.c.foo(C.java:99) at foo.bar.baz.service.X.Y(Z.java:161) at foo.bar.baz.servlet.K.bar(M.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3587) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

    Spring JIRA | 6 years ago | Tom Ziemer
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooBar' defined in class path resource [spring/foo-context.xml]: Initialization of bean failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 10
  2. 0

    Sometimes, mostly after app-server restarts or simple ear-redeployments we encounter a bean creation issue: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooBar' defined in class path resource [spring/foo-context.xml]: Initialization of bean failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 10 The project consists of around 500 beans, 20% prototypes. Only some singletons are advised, using <aop:config> - Prototypes are injecting using org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean. If the issue occurs it always affects the first request and only the first request - all following requests pass. We were unable to reproduce the issue on a small-scale project. Nevertheless, we were able to trace the issue down to AspectJ and filed a bug: http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg12764.html https://bugs.eclipse.org/bugs/show_bug.cgi?id=337855 As a workaround, we replaced AspectJ with SpringAOP, which appears to be working well. While this certainly seems to be an AspectJ issue, the stacktrace below shows, that AbstractAdvisorAutoProxyCreator is also involved. This is rather surprising for me, since, as I said, only a few singletons are advised, yet it looks like AbstractAdvisorAutoProxyCreator is called during the ObjectFactoryCreatingFactoryBean.getObject() method which creates my AOP-free prototypes. Is this really intended and necessary? Full stacktrace: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooBar' defined in class path resource [spring/foo-context.xml]: Initialization of bean failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 10 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.doGetBean(AbstractBeanFactory.java:310) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean$TargetBeanObjectFactory.getObject(ObjectFactoryCreatingFactoryBean.java:146) at foo.bar.baz.a.b.c.foo(C.java:99) at foo.bar.baz.service.X.Y(Z.java:161) at foo.bar.baz.servlet.K.bar(M.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3587) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) java.lang.ArrayIndexOutOfBoundsException: 10 at java.util.ArrayList.add(ArrayList.java:352) at org.aspectj.weaver.ReferenceType.addDependentType(ReferenceType.java:115) at org.aspectj.weaver.ReferenceType.<init>(ReferenceType.java:95) at org.aspectj.weaver.TypeFactory.createParameterizedType(TypeFactory.java:43) at org.aspectj.weaver.reflect.JavaLangTypeToResolvedTypeConverter.fromType(JavaLangTypeToResolvedTypeConverter.java:88) at org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate.getSuperclass(Java15ReflectionBasedReferenceTypeDelegate.java:148) at org.aspectj.weaver.ReferenceType.getSuperclass(ReferenceType.java:906) at org.aspectj.weaver.patterns.KindedPointcut.fastMatch(KindedPointcut.java:144) at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.couldMatchJoinPointsInType(PointcutExpressionImpl.java:82) at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:238) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254) at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean$TargetBeanObjectFactory.getObject(ObjectFactoryCreatingFactoryBean.java:146) at foo.bar.baz.a.b.c.foo(C.java:99) at foo.bar.baz.service.X.Y(Z.java:161) at foo.bar.baz.servlet.K.bar(M.java:136) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3587) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

    Spring JIRA | 6 years ago | Tom Ziemer
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooBar' defined in class path resource [spring/foo-context.xml]: Initialization of bean failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 10
  3. 0
    Your entity is not a valid Entity class.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0
    Upgrade to Confluence 3.5.5 or install the patch as explained in the details.
  6. 0
    Mixed JpaTransactionManager with JTA transaction type in the beans.xml and persistence.xml
    via spring.io

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.beans.factory.BeanCreationException

      Error creating bean with name 'fooBar' defined in class path resource [spring/foo-context.xml]: Initialization of bean failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 10

      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean()
    2. Spring Beans
      ObjectFactoryCreatingFactoryBean$TargetBeanObjectFactory.getObject
      1. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
      2. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      3. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
      4. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
      5. org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean$TargetBeanObjectFactory.getObject(ObjectFactoryCreatingFactoryBean.java:146)
      5 frames
    3. foo.bar.baz
      K.bar
      1. foo.bar.baz.a.b.c.foo(C.java:99)
      2. foo.bar.baz.service.X.Y(Z.java:161)
      3. foo.bar.baz.servlet.K.bar(M.java:136)
      3 frames
    4. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      2. javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      2 frames
    5. Atmosphere weblogic
      WebAppServletContext$ServletInvocationAction.run
      1. weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
      2. weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
      3. weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
      4. weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
      5. weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3587)
      5 frames
    6. weblogic.security.acl
      AuthenticatedSubject.doAs
      1. weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      1 frame
    7. weblogic.security.service
      SecurityManager.runAs
      1. weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
      1 frame
    8. Atmosphere weblogic
      ServletRequestImpl.run
      1. weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200)
      2. weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106)
      3. weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428)
      3 frames
    9. weblogic.work
      ExecuteThread.run
      1. weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
      2. weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
      2 frames