0 Replies Latest reply on Jun 18, 2010 11:31 AM by rrnambreamit

    javax.naming.NameNotFoundException:javax.naming.NameNotFoundException: kda.studentHome not bound

    rrnambreamit

      <%@ page language="java" import="kda.*,kda.StudentBean,javax.naming.*,javax.rmi.PortableRemoteObject,java.rmi.RemoteException,java.util.Properties,java.util.Hashtable,javax.sql.DataSource,java.sql.Connection" contentType="text/html; charset=ISO-8859-1"

          pageEncoding="ISO-8859-1"%>

      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

       

      <%@page import="javax.ejb.CreateException"%>

      <%@page import="javax.ejb.FinderException"%>

      <%@page import="kda.studentHome"%>

      <%@page import="kda.StudentRemote"%><html>

      <head>

      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

      <title>entity bean application</title>

      </head>

      <body>

      <%

      String s1="createtable";

      String s2="droptable";

      studentHome hom=null;

      StudentRemote stud;

      String cr=request.getParameter("ftName");

       

      try{

          

          Hashtable ht1=new Hashtable();

       

            ht1.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");

            ht1.put("java.naming.provider.url","jnp://localhost:1099");

            ht1.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");

          

         

            Context ic2 = new InitialContext(ht1);

             Object o=ic2.lookup("kda.studentHome");

           

                

                

                  Object obj= PortableRemoteObject.narrow(o,studentHome.class);

              hom = (studentHome) obj;

       

       

       

             if(s1==cr){%>

                out.println ("Creating database table...");

                <%hom.makeDbTable();

              

                stud = hom.create(new Integer(3),"John");

                 stud = hom.create(new Integer(4),"Jackson");

                 stud = hom.create(new Integer(5),"Rosy");

                 stud = hom.create(new Integer(6),"Ana");

       

       

                    for(int i=1;i<=4;i++){

                    Integer pk = new Integer(i);

                    StudentRemote stud1 = hom.findByPrimaryKey(pk); %>

                    out.println("Name  " + i + " : " + stud1.getName());

                <%}

             }

             else if(s2==cr){ %>

                out.println ("Dropping database table...");

                <%hom.deleteDbTable ();

             }

           

              }

         

       

      catch(Exception e5){System.out.print("Exception"+ e5);}

      %>

      </body>

      </html>

       

      ---------------------------------------------------------------------

      jboss-web.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss-web>

            <resource-ref>

            <res-ref-name>jdbc/studentbmpHom</res-ref-name>

            <res-type>javax.sql.DataSource</res-type>

            <jndi-name>jdbc/studentbmpHom</jndi-name>

            </resource-ref>

      </jboss-web>

       

      ----------------------------------------------------------------------

       

       

      web.xml

       

      <resource-ref>

        <description>dbconnection</description>

        <res-ref-name>jdbc/studentbmpHom</res-ref-name>

        <res-type>javax.sql.DataSource</res-type>

        <res-auth>Container</res-auth>

      </resource-ref>

      </web-app>