tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mariano" <mlo...@sescam.org>
Subject RE: Problem getting GlobalNamingResources DataSource DBCP from Custom JAAS
Date Fri, 04 Jan 2008 12:59:22 GMT
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:mlopez@sescam.org]
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:markt@apache.org]
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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message