java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • for this spring config: <bean id="ldap.auth.handler" class="org.jasig.cas.adaptors.ldap.FastBindLdapAuthenticationHandler"> <property name="filter" value="${ldap.dn.authenticate}" /> <property name="contextSource"> <bean class="org.springframework.ldap.core.support.LdapContextSource"> <property name="urls"> <bean class="org.apache.commons.lang.StringUtils" factory-method="split"> <constructor-arg value="${ldap.url}" /> <constructor-arg value="," /> </bean> </property> <property name="userDn" value="${ldap.userdn}" /> <property name="password" value="${ldap.password}" /> <property name="baseEnvironmentProperties"> <map> <entry key="java.naming.security.authentication" value="simple" /> <entry key="com.sun.jndi.ldap.connect.timeout" value="2000" /> <entry key="com.sun.jndi.ldap.read.timeout" value="2000" /> </map> </property> <property name="pooled" value="false" /> </bean> </property> </bean> I get the following error: 2011-08-09 14:56:28,437 ERROR [org.apache.struts2.spring.StrutsSpringObjectFactory] - <Error creating bean with name 'ldap.auth.handler' defined in ServletContext resource [/WEB-INF/spring-configuration/thekey-ldap.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanInitializationException: Bean state is invalid: ldapTemplate - may not be null> 2011-08-09 14:56:28,449 ERROR [org.apache.struts2.dispatcher.Dispatcher] - <Dispatcher initialization failed> java.lang.NullPointerException at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:220) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:530) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:501) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:457) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275) at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:380) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:424) at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:195) at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:273) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4542) at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5220) at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5215) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:680) The actual code for FastBindLdapAuthenticationHandler never utilizes the ldapTemplate set in the Abstract class. And it looks like there is code in afterPropertiesSet that should set it if it isn't set already, javax.validation must run before the spring afterPropertiesSet method. removing the @NotNull annotation from ldapTemplate should fix the bug.
    via by Daniel Frett,
  • for this spring config: <bean id="ldap.auth.handler" class="org.jasig.cas.adaptors.ldap.FastBindLdapAuthenticationHandler"> <property name="filter" value="${ldap.dn.authenticate}" /> <property name="contextSource"> <bean class="org.springframework.ldap.core.support.LdapContextSource"> <property name="urls"> <bean class="org.apache.commons.lang.StringUtils" factory-method="split"> <constructor-arg value="${ldap.url}" /> <constructor-arg value="," /> </bean> </property> <property name="userDn" value="${ldap.userdn}" /> <property name="password" value="${ldap.password}" /> <property name="baseEnvironmentProperties"> <map> <entry key="java.naming.security.authentication" value="simple" /> <entry key="com.sun.jndi.ldap.connect.timeout" value="2000" /> <entry key="com.sun.jndi.ldap.read.timeout" value="2000" /> </map> </property> <property name="pooled" value="false" /> </bean> </property> </bean> I get the following error: 2011-08-09 14:56:28,437 ERROR [org.apache.struts2.spring.StrutsSpringObjectFactory] - <Error creating bean with name 'ldap.auth.handler' defined in ServletContext resource [/WEB-INF/spring-configuration/thekey-ldap.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanInitializationException: Bean state is invalid: ldapTemplate - may not be null> 2011-08-09 14:56:28,449 ERROR [org.apache.struts2.dispatcher.Dispatcher] - <Dispatcher initialization failed> java.lang.NullPointerException at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:220) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:530) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:501) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:457) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275) at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:380) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:424) at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:195) at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:273) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4542) at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5220) at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5215) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:680) The actual code for FastBindLdapAuthenticationHandler never utilizes the ldapTemplate set in the Abstract class. And it looks like there is code in afterPropertiesSet that should set it if it isn't set already, javax.validation must run before the spring afterPropertiesSet method. removing the @NotNull annotation from ldapTemplate should fix the bug.
    via by Daniel Frett,
    • java.lang.NullPointerException at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:189) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:479) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:450) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:407) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:239) at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:152) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452) at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:205) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905) at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
    No Bugmate found.