Difference between revisions of "Protege Client-Server Tutorial"

From Protege Wiki
Jump to: navigation, search
 
(45 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
<div class="orangeBox">
 
<div class="orangeBox">
 
<span class="orangeBoxTitle">Protege Client-Server Tutorial</span><br /><br />
 
<span class="orangeBoxTitle">Protege Client-Server Tutorial</span><br /><br />
'''This tutorial explains how to configure and run Protege in client-server mode and is intended for experienced Protege users.'''<br /><br />
+
'''This tutorial explains how to configure and run Protege in client-server mode. Client-server mode allows multiple Protege clients to simultaneously edit a shared ontology stored on a Protege server. Client-server mode is also referred to as the multi-user mode of Protege and is suitable for projects in which multiple users need to access and edit the same ontology.'''
 
 
Please note the following limitations of the client-server capabilities:
 
 
 
* The security system described in the "configuring the server" section is not implemented. The classes exist in the "projects project" but the underlying implementation is absent in the application. The only available security is via the user accounts and passwords.
 
* Forms edited by clients are not propagated to the server (or to other clients).
 
  
 
</div><br /><br />
 
</div><br /><br />
Line 12: Line 7:
 
__TOC__
 
__TOC__
  
== Starting and Testing the Server ==
+
== Protege's client-server mode==
 
 
=== Start the Server ===
 
 
 
There are two processes that need to be started.  In the root directory of your Protege installation, we have provided both an example Windows batch file ("run_protege_server.bat"), and an example Unix shell script ("run_protege_server.sh") to launch these processes. It is important to be aware of what the batch files are doing, so we suggest starting the processes manually at least once.
 
 
 
The '''first process''' to kick off is a background process called "rmiregistry", which is part of the standard [http://en.wikipedia.org/wiki/Java_Runtime_Environment#Java_Runtime_Environment Java Runtime Environment]. If you downloaded the version of Protege that includes a Java Virtual Machine, you will find the rmiregistry executable in your jre/bin directory. If you installed Protege without a VM, you will need to locate and run the rmiregistry executable from the directory where you installed your VM (no parameters are necessary).
 
 
 
To follow are the steps for running the rmiregistry executable:
 
 
 
* Launch a console window.
 
* Change the working directory to the Protege installation directory.
 
* If you are using Windows, type "start /min jre\bin\rmiregistry".
 
* If you are using Unix, type "jre/bin/rmiregistry &".
 
 
 
'''Note:''' If you installed Protege without a VM and your Java installation is located in a path with spaces (such as  "C:\Program Files\Java\jre1.5.0_08\bin\rmiregistry.exe") the start command for the RMI Registry in the "run_protege_server.bat" will fail. To fix this, change the command to:
 
 
 
<code>start "rmiregistry" /min "C:\Program Files\Java\jre1.5.0_08\bin\rmiregistry.exe"</code>
 
 
 
The rmiregistry process will either start with no messages, or will crash saying that the port is already in use. The latter result probably means that you are already running rmiregistry. Either of these results is fine. You only need one version of rmiregistry running on your machine since all applications can use it.
 
 
 
The '''second process''' to kick off is the Protege server process, using the following command (please note that this is a single command):
 
 
 
'''Windows:'''
 
 
 
<code>
 
jre\bin\java -Xmx200M -cp protege.jar;looks-2.1.3.jar;unicode_panel.jar -Djava.rmi.server.codebase=file:/c:/program%20files/protege_3.3.1/protege.jar edu.stanford.smi.protege.server.Server examples\server\metaproject.pprj
 
</code>
 
 
 
'''Unix:'''
 
 
 
<code>
 
jre/bin/java -Xmx200M -cp protege.jar:looks-2.1.3.jar:unicode_panel.jar -Djava.rmi.server.codebase=file:/home/rwf/protege_3.1/protege.jar
 
edu.stanford.smi.protege.server.Server examples/server/metaproject.pprj
 
</code>
 
 
 
The meaning of the parameters will be explained in the [[#Configuring_the_Server|Configuring the Server]] section. The intent of this section is simply to get you going as quickly as possible. The set of parameters listed above assumes that you have installed Protege in the default location with the default directory name. On Unix, you will have to change the path of the codebase parameter to point to the proper location of the Protege JAR file (note that this path must be "absolute" from the root - no shortcuts!).
 
 
 
The Protege server should start up with the normal console window output (the build number, the version of the JVM used, a list of installed plug-ins, etc.). In addition, you should see the following output:
 
 
 
<code><pre>
 
Available Projects:
 
Newspaper
 
Wines
 
Protege server ready to accept connections...
 
</pre></code>
 
 
 
To follow is a screenshot of what this looks like on a Windows machine:
 
 
 
[[Image:ClientServerTutorial_start-the-server.jpg|none]]<br />
 
 
 
Congratulations! You now have the server running.
 
 
 
''Please note the following:''
 
 
 
* On Unix, the metaproject unfortunately refers to other Protege projects using relative paths containing Windows "\" characters rather than Unix "/" characters. Please edit the metaproject (with Protege) to correct these characters before starting the server, otherwise it will complain about projects that can't be found.
 
 
 
* If you start the server twice there are no error messages. The second instance takes over accepting new client connections, while the first continues working with existing client connections, if any.
 
 
 
'''Warning:''' We recommend the use of database projects with the Protege server. However, if for some reason you want to use a file-based project (like those in the example above), you will need to tell the server to periodically save the project to disk. If you do not specify a save interval, any changes you make will be lost if the server goes down. The way to tell the Protege server to periocially save your project is to launch it with the following additional command line option:
 
 
 
<code>
 
...server.Server -save<nowiki>IntervalSec</nowiki>=N ...
 
</code>
 
 
 
where N is the number of seconds between saves. A reasonable number for N is perhaps 120 (every two minutes). If your project is large you may want to chose a larger number since the system will be unavailable while the save is taking place. Note that saves are only performed when a project changes.
 
 
 
=== Connect a Client to the Server ===
 
 
 
On the same machine, start Protege by double-clicking on the executable. From the "Welcome to Protege" dialog, click the "Open Existing Project..." button, which brings up the "Open Project" dialog.  If you have configured Protege not to show the welcome dialog, you can bring up the Open Project dialog by choosing the File | Open Project... menu item. In the Open Project dialog, click on the Server button in the lower-left corner.  To follow is a screenshot of the dialog after clicking on the Server button:
 
 
 
[[Image:ClientServerTutorial_open-server-project.jpg|none]]<br />
 
 
 
Leave the default information in the dialog (User Name = "Guest", etc.) and press OK. You will then see the "Select Project" dialog, which shows you the available projects (Newspaper and Wines) to choose from:
 
 
 
[[Image:ClientServerTutorial_select-server-project.jpg|none]]<br />
 
 
 
Select the "Newspaper" example and press OK.
 
 
 
In a moment the Newspaper project will load and be available in the client. Changes that you make in the client are actually being propagated to the server (although this is difficult to see with just one client running!).
 
 
 
=== Connect a Second Client to the Server ===
 
 
 
You can run a second client either on the same machine or on a different machine. If you choose to connect from the same machine, just follow the instructions given above. If you choose to connect from a different machine, you need to enter the DNS name for the server machine in the Project | Open Project dialog in the "Host Machine Name" text box (in place of the default value of "localhost"). The DNS name will be something like "yourservermachine.yourdomain.com".
 
 
 
Note that you must use the TCP/IP name (DNS name) for the machine and not the "Windows Networking" name for the machine, even if both of your client and server machines are running Windows. If you don't know your server machine's DNS name you may need to get someone at your site to help you figure it out. If your server machine does not have a DNS name then you cannot connect to it from another machine using Protege.
 
 
 
When you make changes in either of the clients, the changes will immediately be reflected in the other. Try it!
 
 
 
== Configuring the Server ==
 
 
 
This section describes how to configure the projects that are available from the Protege server. (Read this section only if you have succeeded in performing the steps from the previous section [[#Starting_and_Testing_the_Server|Starting and Testing the Server]].
 
 
 
=== The Metaproject ===
 
 
 
The metaproject, located in the examples\server subdirectory by default, contains information about which Protege projects are exported and which users have access to these projects. Note that the built-in security concerning which users can access which projects is on top of whatever other security your system provides, e.g. a firewall.
 
 
 
Use Protege to open the metaproject and spend some time browsing the class heirarchy. You will find a very simple ontology of users, security, and projects:
 
 
 
[[Image:ClientServerTutorial_metaproject.jpg|none]]<br />
 
 
 
Instances of the Project class will be made available to people identified with instances of the User class. The security model represented by the metaproject ontology is essentially equivalent to the security model of the Unix file system. Permissions are divided into "read" and "write" access for users categorized into "owner", "group", and "world". Every project has exactly one owner and users may be a member of any number of groups. "World" is a group that has everyone as a member. The Unix security model is extended a bit in the sense that individual users can be given specific access to a project.
 
 
 
If you examine instances of the User class, you will find the default "Guest" user. For the security conscious, your first task should be to delete the "Guest" user, and any other default users. (Before doing this, you may want to try creating some new users and ensure that they can successfully connect).
 
 
 
If you examine instances of the Project class, you will encounter the Newspaper and Wines projects. Note that these are just references to projects that exist on your disk as part of the default Protege installation. Also note that the specified file locations are relative to the Protege installation directory (actually the current working directory) rather than to the location of the metaproject. If you find this confusing, you can always specify the file locations as absolute paths. If you have other projects that you have created and you want to export them in the client-server version, you should create instances of these projects in the metaproject. (We recommend making a copy of the metaproject first, just in case!). Remember to configure the security for your projects since by default, only the owner has access to a particular project.
 
 
 
After editing the metaproject, save it and restart the Protege server. There is currently no way for the server to read an updated metaproject (we may provide this in the future). You should now be able to see the results of your changes, such as additional projects and users, when you connect from a new client.
 
 
 
== Advanced Topics ==
 
 
 
=== Working with Firewalls ===
 
 
 
If the Protege server is running inside a firewall, you need to open two ports to ensure access from outside the firewall. One port is for the rmiregistry and the other port is for the Protege server.
 
 
 
To set the port that the rmiregistry listens on (the default is 1099), the rmiregistry command must be invoked as:
 
 
 
<code><pre>rmiregistry portno.</pre></code>
 
 
 
For a more specific example, suppose that we use port 5100 for the rmiregistry and we start rmiregistry with the command:
 
 
 
<code><pre>rmiregistry 5100</pre></code>
 
 
 
We will also need to tell the Protege server what port to use to access the rmiregistry. This is done by adding the following JVM option to the command that starts the server:
 
 
 
<code><pre>-Dprotege.rmi.registry.port=5100.</pre></code>
 
 
 
Next, suppose we choose port 5200 for the Protege server to listen on. We tell the Protege server to use this port with the following JVM option:
 
 
 
<code><pre>protege.rmi.server.port=5200.</pre></code>
 
 
 
An example of these server settings can be found in the <protege-install-dir>/run_protege_server.sh Unix shell script.
 
 
 
Finally, when we log in from a Protege client, we need to tell the client where to find the rmiregistry. This is done by appending :5100 to the hostname in the rmiregistry connection screen:
 
 
 
<code><pre>elliptic.dyndns.org:5100.</pre></code>
 
 
 
The Protege client will determine how to find the Protege server when it contacts the rmiregistry.
 
 
 
Another important problem to solve is NAT (Network Address Translation): the IP address of the Protege server host is not the same inside the local network (for example 192.168.1.xxx) as it is outside the network (for example 9.154.38.47). To overcome this (but often losing the ability to access the Protege server from inside the network), you have to add -Djava.rmi.server.hostname=9.154.38.47 to the JVM start options of the Protege server.
 
 
 
Remember, you often have to restart the rmiregistry for changes to take effect.
 
 
 
=== Accessing the Server Programatically ===
 
  
To follow is an example of how to access the remote server programatically:
+
The '''client-server mode''' allows multiple Protege clients to simultaneously edit a shared ontology stored on a Protege server. The client-server mode is also referred to as the '''multi-user mode''' of Protege and is suitable for projects in which multiple users need to access and edit the same ontology.
  
<code><pre>
+
The communication between the client and server is realized using the Java [http://java.sun.com/javase/technologies/core/basic/rmi/index.jsp Remote Method Invocation (RMI)], which works also if the clients and server are behind firewalls. See the ''Advanced Topic'' section for information on how to setup the server to run with a firewall.
RemoteProjectManager rpm = RemoteProjectManager.getInstance();
 
Project p = rpm.getProject("localhost", "Timothy Redmond", "troglodyte", "Newspaper", true);
 
KnowledgeBase kb = p.getKnowledgeBase();
 
</pre></code>
 
  
The code in the box below is another more complicated method that eases the process of opening multiple projects. This approach will allow you to use the same session object to retrieve different remote projects, but you cannot use the same session to open a single project twice.
+
The tutorial is structured in the following way: first, it describes how to configure and start the Protege server and some trouble shooting tips, then it will describe how to connect a Protege client to a server, and then it will describe some advance topics, such as working with firewalls, compression, debugging, etc.
  
<code><pre>
+
'''Note. There is a known Java bug in Java 1.6.0_29 and Java 1.7 that affects the starting of the Protege server. If you use this version, please read [[Troubleshooting_Client_Server_Connections#Java_1.6.0_29_and_1.7_rmiregistry_issue|this information]] first.'''
Project p = null;
 
try {
 
    RemoteServer server = (RemoteServer) Naming.lookup("//localhost/" + Server.getBoundName());
 
    if (server != null) {
 
        RemoteSession session = server.openSession("Timothy Redmond",
 
                                                  SystemUtilities.getMachineIpAddress(),
 
                                                  "troglodyte");
 
        if (session != null) {
 
            RemoteServerProject serverProject = server.openProject("Newspaper", session);
 
            if (serverProject != null) {
 
                p = RemoteClientProject.createProject(server, serverProject, session, true);
 
            }
 
        }
 
    }
 
} catch (Exception e) {
 
    Log.getLogger().severe(Log.toString(e));
 
}
 
</pre></code>
 
  
=== Configuration Settings ===
 
  
There are several settings that can be configured in the client-server mode.  We have discussed some of the system properties:
+
== Setting up the server ==
  
<code><pre>
+
The setup of the Protege server is described in details on the [[Protege_Client_Server_Tutorial_Setup|Server setup wiki page]]. The covered topics include:
-Dprotege.rmi.server.port=...
 
-Dprotege.rmi.registry.prot=...
 
</pre></code>
 
  
... above. There are also optimizations that allow the user to control caching on the client. On the client side the user can specify that certain data on the server will cache information about certain frames from the server side ontology while the client initializes. For example, if the client adds the system properties:
+
* Starting the server
 +
* Testing the server
 +
* Shutting down the server
 +
* Troubleshooting
  
<code><pre>-Dserver.client.preload0=Oncogene_TIM -Dserver.client.preload1=Gene_Kind</pre></code>
+
== Configuring the server: users and policies  ==
  
... then the client will preload Oncogene_TIM and Gene_Kind and their parents before it starts up. For large ontologies and bad network latency this can allow a user to start editing a selected set of classes without having to wait for the client to get the data from the server. The initialization of these classes is included in the Protege client startup.
+
The configuration of the Protege server is described in details on the [[Protege_Client_Server_Tutorial_Configuration|Protege server configuration wiki page]]. The covered topics include:
  
The option:
+
* Description of the metaproject
 +
* Creating new users
 +
* Setting the policies
  
<code><pre>-Dserver.client.preload.skip=true</pre></code>
+
== Administering the server: starting and shutting down server projects ==
  
... disables the pre-caching of frames on the client during the Protege client initialization process. The option:
+
The administration of the Protege server is described in details on the [[Protege_Client_Server_Tutorial_Administration|Protege server administration wiki page]]. The covered topics include:
  
<code><pre>-Dpreload.frame.limit=...</pre></code>
+
* User guide for the Protege Server Administration user interface
 +
* Starting and shutting down server projects
 +
* Killing other users' sessions
 +
* Shutting down the Protege server
  
... limits the number of frames that the client will preload during initilialization.
+
== Advanced topics ==
  
Finally, the option:
+
The advanced topics related to the Protege server are described in details on the [[Protege_Client_Server_Tutorial_Advanced|Advanced wiki page]]. The covered topics include:
  
<code><pre>-Dtransaction.level=...</pre></code>
+
* Running the Protege server as a Windows Service
 +
* Working with Firewalls
 +
* Configuration Settings in the start-up scripts of the server and client
 +
* Debug and Performance Monitoring
 +
* Accessing the Server Programmatically
  
... controls the level of protection associated with transactions. The options are:
+
== Troubleshooting ==
  
* NONE - which means that transactions do not even have rollback capabilities. This is not recommended.
+
Occasionally things to wrong. It is especially hard sometimes to debug problems with the first connection from the client to the server and we have started a [[Troubleshooting Client Server Connections|troubleshooting]] page to give some of ideas on how to troubleshoot a problem.
* READ_UNCOMMITTED - which means that users can see other users changes even if the other user is in a transaction and has not committed the transaction.
 
* READ_COMMITTED - which means that user operations made during a transaction are not seen by other users until they are committed.
 
* REPEATABLE_READ - which means that the system assures a user in a transaction that data he reads will not change for the duration of the transaction.
 
* SERIALIZABLE - which means that transactions are serializable. This is the most stringent form of transaction processing but it is also the most expensive and the most likely to cause problems with locked databases.
 
  
=== Running as a Windows Service ===
+
== Limitations ==
  
In some cases it may be desirable to have the Protege server start as a Windows service. The easiest way to do this is to use the Windows Resource Toolkit which includes the AutoExNt utility. This utility allows Windows batch files to run as a service. Create an Autoexnt.bat file (as per instructions here: http://support.microsoft.com/kb/243486) that changes into your Protege directory and then runs the server. To follow is an example batch file:
+
*'''Forms configuration''' made on the client are not propagated to the server. All clients will see the same forms configuration of the project stored on the server side. We do not currently support different forms for different users. So, if you want to change the forms configuration of a project, you will need to edit the server project in the standalone version of Protege on the server side, and then restart the Protege server for the changes to take effect.
  
<code><pre>
+
*'''Policy mechanism'''. Currently we only enforce some of the operations in the ''GroupOperations'' that define the policies for accessing the server. The list of enforced policies is available on the [[Protege_Client_Server_Tutorial_Configuration#Predefined_and_enforced_policies|server configuration wiki page]]. We also provide a policy mechanism that is accessible via an API. If a project defines its own custom operations and policies for its own UI, then the application can use the policy manager API and enforce their own policies in their custom application (it can also be a tab widget, or a separate application).
@echo off
 
C:
 
cd “\Program Files\Protege”
 
run_protege_server.bat {nid 9WE}
 
</pre></code>
 
  
Once you have completed all the steps in the knowledge base article you will note that the service name is still “AutoExNT”. You can adjust this by using regedit to change the value of the following key to “Protege Server” (the change will not be visible until the server is restarted):
+
== Resources ==
  
<code>HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\AutoExNT\DisplayName</code>
+
You may take a look at [[Collaborative_Protege|Collaborative Protege]] that provides support for collaboration (e.g., change tracking, annotations, discussion threads on ontology entities, chat, etc.). Collaborative Protege works in client-server mode with different ontology languages (OWL, RDF, Frames) and for different Protege backends (files or databases).

Latest revision as of 13:05, January 24, 2012

Protege Client-Server Tutorial

This tutorial explains how to configure and run Protege in client-server mode. Client-server mode allows multiple Protege clients to simultaneously edit a shared ontology stored on a Protege server. Client-server mode is also referred to as the multi-user mode of Protege and is suitable for projects in which multiple users need to access and edit the same ontology.



Protege's client-server mode

The client-server mode allows multiple Protege clients to simultaneously edit a shared ontology stored on a Protege server. The client-server mode is also referred to as the multi-user mode of Protege and is suitable for projects in which multiple users need to access and edit the same ontology.

The communication between the client and server is realized using the Java Remote Method Invocation (RMI), which works also if the clients and server are behind firewalls. See the Advanced Topic section for information on how to setup the server to run with a firewall.

The tutorial is structured in the following way: first, it describes how to configure and start the Protege server and some trouble shooting tips, then it will describe how to connect a Protege client to a server, and then it will describe some advance topics, such as working with firewalls, compression, debugging, etc.

Note. There is a known Java bug in Java 1.6.0_29 and Java 1.7 that affects the starting of the Protege server. If you use this version, please read this information first.


Setting up the server

The setup of the Protege server is described in details on the Server setup wiki page. The covered topics include:

  • Starting the server
  • Testing the server
  • Shutting down the server
  • Troubleshooting

Configuring the server: users and policies

The configuration of the Protege server is described in details on the Protege server configuration wiki page. The covered topics include:

  • Description of the metaproject
  • Creating new users
  • Setting the policies

Administering the server: starting and shutting down server projects

The administration of the Protege server is described in details on the Protege server administration wiki page. The covered topics include:

  • User guide for the Protege Server Administration user interface
  • Starting and shutting down server projects
  • Killing other users' sessions
  • Shutting down the Protege server

Advanced topics

The advanced topics related to the Protege server are described in details on the Advanced wiki page. The covered topics include:

  • Running the Protege server as a Windows Service
  • Working with Firewalls
  • Configuration Settings in the start-up scripts of the server and client
  • Debug and Performance Monitoring
  • Accessing the Server Programmatically

Troubleshooting

Occasionally things to wrong. It is especially hard sometimes to debug problems with the first connection from the client to the server and we have started a troubleshooting page to give some of ideas on how to troubleshoot a problem.

Limitations

  • Forms configuration made on the client are not propagated to the server. All clients will see the same forms configuration of the project stored on the server side. We do not currently support different forms for different users. So, if you want to change the forms configuration of a project, you will need to edit the server project in the standalone version of Protege on the server side, and then restart the Protege server for the changes to take effect.
  • Policy mechanism. Currently we only enforce some of the operations in the GroupOperations that define the policies for accessing the server. The list of enforced policies is available on the server configuration wiki page. We also provide a policy mechanism that is accessible via an API. If a project defines its own custom operations and policies for its own UI, then the application can use the policy manager API and enforce their own policies in their custom application (it can also be a tab widget, or a separate application).

Resources

You may take a look at Collaborative Protege that provides support for collaboration (e.g., change tracking, annotations, discussion threads on ontology entities, chat, etc.). Collaborative Protege works in client-server mode with different ontology languages (OWL, RDF, Frames) and for different Protege backends (files or databases).