Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Store] Re-connection to server
[EMF Store] Re-connection to server [message #1283462] Thu, 03 April 2014 12:53 Go to next message
Flo Dubois is currently offline Flo DuboisFriend
Messages: 2
Registered: September 2012
Junior Member
Hello everyone !

I'm having some problems using EMF Store as an internal model database for my RCP application (e4 ! Cool )
I'm doint all the stuff programmaticaly, on the launch of my application.
On the first launch, I create a new server, a new project, I share the project to the server, and I commit some changes after populating the model.
Until now, everything works pretty well !
BUT,
The second step is on a future launch of my application. I want to get the previously committed model.
So I search for the server using his name, I get the remote project and I try to checkout it in a fresh local project.
BOOM
I'm getting :
Usersession not logged in. Login first

So I use the previous user session to log in.
Then I get :
Server could not be reached. Failed to read server's response: Connection refused: connect


After that, I don't know what I could do. Any hint ?

Thanks in advance

Flo

[Updated on: Thu, 03 April 2014 13:36]

Report message to a moderator

Re: [EMF Store] Re-connection to server [message #1284286 is a reply to message #1283462] Fri, 04 April 2014 09:51 Go to previous messageGo to next message
Edgar Mueller is currently offline Edgar MuellerFriend
Messages: 89
Registered: March 2011
Member
Hi Flo,

how exactly do you try to login the previous usersession?
If you call getLastUserssesion() on the ESServer instance you will
get back the most recent usersession, which successfully was logged in.
You may then call refresh() on it to log it in again.
Note that you can only do so, if you previously set the usersession to
save the password by calling setSavePassword(true) on the ESUsersession.
EMFstore does not save passwords by default and keeps requesting them if
setSavePassword hasn't been specified.

Hope this helps,
Cheers

Edgar

Am 03.04.2014 15:19, schrieb Flo Dubois:
> Hello everyone !
>
> I'm having some problems using EMF Store as an internal model database
> for my RCP application (e4 ! 8) )
> I'm doint all the stuff programmaticaly, on the launch of my application.
> On the first launch, I create a new server, a new project, I share the
> project to the server, and I commit some changes after populating the
> model.
> Until now, everything works pretty well ! BUT,
> The second step is on a future launch of my application. I want to get
> the previously committed model.
> So I search for the server using his name, I get the remote project and
> I try to checkout it in a fresh local project.
> BOOM
> I'm getting : "Usersession not logged in. Login first".
> So I use the previous user session to log in.
> Then I get : "Server could not be reached. Failed to read server's
> response: Connection refused: connect"
>
> After that, I don't know what I could do. Any hint ?
>
> Thanks in advance
>
> Flo
>


--
Edgar Mueller

Get Professional Eclipse Support: http://eclipsesource.com/munich
Re: [EMF Store] Re-connection to server [message #1287184 is a reply to message #1284286] Mon, 07 April 2014 13:58 Go to previous message
Flo Dubois is currently offline Flo DuboisFriend
Messages: 2
Registered: September 2012
Junior Member
Hi Edgar,
Thank you for your answer ! I was already doing things this way.
The best is to show you my code.

First the first launch, this code works well :
private void firstLaunch() throws IOException, ESException, ESServerStartFailedException
   {
      workspace = ESWorkspaceProvider.INSTANCE.getWorkspace();
      System.out.println("Delete workspace servers");
      for (ESServer existingServer : workspace.getServers())
      {
         try
         {
            workspace.removeServer(existingServer);
         }
         catch (ESServerNotFoundException e)
         {
            e.printStackTrace();
         }
      }
      System.out.println("Delete workspace projects");
      for (ESLocalProject existingLocalProject : workspace.getLocalProjects())
      {
         existingLocalProject.delete(new ESSystemOutProgressMonitor());
      }

      System.out.println("Create and add a new server");
      localServer = ESServer.FACTORY.createAndStartLocalServer();
      localServer.setPort(8080);
      workspace.addServer(localServer);

      System.out.println("Create a new user session");
      usersession = localServer.login("super", "super");
      usersession.setSavePassword(true);

      System.out.println("Create new project : myProject");
      project = workspace.createLocalProject("myProject");
      System.out.println("Share the project : " + project.getProjectName());
      remoteProject = project.shareProject(usersession, new ESSystemOutProgressMonitor());

      Synchronizer.retrieveDataFromRemoteServer(project); // custom data retriever
      project.commit(new ESSystemOutProgressMonitor());
   }


For everyday launches then, this code doesn't works :
private void normalLaunch() throws ESException, IOException
   {
      workspace = ESWorkspaceProvider.INSTANCE.getWorkspace();

      if (workspace.getServers().size() > 0)
      {
         System.out.println("Get the previously created server");
         localServer = workspace.getServers().get(0); // get the local server already created
      }
      usersession = localServer.getLastUsersession();
      if (usersession == null)
      {
         System.out.println("Previous session not found");
         usersession = localServer.login("super", "super");
         usersession.setSavePassword(true);
      }
      else
      {
         System.out.println("Found previous session");
      }
      System.out.println("usersession.isLoggedIn() = " + usersession.isLoggedIn());
      System.out.println("usrSession.getUsername() = " + usersession.getUsername());
      System.out.println("usrSession.getPassword() = " + usersession.getPassword());

      System.out.println("Delete workspace projects");
      for (ESLocalProject existingLocalProject : workspace.getLocalProjects())
      {
         existingLocalProject.delete(new ESSystemOutProgressMonitor());
      }

      usersession.refresh();

      remoteProject = localServer.getRemoteProjects().get(0);
      for (ESRemoteProject rp : localServer.getRemoteProjects(usersession))
      {
         System.out.println("remote project found : " + rp.getProjectName());
      }
      // usersession = localServer.login("super", "super");
      project = remoteProject.checkout("myProject", usersession, new ESSystemOutProgressMonitor());
   }


I'm still getting the error :
org.eclipse.emf.emfstore.internal.server.exceptions.ConnectionException: Server could not be reached.

just when I try the usersession.refresh();

All what I want is just a local server store, storing locally my model in my computer. The server should start with my custom application, checkout the previous model, and stop when my application turns off.


Again, thank you,

Flo
Previous Topic:[EMFStore] Mixed environment problem
Next Topic:ECP Static UI widgets into Editor
Goto Forum:
  


Current Time: Sat Mar 06 17:11:28 GMT 2021

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

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

Back to the top