You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "dB." <db...@dblock.org> on 2010/11/01 16:50:59 UTC
Tomcat 7 LifecycleBase.init
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
Re: Tomcat 7 LifecycleBase.init
Posted by Mark Thomas <ma...@apache.org>.
On 01/11/2010 12:34, dB. wrote:
> Sorry for the noise.
>
> Once I got the right source code, it was pretty easy to track under a debugger. I needed to implement Context.getName(), getPath, an Engine and a Pipeline.
>
> _authenticator = new NegotiateAuthenticator();
> SimpleContext ctx = new SimpleContext();
> Realm realm = new SimpleRealm();
> ctx.setRealm(realm);
> SimpleEngine engine = new SimpleEngine();
> ctx.setParent(engine);
> SimplePipeline pipeline = new SimplePipeline();
> engine.setPipeline(pipeline);
> ctx.setPipeline(pipeline);
> _authenticator.setContainer(ctx);
> _authenticator.start();
>
> It would be nice if Tomcat's code was a bit more defensive in terms of nulls.
Fair point.
http://svn.apache.org/viewvc?rev=1029755&view=rev should help.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Tomcat 7 LifecycleBase.init
Posted by "dB." <db...@dblock.org>.
Sorry for the noise.
Once I got the right source code, it was pretty easy to track under a debugger. I needed to implement Context.getName(), getPath, an Engine and a Pipeline.
_authenticator = new NegotiateAuthenticator();
SimpleContext ctx = new SimpleContext();
Realm realm = new SimpleRealm();
ctx.setRealm(realm);
SimpleEngine engine = new SimpleEngine();
ctx.setParent(engine);
SimplePipeline pipeline = new SimplePipeline();
engine.setPipeline(pipeline);
ctx.setPipeline(pipeline);
_authenticator.setContainer(ctx);
_authenticator.start();
It would be nice if Tomcat's code was a bit more defensive in terms of nulls.
dB. @ dblock.org
Moscow|Geneva|Seattle|New York
-----Original Message-----
From: dB. [mailto:dblock@dblock.org]
Sent: Monday, November 01, 2010 11:51 AM
To: Tomcat Users List (users@tomcat.apache.org)
Subject: Tomcat 7 LifecycleBase.init
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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org