You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jose María Zaragoza <de...@gmail.com> on 2014/02/06 13:31:29 UTC
UserDatabase resource into META-INF/context.xml
Hello:
I'm using Tomcat 6.0.24
I want to set a realm per only one application, so I define in its
META-INF/context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource auth="Container"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
name=MyUserDatabase"
pathname="conf/my-users.xml"
type="org.apache.catalina.UserDatabase" />
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="MyUserDatabase"/>
</Context>
my-users.xml is stored in $CATALINA_BASE/conf/
But it doesn't work; a javax.naming.NameNotFoundException exception is
thrown when Tomcat restarts
If I put <Resource> under GlobalNamingResources in server.xml , works
fine, But I would prefer to held all configuration in context.xml
is it possible ? or do I need to use GlobalNamingResources ?
is the pathname right ?
Regards
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: UserDatabase resource into META-INF/context.xml
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Jose,
On 2/6/14, 7:31 AM, Jose María Zaragoza wrote:
> Hello:
>
> I'm using Tomcat 6.0.24
>
> I want to set a realm per only one application, so I define in its
> META-INF/context.xml
>
> <?xml version="1.0" encoding="UTF-8"?> <Context> <Resource
> auth="Container" description="User database that can be updated and
> saved"
> factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
> name=MyUserDatabase" pathname="conf/my-users.xml"
> type="org.apache.catalina.UserDatabase" />
>
> <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
> resourceName="MyUserDatabase"/> </Context>
>
> my-users.xml is stored in $CATALINA_BASE/conf/
>
>
> But it doesn't work; a javax.naming.NameNotFoundException exception
> is thrown when Tomcat restarts
Try setting localDataSource="true" on your <Realm> element.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIcBAEBCAAGBQJS+o78AAoJEBzwKT+lPKRYtSwP/3DXAVM8qr0YyvnQNOboYGfn
gvYpEANinhoibJz7c1SGnD7EC4gau7lrQgJNzh+hIuRI5VzjUXCMaC/YNKiQ5xy4
/bdJi/tbleLP2c7VuLc/unF97fIgxGAfN4ZwYzFpy8pl75Ofj77R7SBV/5bo/2HF
N5If+BDjtNNZ2sFeICqHP7iVaq5cmaq1x0fVMR5oPpkzSrxfLKTv94/Ihg2rmayM
frZU24bf1CRdDvmNO81P0a+EHQolCriDs7qtMzl8BDXb8E91WdnQLsGHZMaTTZHK
toVsetxQi6Cxu5iMoXdIQdUiyKuGiMaoNYDj5DUGwhknHSOZK5lItRC5rv9hliuW
CgqQLDhFJOAJn/K7nO5BEg5ARBOw+HaeKcckc/xSjpSd2PgOpveD+JrVxDDw2PDp
Bu+yYBdsqbcXMFV6gng3xnQoRlOZY1hgTR39zm5HmnlWxk4dbV64/Ka2FYtt6X1a
M5UKQVV1RmfjrVjCVi76wC33dEgbLIZaxB7Q58Vwh/0kCBluIz+E/ahXYCGNl76f
jjYnofK7Sz0PQDUgnXEH6NgeB5Mfr0CdB/8luvPEDEvz99OfwZvtSA3iY0BwShbR
5hPxYdgZTg/r8DRAD+6ssfvEOUQuurlWnaeWFef4h5tnKrIBWmsLh+4vEYOro60n
HSVwe8f898u0cMbBuJ8b
=ggO/
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: UserDatabase resource into META-INF/context.xml
Posted by Konstantin Kolinko <kn...@gmail.com>.
2014-02-06 Jose María Zaragoza <de...@gmail.com>:
> Hello:
>
> I'm using Tomcat 6.0.24
>
> I want to set a realm per only one application, so I define in its
> META-INF/context.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Context>
> <Resource auth="Container"
> description="User database that can be updated and saved"
> factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
> name=MyUserDatabase"
> pathname="conf/my-users.xml"
> type="org.apache.catalina.UserDatabase" />
>
> <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
> resourceName="MyUserDatabase"/>
> </Context>
>
> my-users.xml is stored in $CATALINA_BASE/conf/
>
>
> But it doesn't work; a javax.naming.NameNotFoundException exception is
> thrown when Tomcat restarts
>
>
> If I put <Resource> under GlobalNamingResources in server.xml , works
> fine, But I would prefer to held all configuration in context.xml
>
> is it possible ? or do I need to use GlobalNamingResources ?
With the current code: no.
It is hardcoded to do JNDI lookup in the global context.
It might be possible to port "localDataSource" option from
DataSourceRealm class.
(MMV. It depends on what ClassLoader is active when
MyUserDatabase.startInternal() is invoked).
> is the pathname right ?
In general I'd prefer to write "${catalina.base}/conf/my-users.xml",
but that is just my preference.
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org