tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dB. <dbl...@dblock.org>
Subject Tomcat 7 LifecycleBase.init
Date Mon, 01 Nov 2010 15:50:59 GMT
I have some unit test code that mocks a lot of Tomcat classes so that I can test a Tomcat Valve
(code in http://waffle.codeplex.com). Switching to Tomcat 7 is giving me some grief. I used
to be able to do this:

            SimpleContext ctx = new SimpleContext(); // my class
            Realm realm = new SimpleRealm(); // an empty realm
            ctx.setRealm(realm);
            _somevalve.setContainer(ctx); // valve container
            _somevalve.start();

Now I am getting this

java.lang.NullPointerException
                at org.apache.catalina.mbeans.MBeanUtils.getContainerKeyProperties(MBeanUtils.java:1698)
                at org.apache.catalina.valves.ValveBase.getObjectNameKeyProperties(ValveBase.java:281)
                at org.apache.catalina.util.LifecycleMBeanBase.initInternal(LifecycleMBeanBase.java:61)
                at org.apache.catalina.valves.ValveBase.initInternal(ValveBase.java:223)
                at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:100)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:131)
                at waffle.apache.NegotiateAuthenticatorTests.setUp(NegotiateAuthenticatorTests.java:44)
                at junit.framework.TestCase.runBare(TestCase.java:128)
                at junit.framework.TestResult$1.protect(TestResult.java:106)
                at junit.framework.TestResult.runProtected(TestResult.java:124)
                at junit.framework.TestResult.run(TestResult.java:109)
                at junit.framework.TestCase.run(TestCase.java:120)
                at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

The problem is in MBeanUtils that assumes that a valid container object is passed into it
(from ValveBase.getObjectNameKeyProperties). I tried to walk this code and I don't understand
how I am supposed to setup container (and possible its parent(s)) to not get this exception.

What am I missing? Any help is appreciated,

Thx
dB.
dB. @ dblock.org<http://www.dblock.org/>
Moscow|Geneva|Seattle|New York



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message