• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need Help

 
Jasmine kaur
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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


 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will be helpful, if you can post here your application.xml is well..
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What type of help do you need?

I can't tell by your subject line. Maybe you can edit your message and change your topic title to be more specific.

Thanks

Mark Spritzler
 
Jasmine kaur
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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.

<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<bean id="logFactory"
class="com.ibm.ruc.utilities.logging.LogFactory"
factory-method="getInstance"/>

<bean id="exceptionResourceBundle" class="com.ibm.ruc.coreit.utilities.ResourceBundleAdapter">
<constructor-arg>
<value>exception.properties</value>
</constructor-arg>
</bean>

<bean id="exceptionHandler" class="com.ibm.ruc.utilities.exception.ExceptionHandler" factory-method="getInstance">
<property name="resourceBundle" ref="exceptionResourceBundle"/>
</bean>

<!-- CACHE specification -->

<bean id="systemPropertiesCAO"
class="com.ibm.ruc.utilities.cache.cao.PropertyCAO">
<property name="propertiesFile" value="system"/>
</bean>

<bean id="systemPropertiesCache"
class="com.ibm.ruc.utilities.cache.ConfigurationCache">
<constructor-arg ref="systemPropertiesCAO"/>
<property name="name" value="systemPropertiesCache"/>
<property name="logFactory" ref="logFactory"/>
</bean>

<bean id="errorPropertiesCAO"
class="com.ibm.ruc.utilities.cache.cao.PropertyCAO">
<property name="propertiesFile" value="exception"/>
</bean>

<bean id="errorPropertiesCache"
class="com.ibm.ruc.utilities.cache.ConfigurationCache">
<constructor-arg ref="errorPropertiesCAO"/>
<property name="name" value="errorPropertiesCache"/>
<property name="logFactory" ref="logFactory"/>
</bean>

<!-- Configuration Manager Specification -->

<bean id="configurationManager"
class="com.ibm.ruc.utilities.cache.ConfigurationManager"
factory-method="getInstance">
<property name="caches">
<map>
<entry key="systemPropertiesCache"
value-ref="systemPropertiesCache"/>
<entry key="errorPropertiesCache"
value-ref="errorPropertiesCache"/>
</map>
</property>
</bean>

<bean id="fileFactory" class="com.ibm.ruc.coreit.utilities.file.SimpleFileFactory"/>

<bean id="ObjectTranslator" class="uk.gov.tfl.lruc.batch.vehicle.oxm.ManualObjectTranslator">
<property name="logFactory" ref="logFactory"/>
<property name="exceptionHandler" ref="exceptionHandler"/>
<property name="configurationManager" ref="configurationManager"/>
<property name="loggerName" value="BatchVehicleExport"/>
</bean>

<bean id="Application" class="uk.gov.tfl.lruc.batch.vehicle.CoreBatchVehicleListApp">
<property name="logFactory" ref="logFactory"/>
<property name="exceptionHandler" ref="exceptionHandler"/>
<property name="configurationManager" ref="configurationManager"/>
<property name="loggerName" value="BatchVehicleExport"/>
<property name="fileFactory" ref="fileFactory"/>
<property name="objectTranslator" ref="ObjectTranslator"/>
</bean>

</beans>
-----------------------------------


public static void main(String[] pArgs)
{
try
{
ApplicationContext ctx = new ClassPathXmlApplicationContext(SPRING_CONTEXT_FILE);

CoreBatchVehicleListApp app = (CoreBatchVehicleListApp) ctx.getBean(APPLICATION_BEAN_NAME);

// get the key framework instances if any of these are missing we will get a runtime exception

app.getLogger();
app.getExceptionHandler();
app.getRequiredCache(SYSTEM_PROPERTIES_CACHE_NAME);
app.getRequiredCache(ERROR_PROPERTIES_CACHE_NAME);

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

e.printStackTrace();

System.exit(ABNORMAL_TERMINATION_IN_INITIALISATION);
}
}
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please change your subject line so I can see what help you need.

"Need Help" tells me nothing and I go by the subject header.

Mark
 
Sumit Bisht
Ranch Hand
Posts: 331
Python Ruby Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!