Problem getting GlobalNamingResources DataSource DBCP from Custom JAAS
Hi all, I have a custom JAAS implemented in Tomcat 5.5.25. This custom JAAS works fine and i am trying to implement the same custom JAAS in Tomcat 6.0.14 but i have a problem and after deep searching in mailing lists and web I haven't found anything. The configuration is the following: server.xml: ... ... All libraries are placed in %TOMCAT_HOME%/lib folder. I deleted the custom JAAS just to try if DBCP is well initialized with this URL in navigator: http://localhost:9080/manager/resources and the DBCP is correctly configured. The tomcat server started with JVM property: -Djava.security.auth.login.config=C:\...\jaas.config The class that implements 'LoginModule' interface has the following code in initialize method: DataSource dataSourceSQL = null; try { Context ctx = new InitialContext(); Context envContext = (Context) ctx.lookup("java:comp/env"); dataSourceSQL = (DataSource) envContext.lookup("jdbc/dataSource_usuarios_aplicaciones_Local"); LoginModuloChua.entidadesDAO = new EntidadesDAO(dataSourceSQL); } catch (NamingException ex) { LoginModuloChua.entidadesDAO = null; log_ERROR("Se ha producido una NamingException con " + "nombreJndiDBCP: '" + this.nombreJndiDBCP + "' en " + "'initialize' -> iniciando 'entidadesDAO': " + ex.getMessage()); ex.printStackTrace(); } And always throws the following exception: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context Please any idea ?. Best regards and thank you very much, Mariano López - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem getting GlobalNamingResources DataSource DBCP from Custom JAAS
Mariano wrote: > Please any idea ?. Try looking at how the DataSourceRealm does it. http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/java/org/apache/catalina/realm/DataSourceRealm.java Mark - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem getting GlobalNamingResources DataSource DBCP from Custom JAAS
Thanks for the reply Mark but I think that the problem is from getting JNDI objects out of context, like my case is. Remember I need it to implement a custom JAAS and the same implementation works perfectly on tomcat 5.5.25, but not on tomcat 6.0.14. I searched in bug database and nothing found. I will try to open a new bug in tomcat bug database. Regards, Mariano -Mensaje original- De: Mark Thomas [mailto:[EMAIL PROTECTED] Enviado el: miércoles, 02 de enero de 2008 20:52 Para: Tomcat Users List Asunto: Re: Problem getting GlobalNamingResources DataSource DBCP from Custom JAAS Mariano wrote: > Please any idea ?. Try looking at how the DataSourceRealm does it. http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/java/org/apache/catalin a/realm/DataSourceRealm.java Mark - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem getting GlobalNamingResources DataSource DBCP from Custom JAAS
Hello again Mark, I have been looking in DataSourceRealm.java file as you write below in previous messages. Following the same method I change my code to: Context context = null; context = ContextBindings.getClassLoader(); context = (Context) context.lookup("comp/env"); dataSourceSQL = (DataSource) context.lookup("jdbc/dataSource_usuarios_aplicaciones_Local"); But the same exception is thrown: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context Has anything change inside JNDI from tomcat 5.5 to tomcat 6.0 ? I am confused because my implementation works perfectly on tomcat 5.5.25. To clear my confusion I wrote this simple lines for output the names binding to 'comp/env' using both methods. try { Context context = (Context) ContextBindings.getClassLoader(). lookup("comp/env"); System.out.println( "\n --- ContextBindings.getClassLoader().lookup('comp/env') -> " + "context.list()"); if ( context!=null ) { System.out.println(" --- context != null"); } NamingEnumeration list = context.list(""); while (list.hasMore()) { NameClassPair nc = (NameClassPair)list.next(); System.out.println( " --- " + nc.toString() ); } } catch (NamingException ex) { System.out.println( "NamingException ContextBindings.getClassLoader()." + "lookup('comp/env') -> context.list(): " + ex.getMessage()); } try { Context context = new InitialContext(); context = (Context) context.lookup("java:comp/env"); System.out.println( "\n --- new InitialContext() -> " + "(Context) context.lookup('java:comp/env') -> context.list()"); if ( context!=null ) { System.out.println(" --- context != null"); } NamingEnumeration list = context.list(""); while (list.hasMore()) { NameClassPair nc = (NameClassPair)list.next(); System.out.println( " --- " + nc.toString() ); } } catch (NamingException ex) { System.out.println( "NamingException new InitialContext() -> " + "(Context) context.lookup('java:comp/env') -> context.list(): " + ex.getMessage()); } I run this code in both tomcat servers 5.5.25 and 6.0.14 and this was the output: Output in Tomcat 5.5.25: --- ContextBindings.getClassLoader().lookup('comp/env') -> context.list() --- context != null --- users: org.apache.naming.ResourceEnvRef --- jdbc: org.apache.naming.NamingContext --- new InitialContext() -> (Context) context.lookup('java:comp/env') -> context.list() --- context != null --- users: org.apache.naming.ResourceEnvRef --- jdbc: org.apache.naming.NamingContext Output in Tomcat 6.0.14: --- ContextBindings.getClassLoader().lookup('comp/env') -> context.list() --- context != null --- users: org.apache.naming.ResourceEnvRef --- new InitialContext() -> (Context) context.lookup('java:comp/env') -> context.list() --- context != null --- users: org.apache.naming.ResourceEnvRef I think tomcat 6.0.14 does not offer jdbc: org.apache.naming.NamingContext where I put my data source. Best regards and thank you very much for your attention, Mariano Lopez -Mensaje original- De: Mariano [mailto:[EMAIL PROTECTED] Enviado el: jueves, 03 de enero de 2008 8:37 Para: Tomcat User-List (E-mail) Asunto: RE: Problem getting GlobalNamingResources DataSource DBCP from Custom JAAS Thanks for the reply Mark but I think that the problem is from getting JNDI objects out of context, like my case is. Remember I need it to implement a custom JAAS and the same implementation works perfectly on tomcat 5.5.25, but not on tomcat 6.0.14. I searched in bug database and nothing found. I will try to open a new bug in tomcat bug database. Regards, Mariano -Mensaje original- De: Mark Thomas [mailto:[EMAIL PROTECTED] Enviado el: miércoles, 02 de enero de 2008 20:52 Para: Tomcat Users List Asunto: Re: Problem getting GlobalNamingResources DataSource DBCP from Custom JAAS Mariano wrote: > Please any idea ?. Try looking at how the DataSourceRealm does it. http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/java/org/apache/catalin a/realm/DataSourceRealm.java Mark - To start a new topic, e-mail: us