• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Datasource exception during Spring initialization

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am interested in catching an exception during Spring initialization but I am not sure of how to do so. 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?

Any ideas are greatly appreciated. Thanks.

[ January 03, 2006: Message edited by: J Mahayni ]

[ January 03, 2006: Message edited by: J Mahayni ]
[ January 04, 2006: Message edited by: J Mahayni ]
 
Ranch Hand
Posts: 982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In our case...

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"><value>java:/test</value></property>
</bean>


java:/test is defined elsewhere in another xml file ...
 
J Mahayni
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. What I am actually looking for is a way to catch the exception so that I can inform the user of the problem.
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is some Root class available in Spring (I don't remember name of the class) which can give you a root cause of Exception

Just google around for Spring Exception Handling/Spring API docs.

I think question is in wrong forum,but i do not have rights to move the topic.
Shrinivas
 
J Mahayni
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply, as well. I am a bit surprised, to tell you the truth, that neither of you had read my question carefully. I already have the exception (see stack above) and I already fixed the cause of the exception. 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 hope this makes better sense to any reader.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am also getting same exception. Can you please help me in resolving the same as you have mentioned that you resolved it.


Thanks!


J Mahayni wrote:I am interested in catching an exception during Spring initialization but I am not sure of how to do so. 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?

Any ideas are greatly appreciated. Thanks.

[ January 03, 2006: Message edited by: J Mahayni ]

[ January 03, 2006: Message edited by: J Mahayni ]
[ January 04, 2006: Message edited by: J Mahayni ]

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic