Hi all,
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)
Any ideas?
Sincerely,
Micky