JBoss Community

Re: javax.naming.NameNotFoundException: jdbc not bound

created by Smitha K in Beginner's Corner - View the full discussion

I have the following deployment details:-( I am trying to connect to the  database,but getting error)

1)ejb-jar.xml:-

<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
  <description>A simple session bean</description>
  <display-name>Simple Message EJB</display-name>
  <enterprise-beans>
     <session>
      <ejb-name>FirstEJBBean</ejb-name>
      <home>FirstEJBHome</home>
      <remote>FirstEJBObject</remote>
      <local-home>FirstLocalEJBHome</local-home>
      <local>FirstLocalEJBObject</local>
      <ejb-class>FirstEJBBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <env-entry>
                 <description> Maximum percentage discount for a customer </description>
                 <env-entry-name> maxCustomerDiscount </env-entry-name>
                 <env-entry-type> java.lang.Double </env-entry-type>
                 <env-entry-value> 50 </env-entry-value>
      </env-entry>
     <ejb-ref>
            <ejb-ref-name>ejb/FirstEJBBeanRemoteTest</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <home>FirstEJBHome</home>
            <remote>FirstEJBObject</remote>
           <ejb-link>FirstEJBBean</ejb-link>
      </ejb-ref>
      <ejb-local-ref>
            <ejb-ref-name>ejb/FirstEJBBeanTest</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <local-home>FirstLocalEJBHome</local-home>
            <local>FirstLocalEJBObject</local>
           <ejb-link>FirstEJBBean</ejb-link>
      </ejb-local-ref>
       <resource-ref>
        <res-ref-name>jdbc/nbuDS</res-ref-name>
         <res-type>javax.sql.DataSource</res-type>
         <res-auth>Container</res-auth>
      </resource-ref>
    </session>
</enterprise-beans>
</ejb-jar>

 

2)jboss-xml



<?xml version="1.0" encoding="ISO-8859-1"?>
<jboss>
  <enterprise-beans>
     <session>
      <ejb-name>FirstEJBBean</ejb-name>
      <resource-ref>
        <res-ref-name>jdbc/nbuDS</res-ref-name>
        <jndi-name>jbossDS</jndi-name>
       </resource-ref>
      <jndi-name>ejb/FirstEJBBeanRemote</jndi-name>
   </session>
  </enterprise-beans>
</jboss>

 

 

My Local bean code is:-

 

ejbCtx = (Context) context.lookup("java:comp/env");

dsrc = (DataSource)ejbCtx.lookup("jdbc/nbuDS");

 

I have jboss-ds file in the  default/deply folder configured as  follows:-

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
    <local-tx-datasource>
        <jndi-name>jbossDS</jndi-name>
        <connection-url>jdbc:sqlserver://172.16.84.66:1433;sendStringParametersAsUnicode=false;databaseName=NBU</connection-url>
        <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
        <min-pool-size>5</min-pool-size>
        <max-pool-size>30</max-pool-size>
        <track-statements>true</track-statements>
  <prepared-statement-cache-size>10</prepared-statement-cache-size>
  <query-timeout>60</query-timeout>
        <user-name>sa</user-name>
        <password>M8$tek12</password>
</local-tx-datasource>
</datasources>

 

But i am still unable to connect to database.

Please provide me  inputs for the same.

Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community