tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kornmod <>
Subject JNDI, resource and LDAP Trouble
Date Wed, 27 Apr 2011 14:42:36 GMT


I'm trying to create a simple resource for my web-app. My web-app has to
connect to a ldap server to maintain users. I have created a context.xml in
my META-INF folder - with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/LDAP">
	<Resource name="blah"

But when I try to access my resource with the following code:

		Context newCtx = null;
		try {
			newCtx = new InitialContext();
		} catch (NamingException e) {
			// TODO Auto-generated catch block

		try {
			DirContext ctx = (DirContext) newCtx.lookup("blah");
			if (ctx != null){
				System.out.println ("Success");
			} else {
				System.out.println ("False");

it excepts with the following error:

javax.naming.NameNotFoundException: Name blah is not bound in this Context

I must be missing something essential - or doing something obviously wrong.
But I seem not to be able to crack the nut myself. All help or input is much

NOTE: I have also tried to move the Resource config to
CATALINA/conf/server.xml as a GlobalNamingResource with no luck. The classes
in play obviously is in my CLASSPATH since they are part of my JDK/JRE
(rt.jar). I'm using windows 7 with tomcat 7.0.12 and java


View this message in context:
Sent from the Tomcat - Dev mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message