Bookmark Topic Watch Topic
  • New Topic

How to catch Datasource exception during Spring initialization

 
J Mahayni
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Report post to moderator
I am interested in catching an exception during Spring initialization but I am not sure of how to do so. What I am looking for is A WAY to catch this exception should it occur again in the future (i.e.: how and where), so that I can inform the user of what have happened.

I am using Spring to initialize a datasource in the applicationContext.xml as below:
"
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>jdbc/ITLM</value>
</property>
</bean>
"

I am getting the following exception that I already resolved but want to capture it for future "setup" occurrance:

"The following exception was logged org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is javax.naming.NameNotFoundException: Context: servers/server1, name: jdbc/ITLM: First component in name ITLM not found.
Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL mg.org/CosNaming/NamingContext/NotFound:1.0"

I thought of using ServletContextListener but was not sure of how to capture an exception in the contextInitialized() method? I may need a different approach altogether?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
J Mahayni, please do not cross-post the same question in more than one forum.
 
J Mahayni
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thank you for your pointer, I was just pointed to your one forum rule that I was not aware of. Sorry for your trouble.
 
    Bookmark Topic Watch Topic
  • New Topic