aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Access DataSource from Java client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Access DataSource from Java client" Watch "Access DataSource from Java client" New topic
Author

Access DataSource from Java client

Dirk Fiege
Greenhorn

Joined: Apr 15, 2004
Posts: 2
Hi helpers and supporters,
I have a J2EE application running on Websphere (WSAD) and I have written
some JUnit testcase for this application. All this stuff was already running on WebLogic and now I have migrated it to WebSphere. Some of the JUnit testcases directly make a lookup on the DataSources without using an EJB in between. In WebLogic I was able to lookup the DataSources directly from the JUnit testcase, but in WebSphere (WSAD) I get a SecurityException when I try to do this. This happens even I disabled all security stuff in WSAD.
Why is it not possible to lookup a DataSource from a Java application directly (outside the container)?
Any idea how I can make it?
Thanks a lot

- Fide
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
It is possible but you need to use the Application Container (launch Client). This is all covered in detail in my book -- but the short answer is you need to package your JUnit tests into an Application Client project and put that in an EAR file. Then you can use Run... to set up an Application Client runner for your Tests, using the JUnit test runner as the main() class.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Dirk Fiege
Greenhorn

Joined: Apr 15, 2004
Posts: 2
Hi,
Thanks a lot for a quick answer!
I think I understood what you mean. I already started to setup
a new client project and to include a first JUnit testcase here.
So I should be able to assign the required references like EJB
and DataSource references to this client project later on, right?
Then I will try to start the different JUnit test classes from
Run.. and the different available main methods.
Let's see if I can manage this...
- fidi
 
wood burning stoves
 
subject: Access DataSource from Java client