+

Search Tips   |   Advanced Search

Work with multiple MobileFirst Server instances in MobileFirst Studio

Information about how to work in MobileFirst Studio in a development environment with multiple instances of MobileFirst Server.

As noted in The MobileFirst Development Server and the operations console, in IBM Worklight v6.0.0 the embedded Jetty test server was replaced with an instance of WAS Liberty Profile. This server is referred to as the MobileFirst Development Server, and is associated with MobileFirst projects as the default development server. The Open MobileFirst Console menu item enables you to view it in the operations console. We can think of this instance of Liberty profile as the embedded or internal development server.

MobileFirst Studio can also work with additional external MobileFirst Server instances, for example, an instance of Liberty profile installed on the development computer. These external servers are defined in Eclipse's Servers view. This topic covers the information that we need to know to work with these external servers.


Start and stop MobileFirst Server

Because MobileFirst Server can support multiple MobileFirst projects, there are no longer Start Server and Stop Server menu options that are associated directly with the project. Instead, the server that is associated with a MobileFirst project is started automatically (if the server is not already running) when you perform an action against that server or adapter. For example, the target server starts when we use the MobileFirst Studio command Run As > Run on MobileFirst Development Server.


Path to the MobileFirst Development Server and its console

As previously noted, the default server that is associated with MobileFirst projects is the embedded MobileFirst Development Server. The default path for this server is: http://localhost:10080/PROJECT_NAME. The path to the operations console for this embedded server is: http://localhost:10080/worklightconsole.

There are two consoles now. The first is the operations console, which contains the builder and plug-in logs. The second is the MobileFirst Development Server Console, which contains the MobileFirst Server logs and Liberty profile logs. For more information about setting logging levels for these consoles, see Configure logging in the development server.


Work with multiple development servers

We can create and run multiple MobileFirst projects against the same MobileFirst Server. If we have an additional instance of Liberty profile installed in the development environment, we must ensure that the project you are working with is pointing to the correct server when building, deploying, or viewing it in the console.

Every change that is made to the project source that is related to the project WAR file (under the /server folder) is automatically built and deployed to the current target server. The database connector JAR files and MobileFirst JAR file are also automatically deployed to this target server when you deploy the WAR file. That means that the project WAR file (not applications or adapters) is always updated on the target server. Every time that the project WAR file is built, it also gets deployed to the server associated with that project.

The status of the server and its projects as it appears in the Eclipse Servers view does not always reflect its current status. This is a known issue.


Change the MobileFirst Server associated with a project

We can change the target test server or change the project.context root (which MobileFirst Server it is associated with) by right-clicking the application and selecting Run As > Build Settings and Deploy Target.

This action displays the following window:

If the MobileFirst Server instance to associate with this project is visible in the Server drop-down list, select it, update the Context path if necessary, and click OK. The outcome of this action is:

  1. The project WAR file is automatically updated with the new context root value the next time you build.

  2. After rebuilding and deploying the application, the new context root is also saved in the client-side files.

The selected server now becomes the default test MobileFirst Server. This action also changes the URL under the Open MobileFirst Console menu command, so that it now points to the new server.

If the MobileFirst Server instance you want is not displayed in the list on this Configure MobileFirst Build and Deploy Target window, use the following procedure to add it.


Add a new MobileFirst Server

If the MobileFirst Server instance to select is not visible in the Server dropdown list, we can add a new MobileFirst Server using the following procedure. In this example, the user creates a new server entry for an instance of WAS Liberty Profile installed on his development computer.

  1. First, on the Configure MobileFirst Build and Deploy Target window, click Add Server to display the following window:

  2. Select the server type you want (in this example, WebSphere Application Server V8.5 Liberty Profile), and click Add:

  3. On the resulting screen, set Path to point to the directory containing the new external Liberty profile server.

  4. After we add the new server, it displays under Server runtime environment.

  5. The new external server now is displayed in the Server field of the Configure MobileFirst Build and Deploy Target window. If we select the new server on the Configure MobileFirst Build and Deploy Target window, it becomes the default target test server, and all builds, deployments, and updates of the project WAR files made using the Run As > Run on MobileFirst Development Server command will go there.

An alternate method of reaching this New Server window is to right-click the entry for an existing server in the Eclipse Servers view and select New > Server from the menu, as shown in the following screen capture:

In the New Server window, select the type of server to add and click Next. Continue with the remaining screens of the New Server wizard to define the new server.


Set the port for new MobileFirst Server instances

When your new server is added, we can see it in the Eclipse Servers view. When we double-click it, we can view an Overview page on which we can change the Server Name, change the Host name, and other settings.

When you connect a project in MobileFirst Studio to an existing Liberty profile server (not the MobileFirst Development Server), check one thing before you attempt to build and deploy MobileFirst applications:

Any change that is done directly in the Liberty server.xml file and is related to the Liberty configuration causes a server restart.


Writing server-side Java code in a MobileFirst project

Server-side Java code can be added to a MobileFirst project under the <project>/server/java folder. If that code uses specific server runtime classes, be sure to add the Server Runtime Library to the Project Build Path:

  1. Right-click the project and select Build Path > Configure Build Path.

  2. Then, on the Libraries tab, click Add Library.

  3. On the Add Library window, select Server Runtime and click Next.

  4. On the next screen, select a server runtime library to add to the path and click Finish.
Otherwise, compilation markers can appear in the Java code.


Parent topic: Develop hybrid and web applications