aspose file tools
The moose likes Security and the fly likes Urgent...not able to get data source Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » Security
Reply Bookmark "Urgent...not able to get data source" Watch "Urgent...not able to get data source" New topic
Author

Urgent...not able to get data source

Hd Desai
Ranch Hand

Joined: Aug 04, 2003
Posts: 65
Hi,

We areusing WSAD 5.1 as IDE.

We have data source defined in app server which is JAAS secured.

Now we have standalone application which needs to access this data source,but as this is JAAS secured and specified on app server its not able to connect and throws following excpetion.

javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment.

Is it a way to this......

Following is the code snippet.
Properties systemProps = new Properties();

systemProps.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
systemProps.setProperty(Context.PROVIDER_URL,"iiop://localhost:2809");
systemProps.setProperty(Context.SECURITY_PRINCIPAL,"db2admin");
systemProps.setProperty(Context.SECURITY_CREDENTIALS,"db2admin");

InitialContext initContext = new InitialContext(systemProps);



javax.sql.DataSource myDS = (javax.sql.DataSource) initContext.lookup("java:comp/env/SPN DB User");


Pls let me know if some one knows the solution to this problem.
Thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35443
    
    9
Why do you suspect that JAAS is the problem - does it work if you turn JAAS off? The error message suggests that there is more to using JNDI on the client than just using the code shown here. Does JNDI work in this way in other clients?


Android appsImageJ pluginsJava web charts
Hd Desai
Ranch Hand

Joined: Aug 04, 2003
Posts: 65
Hi,

Yes its works fine when I remove JAAS authentication.

The same code is working for web application where we have EAR installed on the server.

But in case of standalone application its not able to get data source from app server which is JAAS protected.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Urgent...not able to get data source
 
Similar Threads
JDBC lookup failure through java:comp....
JDBC lookup failure through java:comp....
JDBC: Concept of DataSource
Problem with JNDI and Cloudscape database
JNDI Lookup from Java Client not working