I'm trying to run class having a below method but getting an exception while running. I have check but wnat to know what is wrong so that I make necessary correction to fix this exception.
SPRING_CONTEXT_FILE: ist is a string variable pointing to application.xml file.
public static void main(String[] pArgs)
{
try
{ System.out.println(" starting ");
ApplicationContext ctx = new ClassPathXmlApplicationContext(SPRING_CONTEXT_FILE);
System.out.println("before applicationbean name");
CoreBatchVehicleListApp app = (CoreBatchVehicleListApp) ctx.getBean(APPLICATION_BEAN_NAME);
System.out.println("After applicationbean name");
// get the key framework instances if any of these are missing we will get a runtime exception
------------------------------------------------------------------------------------------------------------------------------------
starting
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exceptionHandler' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(AccessController.java:224)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at uk.gov.tfl.lruc.batch.vehicle.CoreBatchVehicleListApp.main(CoreBatchVehicleListApp.java:479)
Caused by: java.lang.NullPointerException at org.springframework.core.GenericTypeResolver.getTypeVariableMap(GenericTypeResolver.java:144)
at org.springframework.core.GenericTypeResolver.resolveReturnType(GenericTypeResolver.java:93)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:58)
at java.beans.PropertyDescriptor.setWriteMethod(Unknown Source)
at java.beans.PropertyDescriptor.<init>(Unknown Source)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.<init>(GenericTypeAwarePropertyDescriptor.java:47)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:250)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:252)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:380)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1248)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
... 14 more
Thanks for helping me , well I need help to resolve this exception which I'm getting.
application.xml file is given below. I have written a class which ahs a mani method and method is also given below.
if (null == app.mFileFactory)
{
throw new IllegalStateException("Please supply an appropriate FileFactoryInterface implementation");
}
if (null == app.mObjectTranslator)
{
throw new IllegalStateException("Please supply an appropriate OXMHandlerFactoryInterface implementation");
}
// Everything checks out if we get here - start processing
app.run();
}
catch (Exception e)
{
// Something has stopped processing. Exit with an abnormal termination code - we can't be sure that everything
// is in place so terminate with minimal support i.e we can't use the logger or exception handler
Well, it looks like a classpath issue.
Can you override the Factory provided constants and use the actual names in your main class? (application.xml & Application bean)
Also, is your ApplicationContext file placed at application root or in classpath?