You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dan Washusen <da...@gmail.com> on 2005/02/06 02:17:37 UTC

DataSourceRealm says "Name jdbc is not bound in this Context"

Hi All,
I'm trying to get container managed authentication going under Tomcat
5.5 using the org.apache.catalina.realm.DataSourceRealm class.  I've
configured a DataSource using the name "jdbc/MindDB" and I can access
that from within my app, but when the configured DataSourceRealm tries
to access it I get "javax.naming.NameNotFoundException: Name jdbc is
not bound in this Context".

My context.xml looks like this:
<Context path="/mind" 
    docBase="D:/Development/Projects/mind/src/webapp" 
    debug="5" reloadable="true">	
	<Resource name="jdbc/MindDB" auth="Container" type="javax.sql.DataSource"
		maxActive="100" maxIdle="30" maxWait="10000"
		username="mind" password="********" driverClassName="org.postgresql.Driver"
		url="jdbc:postgresql://localhost/mind"/>

	<Realm className="org.apache.catalina.realm.DataSourceRealm" debug="99"
   		dataSourceName="jdbc/MindDB"
   		userTable="mind_user" userNameCol="alias" userCredCol="password"
		userRoleTable="mind_user_role" roleNameCol="name"/>
</Context>

And the relevant section of my web.xml looks like this:
...
    <resource-ref>
        <description>Mind DB Connection</description>
        <res-ref-name>jdbc/MindDB</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
...

I've also tried using the full name of "java:/comp/env/jdbc/MindDB"
that works in my code but that just changes my error to
"javax.naming.NameNotFoundException: Name java: is not bound in this
Context".

Any help would be greatly appreciated...

Cheers,
Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: DataSourceRealm says "Name jdbc is not bound in this Context"

Posted by Dan Washusen <da...@gmail.com>.
Dominik, that worked!  Champion!!!

My revised context.xml looks like this:
<Context path="/mind"
docBase="D:/Development/Projects/mind/src/webapp" debug="99"
reloadable="true">
	<Resource name="jdbc/MindDB" auth="Container" type="javax.sql.DataSource"
		maxActive="100" maxIdle="30" maxWait="10000"
		username="mind" password="*******" driverClassName="org.postgresql.Driver"
		url="jdbc:postgresql://localhost/mind"/>

	<Realm className="org.apache.catalina.realm.DataSourceRealm" debug="99"
   		dataSourceName="jdbc/MindDB" localDataSource="true"
   		userTable="mind_user" userNameCol="alias" userCredCol="password"
		userRoleTable="mind_user_role" roleNameCol="name"/>
</Context>


On Mon, 07 Feb 2005 08:57:08 +0100, Dominik Drzewiecki <dr...@post.pl> wrote:
> Dan Washusen <da...@gmail.com> wrote:
> > Hi Sven,
> > I can access the data source from within my code using the name
> > "java:/comp/env/jdbc/MindDB" and everything works great.  It's just
> > that the Realm can't... I have found a few other posts to this list
> > with the same problem and one of the email suggested that the Realm is
> > configured before the DataSource causing an error to be thrown during
> > realm initialisation (as the DataSource is missing).
> >
> > It looks like the "solution" is to move the DataSource configuration
> > to the Global configuration area or to use the JBDCRealm.
> 
> It is not necessary to make the datasource global. Try adding
> localDataSource="true" to your context Realm definition.
> Having consulted the docs for 4.1.x, 5.0.x and 5.5.x, t seems that this
> flag is only allowed in the latest version of tomcat. There's a chance
> though that it has been backported without having the docs updated.
> 
> HTH,
> /dd
> 
> 


-- 
Jar-Jar makes the Ewoks look like f*%#ing Shaft! -  Tim Bisley

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: DataSourceRealm says "Name jdbc is not bound in this Context"

Posted by Dominik Drzewiecki <dr...@post.pl>.
Dan Washusen <da...@gmail.com> wrote:
> Hi Sven,
> I can access the data source from within my code using the name
> "java:/comp/env/jdbc/MindDB" and everything works great.  It's just
> that the Realm can't... I have found a few other posts to this list
> with the same problem and one of the email suggested that the Realm is
> configured before the DataSource causing an error to be thrown during
> realm initialisation (as the DataSource is missing).
> 
> It looks like the "solution" is to move the DataSource configuration
> to the Global configuration area or to use the JBDCRealm.

It is not necessary to make the datasource global. Try adding 
localDataSource="true" to your context Realm definition.
Having consulted the docs for 4.1.x, 5.0.x and 5.5.x, t seems that this 
flag is only allowed in the latest version of tomcat. There's a chance 
though that it has been backported without having the docs updated.


HTH,
/dd


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: DataSourceRealm says "Name jdbc is not bound in this Context"

Posted by Dan Washusen <da...@gmail.com>.
Hi Sven,
I can access the data source from within my code using the name
"java:/comp/env/jdbc/MindDB" and everything works great.  It's just
that the Realm can't... I have found a few other posts to this list
with the same problem and one of the email suggested that the Realm is
configured before the DataSource causing an error to be thrown during
realm initialisation (as the DataSource is missing).

It looks like the "solution" is to move the DataSource configuration
to the Global configuration area or to use the JBDCRealm.

To some it up, given the number of emails I've found with this problem
I believe it's a bug in Tomcat.

Cheers,
Dan

On Sun, 6 Feb 2005 10:38:14 -0800 (PST), sven morales
<ak...@yahoo.com> wrote:
> Hi,
>     This is an excerpt of my code, to get a Context.
> Try and see if it works for you.
> 
>      31   private void initDataSource () {
>      32     try {
>      33       Context initCtx = new InitialContext();
>      34       Context envCtx = (Context)
> initCtx.lookup("java:comp/env");
>      35       dataSource = (DataSource)
> envCtx.lookup("jdbc/Taglib");
>      36     }
>      37     catch (NamingException e) {
>      38       System.out.println("ERR: Unable to
> Initialize Data Source (" + e + ")");
>      39     }
>      40   }
> 
> Configs of web.xml is similar to yours. However am not
> sure if you need an additional parameter to <web-app>
> like so:
> 
>       8   <context-param>
>       9     <param-name>dataSource</param-name>
>      10     <param-value>jdbc/Taglib</param-value>
>      11   </context-param>
> 
> Check the dtd description at
> http://java.sun.com/j2ee/dtds/web-app_2.3.dtd for
> further info.
> 
> aka_sergio
> 
> 
> --- Dan Washusen <da...@gmail.com> wrote:
> 
> > Hi All,
> > I'm trying to get container managed authentication
> > going under Tomcat
> > 5.5 using the
> > org.apache.catalina.realm.DataSourceRealm class.
> > I've
> > configured a DataSource using the name "jdbc/MindDB"
> > and I can access
> > that from within my app, but when the configured
> > DataSourceRealm tries
> > to access it I get
> > "javax.naming.NameNotFoundException: Name jdbc is
> > not bound in this Context".
> >
> > My context.xml looks like this:
> > <Context path="/mind"
> >
> > docBase="D:/Development/Projects/mind/src/webapp"
> >     debug="5" reloadable="true">
> >       <Resource name="jdbc/MindDB" auth="Container"
> > type="javax.sql.DataSource"
> >               maxActive="100" maxIdle="30" maxWait="10000"
> >               username="mind" password="********"
> > driverClassName="org.postgresql.Driver"
> >               url="jdbc:postgresql://localhost/mind"/>
> >
> >       <Realm
> >
> className="org.apache.catalina.realm.DataSourceRealm"
> > debug="99"
> >               dataSourceName="jdbc/MindDB"
> >               userTable="mind_user" userNameCol="alias"
> > userCredCol="password"
> >               userRoleTable="mind_user_role"
> > roleNameCol="name"/>
> > </Context>
> >
> > And the relevant section of my web.xml looks like
> > this:
> > ...
> >     <resource-ref>
> >         <description>Mind DB
> > Connection</description>
> >         <res-ref-name>jdbc/MindDB</res-ref-name>
> >         <res-type>javax.sql.DataSource</res-type>
> >         <res-auth>Container</res-auth>
> >     </resource-ref>
> > ...
> >
> > I've also tried using the full name of
> > "java:/comp/env/jdbc/MindDB"
> > that works in my code but that just changes my error
> > to
> > "javax.naming.NameNotFoundException: Name java: is
> > not bound in this
> > Context".
> >
> > Any help would be greatly appreciated...
> >
> > Cheers,
> > Dan
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > tomcat-user-help@jakarta.apache.org
> >
> >
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - Easier than ever with enhanced search. Learn more.
> http://info.mail.yahoo.com/mail_250
> 


-- 
Jar-Jar makes the Ewoks look like f*%#ing Shaft! -  Tim Bisley

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: DataSourceRealm says "Name jdbc is not bound in this Context"

Posted by sven morales <ak...@yahoo.com>.
Hi,
    This is an excerpt of my code, to get a Context.
Try and see if it works for you.
     
     31   private void initDataSource () {
     32     try {
     33       Context initCtx = new InitialContext();
     34       Context envCtx = (Context)
initCtx.lookup("java:comp/env");
     35       dataSource = (DataSource)
envCtx.lookup("jdbc/Taglib");
     36     }
     37     catch (NamingException e) {
     38       System.out.println("ERR: Unable to
Initialize Data Source (" + e + ")");
     39     }
     40   }

Configs of web.xml is similar to yours. However am not
sure if you need an additional parameter to <web-app>
like so:
 
      8   <context-param>
      9     <param-name>dataSource</param-name>
     10     <param-value>jdbc/Taglib</param-value>
     11   </context-param>

Check the dtd description at
http://java.sun.com/j2ee/dtds/web-app_2.3.dtd for
further info.

aka_sergio


--- Dan Washusen <da...@gmail.com> wrote:

> Hi All,
> I'm trying to get container managed authentication
> going under Tomcat
> 5.5 using the
> org.apache.catalina.realm.DataSourceRealm class. 
> I've
> configured a DataSource using the name "jdbc/MindDB"
> and I can access
> that from within my app, but when the configured
> DataSourceRealm tries
> to access it I get
> "javax.naming.NameNotFoundException: Name jdbc is
> not bound in this Context".
> 
> My context.xml looks like this:
> <Context path="/mind" 
>    
> docBase="D:/Development/Projects/mind/src/webapp" 
>     debug="5" reloadable="true">	
> 	<Resource name="jdbc/MindDB" auth="Container"
> type="javax.sql.DataSource"
> 		maxActive="100" maxIdle="30" maxWait="10000"
> 		username="mind" password="********"
> driverClassName="org.postgresql.Driver"
> 		url="jdbc:postgresql://localhost/mind"/>
> 
> 	<Realm
>
className="org.apache.catalina.realm.DataSourceRealm"
> debug="99"
>    		dataSourceName="jdbc/MindDB"
>    		userTable="mind_user" userNameCol="alias"
> userCredCol="password"
> 		userRoleTable="mind_user_role"
> roleNameCol="name"/>
> </Context>
> 
> And the relevant section of my web.xml looks like
> this:
> ...
>     <resource-ref>
>         <description>Mind DB
> Connection</description>
>         <res-ref-name>jdbc/MindDB</res-ref-name>
>         <res-type>javax.sql.DataSource</res-type>
>         <res-auth>Container</res-auth>
>     </resource-ref>
> ...
> 
> I've also tried using the full name of
> "java:/comp/env/jdbc/MindDB"
> that works in my code but that just changes my error
> to
> "javax.naming.NameNotFoundException: Name java: is
> not bound in this
> Context".
> 
> Any help would be greatly appreciated...
> 
> Cheers,
> Dan
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org