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

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