• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

UserRegistry and DataSource

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem Description:
This simple code works fine in UserRegistry set in Admin Web Console.

Context initialcontext = new InitialContext();
DataSource datasource = (DataSource)
initialcontext.lookup("jdbc/DSNAME");

But when I stop and start server for applying security set, I have :
My log:
...
NamingException while looking up datasource: jdbc/DSNAME
javax.naming.NameNotFoundException: jdbc/DSNAME
...
WAS trace:
[1/8/03 19:13:54:116 CET] 28c15c33 CNContextImpl < lookup: exception
[1/8/03 19:13:54:116 CET] 28c15c33 CNContextImpl d
getNameInNamespace()-->>myserver/nodes/myserver/servers/server1
[1/8/03 19:13:54:116 CET] 28c15c33 Helpers d jndiNamingException

com.ibm.ws.naming.jndicos.CNContextImpl
lookup

infep1b30/nodes/infep1b30/servers/server1
jdbc/DSNAME

javax.naming.NameNotFoundException: jdbc/DSNAME
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1503)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1457)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1167)

Can I get datasource 'outside' WAS Console ?
Can I use a datasource in UserRegistry implementation ?
Thank you very much.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I may be going out on a limb here (in other words, I'm not 100% certain -- more like 70%) but I THINK that you can't use J2EE resources like DataSources or EJB's in a custom registry because it starts up before the services do. Have you looked at the custom registry example (which uses a database) that comes with WebSphere? I THINK they ended up using the DriverManager to get to the database, but I would check the example to be sure.
Kyle
 
Gianni Salvagno
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are right about Security it's initialize before resource (I posted a problem on IBM support but I had no posts about this).
I can't find an example for the UserRegistry implementation for WAS 5, but I think they use DriverManager that always works...
In WAS 5 Info Center says:
"If the custom registry implementation is using data sources to connect to a database you need to set the property WAS_UseDataSource to true in the custom registry properties in the Network Deployment environment"

So, I think they knows the problem ( which it seems to be not for datasource only ...) .
So, I set this property in CustomRegistry Custom Property by admin web console, but the result is the same.
So, I failed to set property ( What Network Deployment environment means ? ) OR this property doesn't work ( I will not be surprise, because in was 4.0 you Must use a 2-phase commit datasource in customregistry even if no documentation suggests ... ).
Thank you very much.
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep found it. Read this redbook, especially the chapter on Custom Registries (page 184). You can't use DataSources in Custom Registries in V5, plain and simple.
Kyle
[ January 10, 2003: Message edited by: Kyle Brown ]
 
Gianni Salvagno
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kyle, thank you very much.
Now, two questions:
- WAS_UseDataSource, I can't understand why Info Center says this property should be set for using datasource ?!
- Where can I get a Connection in User Registry, I don't think I can't use a connection pooling whitout a datasource ...
Thanks,
Gianni
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gianni,
I'm as clueless as you are about why the property exists -- I'll have to take that one up with the developers, since it goes against everything I've read and heard from them.
As far as I know, the only way to get a connection in a custom registry is the old-fashioned way -- from a DriverManager.
Kyle
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

Thanks for your posts. I just tried out custom registries by following
IBM's example instruction and it's working fine. Here is a question, if
I wanna use a database as user registry, I have to use the old-fashioned way
which is getting a database connection from DriverManager and it seems I
cannot use connection pooling mechanism. In that case, would the performance
be dragged down because it has to get a connection each time when a security
check is necessary?

Thanks.

Lorenz
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it would. Luckily this shouldn't happen that often (e.g. it only accesses the database on login in most cases). My recommendation would be to perhaps look into an open-source connection pooling mechanism like the one in Struts.

Kyle
 
reply
    Bookmark Topic Watch Topic
  • New Topic