JNDI, resource and LDAP Trouble
Hi, 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 auth=Container type=com.sun.jndi.ldap.LdapCtx factory=com.sun.jndi.ldap.LdapCtxFactory java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory com.sun.jndi.ldap.connect.pool=true java.naming.provider.url=ldap://192.168.7.1:389/dc=blah,dc=com; java.naming.security.authentication=simple java.naming.security.principal=cn=blah java.naming.security.credentials=blahblah/ /Context 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 e.printStackTrace(); } 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 appreciated. 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 1.6.0.24. Brgds /Poul -- View this message in context: http://old.nabble.com/JNDI%2C-resource-and-LDAP-Trouble-tp31488050p31488050.html Sent from the Tomcat - Dev mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: JNDI, resource and LDAP Trouble
On 27/04/2011 15:42, Kornmod wrote: Hi, 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: This question belongs on the users mailing list, not the dev list. Mark ?xml version=1.0 encoding=UTF-8? Context antiJARLocking=true path=/LDAP Resource name=blah auth=Container type=com.sun.jndi.ldap.LdapCtx factory=com.sun.jndi.ldap.LdapCtxFactory java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory com.sun.jndi.ldap.connect.pool=true java.naming.provider.url=ldap://192.168.7.1:389/dc=blah,dc=com; java.naming.security.authentication=simple java.naming.security.principal=cn=blah java.naming.security.credentials=blahblah/ /Context 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 e.printStackTrace(); } 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 appreciated. 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 1.6.0.24. Brgds /Poul - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: JNDI, resource and LDAP Trouble
You need to create the resource in your server.xml and then create a resource reference in the web app's context.xml. Sorry I don't have an example in front of me but the basics are: 1.) the resource element in the server.xml creates the resource 2.) the web.xml references the resource by an application specific name 3.) the context.xml links the application specific name to the name as defined in server.xml On Wed, Apr 27, 2011 at 10:42 AM, Kornmod p...@kornmod.dk wrote: Hi, 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 auth=Container type=com.sun.jndi.ldap.LdapCtx factory=com.sun.jndi.ldap.LdapCtxFactory java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory com.sun.jndi.ldap.connect.pool=true java.naming.provider.url=ldap:// 192.168.7.1:389/dc=blah,dc=com java.naming.security.authentication=simple java.naming.security.principal=cn=blah java.naming.security.credentials=blahblah/ /Context 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 e.printStackTrace(); } 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 appreciated. 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 1.6.0.24. Brgds /Poul -- View this message in context: http://old.nabble.com/JNDI%2C-resource-and-LDAP-Trouble-tp31488050p31488050.html Sent from the Tomcat - Dev mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: JNDI, resource and LDAP Trouble
If you are going to answer questions that are asked in the wrong list, rather than waiting until they are re-posted on the users list, please do so privately, or on the user list. Answering them on the wrong list leads to search engines finding the answer in the wrong list's archive and this leads to more people posting queries on the wrong list. Thanks - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: JNDI, resource and LDAP Trouble
Sorry - I was too fast with the mouse not verifying that I was in the correct group. /Poul markt-2 wrote: On 27/04/2011 15:42, Kornmod wrote: Hi, 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: This question belongs on the users mailing list, not the dev list. Mark ?xml version=1.0 encoding=UTF-8? Context antiJARLocking=true path=/LDAP Resource name=blah auth=Container type=com.sun.jndi.ldap.LdapCtx factory=com.sun.jndi.ldap.LdapCtxFactory java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory com.sun.jndi.ldap.connect.pool=true java.naming.provider.url=ldap://192.168.7.1:389/dc=blah,dc=com; java.naming.security.authentication=simple java.naming.security.principal=cn=blah java.naming.security.credentials=blahblah/ /Context 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 e.printStackTrace(); } 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 appreciated. 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 1.6.0.24. Brgds /Poul - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org -- View this message in context: http://old.nabble.com/JNDI%2C-resource-and-LDAP-Trouble-tp31488050p31488352.html Sent from the Tomcat - Dev mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org