Websphere自由的dataSource

时间:2018-11-28 13:49:59

标签: spring datasource jndi websphere-liberty

我正在尝试在 websphere-liberty:springBoot2 Docker映像上设置数据源。我共享了一个 war文件和一个包含jdni定义的 server.xml 文件

<dataSource id="oracle" jndiName="jdbc/oracle">
    <jdbcDriver libraryRef="OracleLib"/>
    <properties ....... />
</dataSource>

war文件具有bean定义:

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/oracle"/>
    <property name="lookupOnStartup" value="false"/>
    <property name="cache" value="true" />
    <property name="proxyInterface"  value="javax.sql.DataSource" />
</bean>

但是出现下一个错误堆栈:

Invocation of init method failed; nested exception is org.springframework.jndi.JndiLookupFailureException: 
JndiObjectTargetSource failed to obtain new target object; 
nested exception is javax.naming.NamingException: 
CWWKE0800W: An attempt was made to retrieve an initial context for [jdbc/oracle] but no JNDI feature is configured.

我将server.xml和ojdbc8.jar都共享到了容器中。预先感谢。

1 个答案:

答案 0 :(得分:2)

您需要通过将<feature>jndi-1.0</feature>添加到server.xml的<featureManager>元素中来启用JNDI功能,并且您可能想使用Oracle特定的配置元素properties.oracle而不是通用驱动程序配置元素properties