tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amy Roh <amy...@apache.org>
Subject Re: Exception in RealmBase
Date Thu, 08 Jan 2004 18:10:10 GMT
Mark Woon wrote:

> Hi all,
> 
> I'm reposting this in the hopes that someone will responsd.
> I have a custom Realm implementation that extends
> org.apache.catalina.realm.RealmBase.  It used to work in 4.x, but in
> 5.0.16, I'm getting the following exception on startup:
> 
> 21:17:29,719 ERROR RealmBase:1092 - Can't register null
> java.lang.NullPointerException
>   at org.apache.catalina.realm.RealmBase.init(RealmBase.java:1088)
>   at org.apache.catalina.realm.RealmBase.start(RealmBase.java:769)
>   at
> org.pharmgen.webapp.tomcat.PharmGenRealmAdapter.setRealm(PharmGenRealmAdapter.java:34)

> 
> 
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
> 
> 
>   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

> 
> 
>   at java.lang.reflect.Method.invoke(Method.java:324)
>   at
> org.securityfilter.config.SecurityConfig.addRealm(SecurityConfig.java:216)
> [snip]
> 
> 
> I've taken a look at the source, and as far as I can tell, it's because
> the container is null.  What is responsible for providing the Realm the
> container it's in?  Is there some new bit of configuration I need to do
> in Tomcat 5?  I'm also surprised that there's this bit of code in
> RealmBase.init():
> 
> if( container== null ) {
> // do some stuff, and don't set container or oname
> }
> if( oname==null ) {
> try {
>   ContainerBase cb=(ContainerBase)container;
>   // >>> NPE HAPPENS HERE  <<<
>   oname=new ObjectName(cb.getDomain()+":type=Realm" +
> cb.getContainerSuffix());
>   // some other stuff
> } catch (Throwable e) {
>   log.error( "Can't register " + oname, e);
> }
> }

How are you adding your realm?  It seems the code under container==null 
should be executed when the realm is added via JMX using full object 
name only.  It's using its own object name to figure out its container 
and calls setRealm to its container.  When oname==null, the realm should 
already have its container...

Amy

> 
> I don't have any experience with JMX, so maybe it's doing something
> behind the scenes, but if not, that bit of code looks wrong.  While this
> seems to be an error that can be safely ignored if I'm not using JMX,
> it's still a little distressing.
> 
> Any help would be appreciated.
> 
> Thanks,
> -Mark
> 
> 




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


Mime
View raw message