Issue Details (XML | Word | Printable)

Key: CACTUS-63
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Vincent Massol
Reporter: James Stangler
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Cactus

Failure to start jetty prevents subsequent jetty tests from running

Created: 24/Oct/03 12:39 AM   Updated: 17/Apr/04 03:43 PM
Return to search
Component/s: Framework
Affects Version/s: 1.5-beta1
Fix Version/s: 1.6

Time Tracking:
Not Specified

Environment:
Operating System: Other
Platform: Other

Bugzilla Id: 24072


 Description  « Hide
If an exception occurs while starting a jetty context, the setup will throw an exception and
teardown won't be called even though jetty is still running. Subsequent jetty tests will fail
because jetty is still running and can't be started again.
 
Here's an example stack trace:
 
java.lang.RuntimeException: ConnectionPoolManager already configured
at
com.aex.common.manager.ConnectionPoolManager.configure(ConnectionPoolManager.java:234)
at com.aex.common.servlet.InitializeListener.contextInitialized(InitializeListener.java:67)
at
org.mortbay.jetty.servlet.WebApplicationContext.start(WebApplicationContext.java:439)
at org.mortbay.http.HttpServer.start(HttpServer.java:663)
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.apache.cactus.extension.jetty.JettyTestSetup.setUp(JettyTestSetup.java:169)
at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.extensions.TestSetup.run(TestSetup.java:23)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
 
The Exception is caught in the try block around TestSetup.java:18. Jetty is running at this point
but teardown is never called to stop it even though the test is over.
 
I'd suggest replacing the startup line in org.apache.cactus.extension.jetty.JettyTestSetup with
something like:
 
       // Start the Jetty server
        try {
server.getClass().getMethod("start", null).invoke(server, null);
        } catch (Throwable ex) {
try {
boolean started = ((Boolean) server.getClass().getMethod("isStarted",
null).invoke(server, null)).booleanValue();
if (started) {
server.getClass().getMethod("stop", null).invoke(server, null);
}
} finally {
if (ex instanceof Exception) {
throw (Exception)ex;
} else {
throw (Error)ex;
}
}
        }

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Serge Knystautas made changes - 20/Mar/04 07:02 PM
Field Original Value New Value
issue.field.bugzillaimportkey 24072 15840
Vincent Massol made changes - 17/Apr/04 03:15 PM
Description If an exception occurs while starting a jetty context, the setup will throw an exception and
teardown won't be called even though jetty is still running. Subsequent jetty tests will fail
because jetty is still running and can't be started again.
 
Here's an example stack trace:
 
java.lang.RuntimeException: ConnectionPoolManager already configured
at
com.aex.common.manager.ConnectionPoolManager.configure(ConnectionPoolManager.java:234)
at com.aex.common.servlet.InitializeListener.contextInitialized(InitializeListener.java:67)
at
org.mortbay.jetty.servlet.WebApplicationContext.start(WebApplicationContext.java:439)
at org.mortbay.http.HttpServer.start(HttpServer.java:663)
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.apache.cactus.extension.jetty.JettyTestSetup.setUp(JettyTestSetup.java:169)
at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.extensions.TestSetup.run(TestSetup.java:23)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
 
The Exception is caught in the try block around TestSetup.java:18. Jetty is running at this point
but teardown is never called to stop it even though the test is over.
 
I'd suggest replacing the startup line in org.apache.cactus.extension.jetty.JettyTestSetup with
something like:
 
       // Start the Jetty server
        try {
server.getClass().getMethod("start", null).invoke(server, null);
        } catch (Throwable ex) {
try {
boolean started = ((Boolean) server.getClass().getMethod("isStarted",
null).invoke(server, null)).booleanValue();
if (started) {
server.getClass().getMethod("stop", null).invoke(server, null);
}
} finally {
if (ex instanceof Exception) {
throw (Exception)ex;
} else {
throw (Error)ex;
}
}
        }
If an exception occurs while starting a jetty context, the setup will throw an exception and
teardown won't be called even though jetty is still running. Subsequent jetty tests will fail
because jetty is still running and can't be started again.
 
Here's an example stack trace:
 
java.lang.RuntimeException: ConnectionPoolManager already configured
at
com.aex.common.manager.ConnectionPoolManager.configure(ConnectionPoolManager.java:234)
at com.aex.common.servlet.InitializeListener.contextInitialized(InitializeListener.java:67)
at
org.mortbay.jetty.servlet.WebApplicationContext.start(WebApplicationContext.java:439)
at org.mortbay.http.HttpServer.start(HttpServer.java:663)
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.apache.cactus.extension.jetty.JettyTestSetup.setUp(JettyTestSetup.java:169)
at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.extensions.TestSetup.run(TestSetup.java:23)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
 
The Exception is caught in the try block around TestSetup.java:18. Jetty is running at this point
but teardown is never called to stop it even though the test is over.
 
I'd suggest replacing the startup line in org.apache.cactus.extension.jetty.JettyTestSetup with
something like:
 
       // Start the Jetty server
        try {
server.getClass().getMethod("start", null).invoke(server, null);
        } catch (Throwable ex) {
try {
boolean started = ((Boolean) server.getClass().getMethod("isStarted",
null).invoke(server, null)).booleanValue();
if (started) {
server.getClass().getMethod("stop", null).invoke(server, null);
}
} finally {
if (ex instanceof Exception) {
throw (Exception)ex;
} else {
throw (Error)ex;
}
}
        }
Environment Operating System: Other
Platform: Other
Operating System: Other
Platform: Other
Fix Version/s 1.6 [ 10691 ]
Assignee Cactus Developers Mailing List [ cactus-dev@jakarta.apache.org ] Vincent Massol [ vmassol ]
Priority Blocker [ 1 ]
Vincent Massol made changes - 17/Apr/04 03:16 PM
Status Resolved [ 5 ] Closed [ 6 ]
Vincent Massol made changes - 17/Apr/04 03:43 PM
Priority Blocker [ 1 ] Major [ 3 ]