Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-13599

Autowiring throws NullPointerException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 4.2.2
    • Fix Version/s: 4.2.3
    • Component/s: Core
    • Labels:
    • Last commented by a User:
      false

      Description

      After switching to 4.2.2 I get the following exception during autowiring:

      Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String de.ei.janet.server.Janet.saDir; nested exception is java.lang.NullPointerException
      	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:571) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
      	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
      	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
      	... 29 common frames omitted
      Caused by: java.lang.NullPointerException: null
      	at java.util.concurrent.ConcurrentHashMap.containsValue(ConcurrentHashMap.java:979) ~[na:1.8.0_60]
      	at java.util.concurrent.ConcurrentHashMap$ValuesView.contains(ConcurrentHashMap.java:4664) ~[na:1.8.0_60]
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.determineAutowireCandidate(DefaultListableBeanFactory.java:1228) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1124) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
      	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:543) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
      	... 31 common frames omitted
      

      The reason seams to be the last changes in DefaultListableBeanFactory (Commit 097bcfb997bd215c7b39635770e34812744f0d9e). This commit replaces HashMap with ConcurrentHashMap. After this change the fallback case in method determineAutowireCandidate throws the NullPointerException if beanInstance is null.

        Attachments

          Activity

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              mrs22 Michael Schoene
              Last updater:
              St├ęphane Nicoll
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 4 weeks, 2 days ago