Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Restart workbench in a new VM process
Restart workbench in a new VM process [message #1273959] Thu, 20 March 2014 20:08 Go to next message
Barys Dubauski is currently offline Barys DubauskiFriend
Messages: 38
Registered: July 2009
Member
Our application needs to be able to automatically restart in a new VM process (since it might have performed a JRE refresh as part of its functionality). I've looked at the RAP 2.2 source and found that Workbench.restart() function is commented out and the comment says: "// RAP [bm]: no restart".

I have two questions:
1) why is it disabled?
2) what is the recommended way to restart RAP application programmatically in a new VM process?

Thank you,
-Boris
Re: Restart workbench in a new VM process [message #1281030 is a reply to message #1273959] Mon, 31 March 2014 08:49 Go to previous messageGo to next message
Barys Dubauski is currently offline Barys DubauskiFriend
Messages: 38
Registered: July 2009
Member
Any insight on this from RAP developers?
Re: Restart workbench in a new VM process [message #1281232 is a reply to message #1281030] Mon, 31 March 2014 15:05 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Barys,
to restart the application reload browser window from the server by
executing:
final JavaScriptExecutor executor =
RWT.getClient().getService(JavaScriptExecutor.class);
executor.execute("window.location.reload(true);");
This will create a new UI session. I don't understand what do you mean
by "new VM process". You want to restart the servlet container in a new
VM process from your RAP application?
Best,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Restart workbench in a new VM process [message #1281366 is a reply to message #1281232] Mon, 31 March 2014 19:45 Go to previous messageGo to next message
Barys Dubauski is currently offline Barys DubauskiFriend
Messages: 38
Registered: July 2009
Member
Thank you for the reply, Ivan.

Let me explain a bit more. Before we converted our RCP application to RAP it had a function which allowed automatic restart of the application when certain button is clicked. This was achieved using PlatformUI.getWorkbench().restart(); call. What this would do:
- is shutdown Eclipse/Equinox framework (old process running Eclipse would terminate) and
- automatically restart it (using new process).

SWT implementation used Workbench.restart(); call to accomplish that.

I found out that RAP implementation has Workbench.restart() disabled and wondering why and what are my options now to force equinox framework to restart. Our RAP application is plugged into equinox/jetty framework using org.eclipse.rap.ui.entrypoint.

Why is Workbench.restart() function commented out? What is the alternative to restarting Workbench?

Thank you for any pointers

[Updated on: Fri, 04 April 2014 06:49]

Report message to a moderator

Re: Restart workbench in a new VM process [message #1285832 is a reply to message #1281366] Sun, 06 April 2014 02:12 Go to previous messageGo to next message
Barys Dubauski is currently offline Barys DubauskiFriend
Messages: 38
Registered: July 2009
Member
I've tried shutting down the Workbench using PlatformUI.getWorkbench().close() method and then starting new process using ProcessBuilder class (a Java 7 alternative to Runtime.exec()) but I am running into exception "Address already in use: bind". See the stack below. I suspect that the exception is due to old jetty server process holding onto URL and thus block new server process from allocating it. In my scenario I need to reuse the same server URL as prior to restart.

!ENTRY org.eclipse.equinox.http.jetty 4 0 2014-04-05 19:01:44.870
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Exception in org.eclipse.equinox.http.jetty.
internal.Activator.start() of bundle org.eclipse.equinox.http.jetty.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: org.osgi.service.cm.ConfigurationException: default : Address already in use: bind
at org.eclipse.equinox.http.jetty.internal.HttpServerManager.updated(HttpServerManager.java:115)
at org.eclipse.equinox.http.jetty.internal.Activator.start(Activator.java:62)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
at java.security.AccessController.doPrivileged(AccessController.java:330)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
... 12 more
Caused by: java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:567)
at sun.nio.ch.Net.bind(Net.java:547)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:259)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:86)
at org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:182)
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:311)
at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:260)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.Server.doStart(Server.java:273)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.equinox.http.jetty.internal.HttpServerManager.updated(HttpServerManager.java:113)
... 16 more
Root exception:
org.osgi.service.cm.ConfigurationException: default : Address already in use: bind


Am I not properly shutting down jetty server / RAP prior to restart? Thanks for any pointers here.

-Boris
Re: Restart workbench in a new VM process [message #1286054 is a reply to message #1285832] Sun, 06 April 2014 08:18 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Barys,
RAP application is just a single application inside servlet container
(Jetty, Tomcat...). By stop/shutdown the workbench (RAP application) you
didn't stop the servlet container (Jetty). When you run your application
with embedded Jetty (osgi) stopping and starting the osgi again probably
will do the trick, will restart the Jetty server bundle too (I have no
pointers here how to do it). Of course, this will not work if you deploy
your application in another servlet container (Tomcat for example).
Best,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Restart workbench in a new VM process [message #1290180 is a reply to message #1286054] Thu, 10 April 2014 00:39 Go to previous messageGo to next message
Barys Dubauski is currently offline Barys DubauskiFriend
Messages: 38
Registered: July 2009
Member
Thank you for the reply, Ivan.

I've gotten much further now and you are correct about stopping embedded Jetty was the key part and especially doing it in a non-blocking fashion. Here is the snippet that might help someone else running into the same issues:

            
new Thread() {
  public void run() {
     try {
         final BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
         if ( bundleContext != null ) {
            // stop jetty Platform.getBundle("org.eclipse.equinox.http.jetty").stop(org.osgi.framework.Bundle.STOP_TRANSIENT); //$NON-NLS-1$
            // stop osgi
                         bundleContext.getBundle(0).stop(org.osgi.framework.Bundle.STOP_TRANSIENT);
         }            
     } catch (BundleException ex) {
         log.error("problem stopping jetty");
     }
  }
}.start();


My only remaining issue now is automatic refresh of the browser after specified timeout. The code below used to work

        
    String REFRESH_DELAY = "20000"; // in ms //$NON-NLS-1$
    // client side: auto-refresh to pick up newly restarted server contents 
    JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
    executor.execute("setTimeout(function(){window.location.reload(true);}," + REFRESH_DELAY + ");"); //$NON-NLS-1$ //$NON-NLS-2$


Regardless of the timeout value I set the browser just displays "Network Error" dialog with message: "The server seems to be temporarily unavailable". Does this error get set automatically whenever server is shutdown? Any way to make the same browser instance auto-refresh without running into this error?

Thank you again for all the help on these forums.

Regards,
-Barys
Re: Restart workbench in a new VM process [message #1291762 is a reply to message #1290180] Fri, 11 April 2014 07:40 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Barys,
this error is shown on the client when requests is sent and the server
is not reachable.
Best,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:Mobile browser support and global scrollbars
Next Topic:Linebreak in ComboViewer-Dropdown with RAP 2.2
Goto Forum:
  


Current Time: Thu Apr 25 22:03:36 GMT 2024

Powered by FUDForum. Page generated in 0.03429 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top