3 Replies Latest reply on May 27, 2002 2:51 AM by Vicky Kak

    Very Urgent !!!!!Regarding DataSource access through EJB

    Vicky Kak Master

      Hi,
      As already learned that the other jvm cant access the
      jndi directly so I deployed the interest EJB in the Jboss
      with one additional method as getDataSource(String sname).I have attached the files which I tested and found that the ejb is deployed properly and it is not
      able to get the DataSource from the same VM.My EJB and
      jndi are now in the same JVM,and the client gets the
      DataSource from the EJB..
      But I failed to do so I get the error as -----
      C:\Developer\interest>java org.jboss.docs.interest.InterestClient DefaultDS
      Got context 66
      Got context
      Got reference
      Interest on 1000 units, at 10% per period, compounded over 2 periods is:
      210.00000000000023
      Hello java.lang.NullPointerException....

      Server OUTPUT--------
      [Default] Someone called `calculateCompoundInterest!'
      [Default] Error in getDataSource javax.naming.NameNotFoundException: DefaultDS n
      ot bound

      Actually I wanted to create my own DataSource and use in the bean(in jsp) in web module.I believe it should work
      as they are in the same JVM.But I am failing in not getting the instance of DefaultDS from the JNDI.
      It is very urgent,all my work is getting held because
      of this.Hope to get the solutions from the JBoss gurus...
      I also wanted to understand the implementation of the Jboss,where I can get its details.....
      regards vicky



        • 1. Re: Very Urgent !!!!!Regarding DataSource access through EJB
          Vicky Kak Master

          Hi,
          Sorry for not giving the files but I tried it gave the
          problem,let me try again..It is not comming up...Any way
          let me put the additional method here alongwith the default one.....
          ***************************
          /**
          Calulates the compound interest on the sum `principle', with interest rate per
          period `rate' over `periods' time periods. This method also prints a message to
          standard output; this is picked up by the EJB server and logged. In this way we
          can demonstrate that the method is actually being executed on the server,
          rather than the client.
          */
          public double calculateCompoundInterest(double principle,
          double rate, double periods)
          {
          System.out.println("Someone called `calculateCompoundInterest!'");
          return principle * Math.pow(1+rate, periods) - principle;
          }
          /** Gets the reference of DataSource.Implemented by vk 24/05/2002
          */
          public DataSource getDataSource(String sname)
          {
          DataSource ods=null;
          try
          {
          InitialContext initial = new InitialContext();
          ods=(DataSource)initial.lookup(sname);
          }
          catch(Exception e)
          {
          System.out.println("Error in getDataSource "+e);
          }
          return ods;
          }
          ********************************
          Hope this to be clear for the understanding
          regards vickyk

          • 2. Re: Very Urgent !!!!!Regarding DataSource access through EJB
            David Jencks Master

            Buy the docs or read the code.

            Pay attention to what the datasource is bound under, java:/DefaultDS != DefaultDS

            • 3. Re: Very Urgent !!!!!Regarding DataSource access through EJB
              Vicky Kak Master

              Hi,
              I have checked the consle lots of times and it shows
              the DataSource bound as java:/DefaultDS,Now source I have
              am downloading and it will take a time to understand the
              object hirerchy and relationship.As my requirement
              is very urgent I would be thankful if some contributes
              regarding reading the default DS from the EJB...
              Thanks a lot..
              regards vickyk