2016-04-14 97 views
0
I have configured JNDI reference in spring-context.xml ,created JNDI in Websphere application server 7.5, this working fine, but if its database is down, I am not able to start the web application ,i am getting 500 uncaught servlet initialization exception . 

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 
    <property name="jndiName" value="${reports_db_jndi_ref}"/> 
</bean> 

您能否提供建议?即使数据库关闭,如何处理异常或如何启动Web应用程序?Spring框架中的异常处理JNDI

回答

1

将lookupOnStartup属性设置为false,以便Spring将代理返回给数据源而不是实际的数据源。但是,如果您的应用程序使用数据源作为启动过程的一部分,例如由于某些依赖性尝试连接到数据库,仍然会出现这种情况。更改如下

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 
    <property name="jndiName" value="${reports_db_jndi_ref}"/> 
    <property name="lookupOnStartup" value="false"/> 
</bean>