Lookup a resource from a client?

Discussions

General J2EE: Lookup a resource from a client?

  1. Lookup a resource from a client? (6 messages)

    Is it valid to lookup a DataSource or any other non-ejb resource from a java client? When I try to lookup a DataSource from a client, I get a ClassCastException cuz the lookup returns a javax.naming.Reference rather than my DataSource.

    - Srini

    Threaded Messages (6)

  2. Is it valid to lookup a DataSource or any other non-ejb resource from a java client?

    Yes, but please be more specific (f.e. adding a scenario, an example, or code).
    When I try to lookup a DataSource from a client, I get a ClassCastException cuz the lookup returns a javax.naming.Reference rather than my DataSource.- Srini

    How are you doing the lookup?

    sv
  3. Hi Srini,

    You cannot lookup and use a datasource from a client.

    Regards,
    Senthil
  4. Datasource not possible[ Go to top ]

    Senthil,

    If the datasource is in jndi, why couldn't it be accessible?

    sv
  5. Remote Interface???[ Go to top ]

    Hi Stephane,

    Not sure if I am using the right terminology to explain this, but anyways I'll try.

    The datasource unlike EJBs, does not implement a remote interface. (Notice the returned object is a javax.naming.Reference rather than DataSource). Hence if you want to lookup datasource, you have to be in the same process.

    Hope I am making sense, else let me know, I'll try to explain it differently.

    Regards,
    Senthil
  6. It is Possible[ Go to top ]

    Hi,

    If it is possible to put object in JNDI then it is also possible to retrieve it. Ofcourse, you may need to deal with security , depending upon the Application Server.

    If you are using WAS or WSAD5.0 you may need to tweak classpath and some properties file. Let me know, if you may need more details.

    Thanks,
    Sanjay
  7. Need more information[ Go to top ]

    Hi Sanjay,
              Thanks for saying it's possible as I'm in the same situation and need to make it work. What tweaks would be required with classpaths etc ?

    javax.naming.Reference actually gives the addresses of ten different locations of the DataSource objects.

    If I try to find out the class-name of the those objects it gives the the same name as my DB alias with which I configured. I'm using IBM WAS 5.1.

    Also, note that I'm able to do it in WAS 3.5

    Thanks for all the help !!!

    - AT