Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

read jndi from outside the container

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to get a connection from the JNDI from outside the container in Tomcat? (From a JUnit integration test in particular.)

I think the answer is no because Apache's FAQ implies you can't do that. I saw this which tells you how to inject your own datasource in what looks like a different JNDI but that's the opposite of what I want to do. I want to use the same connection settings as the actual app.

Or this is a security thing?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18169
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd thought about that long ago. I think that (aside from security) the biggest problem is that the JNDI server in Tomcat doesn't have a network port, and therefore isn't accessible from outside the VM.

If the unit tester is actually launching Tomcat, it might be easier to have the pre-test setup write out a context XML file that gets fed to the launched Tomcat. In other words, instead of reading the server's JNDI, set the JNDI data from the test itself.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's easier to have the code under test read from a standalone connection than inject it into the jndi. I was looking for a way to externalize the settings from the code by using the developer's tomcat jndi setup. Doesn't sound feasible in Tomcat though
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18169
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:It's easier to have the code under test read from a standalone connection than inject it into the jndi. I was looking for a way to externalize the settings from the code by using the developer's tomcat jndi setup. Doesn't sound feasible in Tomcat though


I'm presuming that your test framework uses an external running tomcat, then, not launching embedded Tomcat.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes (it is the Jfroum integration tests if that matters)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic