java.lang.IllegalArgumentException: Name must not be null

Spring JIRA | Casey Hadden | 10 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    When <context:load-time-weaver aspectj-weaving="on" /> is used in the same application context as a bean defined via the factory-method and factory-bean functionality the following IllegalArgumentException is thrown: Exception in thread "main" java.lang.IllegalArgumentException: Name must not be null at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.util.ClassUtils.forName(ClassUtils.java:186) at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1131) at org.springframework.beans.factory.support.AbstractBeanFactory.isBeanClassMatch(AbstractBeanFactory.java:1161) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:172) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:474) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:340) Sample driver: package test; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Main { public static void main(String[] args) { System.out.println("Successful context is bootstrapping. It does not contain loadTimeWeaver."); ClassPathXmlApplicationContext successCtx = new ClassPathXmlApplicationContext("test-success.xml"); System.out.println("factory: " + successCtx.getBean("factory")); System.out.println("object: " + successCtx.getBean("object")); System.out.println("Failing context is bootstrapping. It is the same as successful, except for addition of loadTimeWeaver."); ClassPathXmlApplicationContext failCtx = new ClassPathXmlApplicationContext("test-fails.xml"); System.out.println("factory: " + failCtx.getBean("factory")); System.out.println("object: " + failCtx.getBean("object")); } } Associated simple factory: package test; public class Factory { public String getObject() { return "Hello world"; } } test-success.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="factory" class="test.Factory" /> <bean id="object" factory-bean="factory" factory-method="getObject" /> </beans> test-fails.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.1.xsd"> <bean id="factory" class="test.Factory" /> <bean id="object" factory-bean="factory" factory-method="getObject" /> <context:load-time-weaver aspectj-weaving="on" /> </beans> By changing lines 1130-1132 of AbstractBeanFactory.java from: if (typeMatchOnly && getTempClassLoader() != null) { return ClassUtils.forName(mbd.getBeanClassName(), getTempClassLoader()); } to: if (typeMatchOnly && getTempClassLoader() != null) { return mbd.resolveBeanClass(getTempClassLoader()); } the above test code does bootstrap and run successfully. Additionally, the changed code above does still successfully apply @Aspect advice to non-spring managed objects in both a standalone and JBoss 4.2.0 environment. We do not currently have a case and haven't done any verification of the above change and its impact on advising spring managed beans.

    Spring JIRA | 10 years ago | Casey Hadden
    java.lang.IllegalArgumentException: Name must not be null
  2. 0

    When <context:load-time-weaver aspectj-weaving="on" /> is used in the same application context as a bean defined via the factory-method and factory-bean functionality the following IllegalArgumentException is thrown: Exception in thread "main" java.lang.IllegalArgumentException: Name must not be null at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.util.ClassUtils.forName(ClassUtils.java:186) at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1131) at org.springframework.beans.factory.support.AbstractBeanFactory.isBeanClassMatch(AbstractBeanFactory.java:1161) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:172) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:474) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:340) Sample driver: package test; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Main { public static void main(String[] args) { System.out.println("Successful context is bootstrapping. It does not contain loadTimeWeaver."); ClassPathXmlApplicationContext successCtx = new ClassPathXmlApplicationContext("test-success.xml"); System.out.println("factory: " + successCtx.getBean("factory")); System.out.println("object: " + successCtx.getBean("object")); System.out.println("Failing context is bootstrapping. It is the same as successful, except for addition of loadTimeWeaver."); ClassPathXmlApplicationContext failCtx = new ClassPathXmlApplicationContext("test-fails.xml"); System.out.println("factory: " + failCtx.getBean("factory")); System.out.println("object: " + failCtx.getBean("object")); } } Associated simple factory: package test; public class Factory { public String getObject() { return "Hello world"; } } test-success.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="factory" class="test.Factory" /> <bean id="object" factory-bean="factory" factory-method="getObject" /> </beans> test-fails.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.1.xsd"> <bean id="factory" class="test.Factory" /> <bean id="object" factory-bean="factory" factory-method="getObject" /> <context:load-time-weaver aspectj-weaving="on" /> </beans> By changing lines 1130-1132 of AbstractBeanFactory.java from: if (typeMatchOnly && getTempClassLoader() != null) { return ClassUtils.forName(mbd.getBeanClassName(), getTempClassLoader()); } to: if (typeMatchOnly && getTempClassLoader() != null) { return mbd.resolveBeanClass(getTempClassLoader()); } the above test code does bootstrap and run successfully. Additionally, the changed code above does still successfully apply @Aspect advice to non-spring managed objects in both a standalone and JBoss 4.2.0 environment. We do not currently have a case and haven't done any verification of the above change and its impact on advising spring managed beans.

    Spring JIRA | 10 years ago | Casey Hadden
    java.lang.IllegalArgumentException: Name must not be null
  3. 0

    Springframework webflow variable class name not found

    Stack Overflow | 5 years ago | Daggeto
    java.lang.IllegalArgumentException: Name must not be null
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Initialization of bean failed; nested exception is org.springframework.beans

    Stack Overflow | 2 years ago | user2586010
    java.lang.IllegalArgumentException: Cannot find class [com.anand.model.Employee] at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:294) at org.springframework.beans.propertyeditors.ClassEditor.setAsText(ClassEditor.java:64) at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:474) at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:446) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:215) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:122) at org.springframework.beans.TypeConverterDelegate.convertToTypedArray(TypeConverterDelegate.java:485) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:227) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:154) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:452) ... 30 more Caused by: java.lang.ClassNotFoundException: com.anand.model.Employee at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      Name must not be null

      at org.springframework.util.Assert.notNull()
    2. Spring Core
      ClassUtils.forName
      1. org.springframework.util.Assert.notNull(Assert.java:112)
      2. org.springframework.util.ClassUtils.forName(ClassUtils.java:186)
      2 frames
    3. Spring Beans
      DefaultListableBeanFactory.getBeanNamesForType
      1. org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1131)
      2. org.springframework.beans.factory.support.AbstractBeanFactory.isBeanClassMatch(AbstractBeanFactory.java:1161)
      3. org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:172)
      3 frames
    4. Spring Context
      AbstractApplicationContext.refresh
      1. org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:474)
      2. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:340)
      2 frames