java - JBoss DataSource configuration Issue -
i unable configure datasource in jboss. following configuration in jboss web.xml
<jboss-web> <resource-ref> <res-ref-name>jdbc/testdatasource</res-ref-name> <!-- matches web.xml --> <jndi-name>java:jdbc/testdatasource</jndi-name> <!-- matches oracle-ds.xml --> <res-type>javax.sql.datasource</res-type> </resource-ref> </jboss-web>
we have created oracle-ds.xml contains:
<?xml version="1.0" encoding="utf-8"?> <datasources> <local-tx-datasource> <jndi-name>jdbc/testdatasource</jndi-name> <connection-url>jdbc:oracle:thin:@11.120.184.77:1521:starsdev</connection-url> <driver-class>oracle.jdbc.driver.oracledriver</driver-class> <user-name>cmsusr</user-name> <password>cmsusr</password> <min-pool-size>2</min-pool-size> <max-pool-size>20</max-pool-size> <idle-timeout-minutes>5</idle-timeout-minutes> <track-statements/> <metadata> <type-mapping>oracle10g</type-mapping> </metadata> </local-tx-datasource> </datasources>
i have created 1 servlet contains following code in service method:
context initialcontext = new initialcontext(); context envcontext = (context) initialcontext.lookup( "java:comp/env" ); datasource ds = (datasource) envcontext.lookup( "jdbc/testdatasource" ); printwriter pw = response.getwriter(); pw.print(ds);
when i'm running servlet showing following error:
[stdout] javax.naming.namenotfoundexception: jdbc not bound
do in single lookup. there's no need use 2 contexts here.
context initialcontext = new initialcontext(); datasource ds = (datasource) initialcontext.lookup("java:comp/env/jdbc/testdatasource");
Comments
Post a Comment