Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338766 - Jetty server doesn't unload all classes and threads when restart dynamically?
Summary: Jetty server doesn't unload all classes and threads when restart dynamically?
Status: RESOLVED WONTFIX
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: 7.3.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 7.2.x   Edit
Assignee: Greg Wilkins CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-02 21:47 EST by mickyp CLA
Modified: 2011-03-31 18:29 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mickyp CLA 2011-03-02 21:47:51 EST
Build Identifier: 20100917-0705

I use Jetty as my embedded web server in my application.

 

And I have a function to restart the Jetty dynamically in my application.

 

I just use the org.eclipse.jetty.server.Server.start() to start a web server and org.eclipse.jetty.server.Server.stop() to stop a web server.

The problem is I have DWR in my web application and when restart the Jetty, DWR will throw an exception as below.

 

It seems the Jetty didn’t unload all loaded classes or didn’t stop running threads when Jetty stopped. So that the restart will cause the problem but the first start is ok.

 
----------
2011/2/17 PM 05:18:59 org.directwebremoting.impl.DefaultServerContextBuilder get

severe: Error initializing ServerContext because this is not a DWR thread and there is more than one DWR servlet in the current classloader.

2011/2/17 PM 05:18:59 org.directwebremoting.impl.DefaultServerContextBuilder get

severe: This probably means that either DWR has not been properly initialized (in which case you should delay the current action until it has)

2011/2/17 PM 05:18:59 org.directwebremoting.impl.DefaultServerContextBuilder get

severe: or that there is more than 1 DWR servlet is configured in this classloader, in which case you should provide a ServletContext to the get() yourself.

2011-02-17 17:18:59.450:WARN::/center/ppbe.json

java.lang.IllegalStateException: No singleton ServerContext see logs for possible causes and solutions.

        at org.directwebremoting.impl.DefaultServerContextBuilder.get(DefaultServerContextBuilder.java:46)

        at org.directwebremoting.impl.DefaultServerContextBuilder.get(DefaultServerContextBuilder.java:29)

        at org.directwebremoting.extend.Factory.get(Factory.java:60)

        at org.directwebremoting.ServerContextFactory.get(ServerContextFactory.java:35)

        at com.cyberpowersystems.ppbe.center.core.facility.FacilityUpdater.getScriptSession(FacilityUpdater.java:293)

        at com.cyberpowersystems.ppbe.center.core.facility.FacilityUpdater.isScriptSessionViewSnapExist(FacilityUpdater.java:265)

        at com.cyberpowersystems.ppbe.center.core.jsonservice.handler.DevicePresentHandler.handle(DevicePresentHandler.java:29)

        at com.cyberpowersystems.ppbe.center.core.jsonservice.RequestProcessor.process(RequestProcessor.java:73)

        at com.cyberpowersystems.ppbe.center.ui.web.jsonservice.JsonServiceServlet.doPost(JsonServiceServlet.java:66)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)

        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:527)

        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1216)

        at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)

        at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)

        at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)

        at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)

        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187)

        at com.cyberpowersystems.ppbe.center.ui.web.processor.PathFilter.processUrlRequest(PathFilter.java:171)

        at com.cyberpowersystems.ppbe.center.ui.web.processor.PathFilter.doFilter(PathFilter.java:85)

        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187)

        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:421)

        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)

        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:493)

        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)

        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:930)

        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:358)

        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)

        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:866)

        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)

        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:245)

        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)

        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)

        at org.eclipse.jetty.server.Server.handle(Server.java:351)

        at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:594)

        at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1059)

        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:764)

        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217)

        at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:424)

        at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:241)

        at org.eclipse.jetty.server.ssl.SslSocketConnector$SslConnectorEndPoint.run(SslSocketConnector.java:645)

        at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)

        at java.lang.Thread.run(Unknown Source)

 

Reproducible: Always

Steps to Reproduce:
1. embedded Jetty in Java
2. add DWR in WAR
3. dynamically restart Jetty
Comment 1 mickyp CLA 2011-03-09 20:42:52 EST
The problem is solved by DWR, ref: http://directwebremoting.org/jira/browse/DWR-498

See if the Jetty need to handle static variable or not when restart?
Comment 2 Greg Wilkins CLA 2011-03-31 18:29:37 EDT
Jetty did have a couple of references holding old classloaders in memory.
These have been fixed in latest jetty 7.3 releases, so if DWR is loaded from the WEB-INF/lib directory, then the loaded class should be correctly discarded when the context is stopped.  But I don't think this could have been your problem.

Note that if  you load DWR from the system classpath, then you may need to manage the statics yourself - perhaps in the destroy methods.


Where were you loading DWR from?   if it was from WEB-INF/lib and the static was set after a restart, then please reopen this issue and we'll look more closely.