File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Share information between Web App and Stand-alone Java App Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Share information between Web App and Stand-alone Java App" Watch "Share information between Web App and Stand-alone Java App" New topic
Author

Share information between Web App and Stand-alone Java App

David Wei
Greenhorn

Joined: Jan 04, 2002
Posts: 17
Hi All,
Merry Christmas!
I am writing a stand-alone java application to send out emails to the people whose subscribed item status is changed through a web application. I need to share some property information, like datasource name (dsn) and user information. In my web application using WAS 4.0, I created datasource and Ldap directory and tried to use jndi to obtain the shared information.
When I run my main method to get database connection by using jndi name for database name, my code is like this
public DataSource getDataSource()
throws NamingException
{
InitialContextctx=new InitialContext();
return(DataSource) ctx.lookup(dataSourceName);
}

I got the exception "Caught exception when resolving initial reference=NameService" in the first line of this method

Can you help me on this?
Thanks in advance!
David
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi David and welcome to JavaRanch. It's a coincidence that we have been struggling with a similar problem at work for the last couple of days though we are using WAS 5.0 and are getting a Malformed URL from the InitialContext (it doesn't seem to recognize the corbaloc protocol). A work around is to use pure CORBA.
Get an ORB in your main and initialize to the WebSphere ORB:


Get the NameService:

Get the DataSource:

You will obviously need to make some adjustments to this code to match your host, ORB port etc. I am still investigating why we are having trouble using InitialContext and if I find the answer, I'll post it back here.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Share information between Web App and Stand-alone Java App
 
Similar Threads
DataSouce without JNDI
Query reg Tomcat connection pool
Oracle Clob error on shared Sun One connection pool
Datasource/EJB
Datasource JNDI Lookup in WSAD from standalone app