我在websphere 8.5上部署了一个java war
但是在创建和使用JDBC数据源方面遇到了一些麻烦。
这是ibm-web-bnd.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<web-bnd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd" version="1.0">
<virtual-host name="default_host"/>
<resource-ref binding-name="jdbc/foobar" name="jdbc/bar"/>
</web-bnd>
这是websphere上的错误日志:
[5/19/17 11:17:21:137 UTC] 00000095 SystemOut O [TEMPLATE-MYCOMPANY-WP]2017-05-19 11:17:21,137 ERROR [WebContainer : 6] taaccess.provider.JNDIConnectionProvider:
Cannot get connection: com.ibm.websphere.naming.CannotInstantiateObjectException:
A NameNotFoundException occurred on an indirect lookup on the name java:comp/env/jdbc/bar.
The name java:comp/env/jdbc/bar maps to a JNDI name in deployment descriptor bindings for the application performing the JNDI lookup.
Make sure that the JNDI name mapping in the deployment descriptor binding is correct.
If the JNDI name mapping is correct, make sure the target resource can be resolved with the specified name relative to the default initial context.
[Root exception is javax.naming.NameNotFoundException: Context: DefaultCell01/nodes/DefaultNode01/servers/server1, name: jdbc/foobar: First component in name foobar not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]]
我的websphere数据源配置了一个跟随(并且测试连接正在运行)
foo_bar
jdbc_foobarlocal
Node=DefaultNode01,Server=server1
Oracle JDBC Driver
部署期间ibm-web-bnd.xml
是否被忽略,或者我必须修改我的数据源?
答案 0 :(得分:1)
ibm-web-bnd.xml
提供了您在代码中使用的引用之间的映射 - 我假设它是java:comp/env/jdbc/bar
- 以及在服务器配置中为该资源配置的实际JNDI名称 - 在您的情况下它是当前的jdbc_foobarlocal
。因此,您有两个选项,保持JNDI名称不变,修改xml设置binding-name=jdbc_foobarlocal
或将数据源上的JNDI名称更改为jdbc/foobar
。