---
title: "jboss部署数据源却提示javax.naming.NameNotFoundException "
author: "daniel_tu"
date: "2009-05-08T14:03:50Z"
tags: ["JBoss", "JDBC", "Oracle", "SQL", "XML"]
slug: "jboss-javax-naming-namenotfoundexception"
draft: false
lastmod: "2009-05-08T14:03:50Z"
id: 382069
url: "https://daniel-tu.iteye.com/blog/382069"
---

javax.naming.NameNotFoundException: DefaultDS not bound  
如同这样问题的解决：

我在中文各大知名论坛求助都没有一个好的解决方式，终于在国外的论坛上获取相识问题解决方法：

通常你通过Console都能看到部署成功，在JMX的service=JNDIView中也能看到，就是不能Lookup :)

解决方法：加上下面红色部分！

&lt;datasources&gt;  
  &lt;local-tx-datasource&gt;  
    &lt;jndi-name&gt;jdbc/OracleDS&lt;/jndi-name&gt;  
    &lt;use-java-context&gt;false&lt;/use-java-context&gt;  
    &lt;connection-url&gt;jdbc:oracle:thin:@127.0.0.1:1521:lpar01&lt;/connection-url&gt;  
    &lt;driver-class&gt;oracle.jdbc.driver.OracleDriver&lt;/driver-class&gt;  
    &lt;user-name&gt;sa&lt;/user-name&gt;  
    &lt;password&gt;123&lt;/password&gt;  
    &lt;!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool --&gt;  
    &lt;!--valid-connection-checker-class-name&gt;org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker&lt;/valid-connection-checker-class-name--&gt;  
    &lt;!-- Checks the Oracle error codes and messages for fatal errors --&gt;  
    &lt;exception-sorter-class-name&gt;org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter&lt;/exception-sorter-class-name&gt;  
        &lt;!-- sql to call when connection is created  
        &lt;new-connection-sql&gt;some arbitrary sql&lt;/new-connection-sql&gt;  
        --&gt;

        &lt;!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered  
        &lt;check-valid-connection-sql&gt;some arbitrary sql&lt;/check-valid-connection-sql&gt;  
        --&gt;

      &lt;!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --&gt;  
      &lt;metadata&gt;  
         &lt;type-mapping&gt;Oracle9i&lt;/type-mapping&gt;  
      &lt;/metadata&gt;  
  &lt;/local-tx-datasource&gt;

&lt;/datasources&gt;