Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: ClassCastException trying to cast MemoryUserDatabase to UserDatabase

Matthew Kerle

2007-08-16

Replies:

//code
Object o = ic.lookup("java:comp/env/users");
System.out.println(o.getClass().getName()); // prints :
"org.apache.catalina.users.MemoryUserDatabase"

doing instanceof tests on the returned object for MemoryUserDatabase &
UserDatabase all fail, even though in debug that's clearly what it
identifies as.

could this be a security manager thing? I notice that in the tomcat
manager deployment descriptor it has privileged="true" in the Context
tag. Are only privileged applications allowed access to the
UserDatabase? (this would make sense as you could enumerate all users &
passwords...)

Gregor Schneider wrote:
> InitialContext.lookup() gives you a simple object:
>
> so change your code to
>
> Context ic = new InitialContext();
> Object o = ic.lookup("java:comp/env/users");
>
> set a breakpoint and see, what type of object you're getting back.
>
> hth
>
> gregor
>  

--
Matthew Kerle
IT Consultant
Canberra, Australia

Mobile: +61404 096 863
Email : mattkerle@(protected)
Web : http://threebrightlights.blogspot.com/


---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.