Using MyEclipse Application Servers
MyEclipse includes more than 50 server connectors for application deployment during development. This tutorial provides you with some basics on MyEclipse application servers. You will learn how to:
- Define a new server
- Install a third-party server extension
- Deploy a project
- Publish applications
- Operate a the server and use debugging features
- Customize server configurations
1. Defining New MyEclipse Application Servers
Defining a new server allows you to select the server connector you want to use, provide configuration information, and choose projects to deploy to the server.
- Click on the Servers view toolbar. Alternatively, right-click the Servers view, and select New>Server.
- Select the server connector and version to configure.
Choosing a server connector
- Accept localhost as the host name or provide the fully qualified DNS name or IP address of the host machine.
- Accept the default server name or enter a new name. The server name identifies the server in the Servers view.
- Accept the default Create a new runtime environment option for first-time connector setup, and click Next. For subsequent server connector setup, see Working with Custom Server Connector Configurations.
- Select the path to the server installation.
- The default JRE for the workspace is selected by default. You can select an installed JRE to be used for launching the application server. See Defining a New JRE Installation to add an installed JRE.
- Click Next to select projects to configure on the server.
Adding projects to the server
- Click Finish. The server is configured and appears in the Servers view.
New server in the Servers view
1.1 Defining a New JRE Installation
The JRE installation is used by the connector to launch the application server instance. If you have previously configured a JDK installation, you can select it from the Configured JRE drop-down list in the new runtime environment configuration; otherwise, continue reading to configure a new JRE installation. The default JRE name lists only the JRE used to launch MyEclipse, which is insufficient for supporting the requirements of most application servers.
- Click Installed JREs on the runtime environment configuration page.
- Click Add. Note that while the fields of this window refer to the a JRE environment, the objective is to specify the location of a full JDK as the runtime environment, not the default JRE provided by Sun Microsystems.
- Select the JRE type you want to add to the workspace, and click Next.
- In the JRE home field, browse for and select the root folder of your JDK installation folder, not the JRE folder it contains.
- Enter a name in the JRE name field, and click Finish.
Adding a JDK
- Select the newly configured JDK from the Configured JREs drop-down, and continue with the server configuration.
Selecting an installed JDK
2. Deploying a Java EE Project to an Application Server
During initial server configuration, you can specify existing Java EE projects to run on the server. After a server is configured, you can manually or automatically deploy projects to a server.
2.1 Manual Deployment
There are several ways to deploy a project manually:
- Drag a project to a server in the Servers view
- Right-click a project and select MyEclipse>Add and Remove Project Deployments from the menu
- Click the Manage Deployments icon on the main toolbar
- Right-click a server in the Servers view, and select Add/Remove Deployments
- Click the Add/Remove Deployments icon on the Servers view toolbar.
The steps below demonstrate using the right-click context menu in the Servers view.
- Right-click the server you want to deploy to, and select Add/Remove Deployments.
- Select projects to configure on the server. When supported by the server connector, you have the option to choose either exploded or packaged deployment by using the drop-down beside the module in the Configured column.
Adding a project to the server
- Click Finish.
Project added to the server
2.2 Automatic Deployment
If you don’t want to manually manage your project deployments or server running state, use Automatic deployment to let MyEclipse handle these for you.
- To enable Automatic deployment, right-click your project, and select either Run As> or Debug As>MyEclipse Server Application.
Setting Automatic deployment
- Select the application server on which you want to run your project (or configure a new server connector), and click OK. MyEclipse automatically deploys your application to the selected application server, and then starts or republishes that server for you. Only applicable servers appear in the list.
Note: In the project preferences (Deployment>Server Deployment), you can choose an app server to always deploy the project to when using the Run (Debug) As menu.
Selecting a server to which you want to deploy
In the Servers view, you can expand the the application server on which you ran your project to see the deployments registered with it. In the application server Console view, you likely see log messages reflecting the application server status and the new deployment sent to it.
Expanded server showing deployments
If the deployment mode is Exploded Archive, you can discover the deploy location by hovering over the deployed application in the Servers view.
Viewing deployment information
2.3 Removing a Deployment
Use either of the following methods to remove a deployment from a server:
- From the Servers view toolbar, select the deployment you want to remove, and click .
- Right-click the project, and select Add/Remove Deployment. Select the project you want to remove, click Remove, and click Finish.
Removing a deployment with the Add and Remove window
The project shuts down and is uninstalled from your server instance. As a last step, MyEclipse deletes the deployment from the server. The server logs these activities and issues to the Console view.
3. Publishing Applications on the Server
Publishing syncs up all deployed projects on the server with the associated resource files. When you add projects to a server, whether it is during server configuration or later, the project is not necessarily published on the server. Publishing can be done either with the server running or stopped. When you start a server, deployed applications automatically sync by default. The Servers view displays the status of Republish if applications are out of sync. You can change the default publish behavior in the server configuration file.
Note: When you deploy a project using the Run As (or Debug As)>MyEclipse Server Application, the project is deployed and published simultaneously.
To publish applications on a server, select a server in the Servers view, and click on the Servers view toolbar.
When you remove a project from a running server, publish happens automatically, removing the project and sync’ing all other projects deployed to the server. If you remove a project when the server is stopped, it is not technically removed from the server until the server starts again or until you manually publish the server.
Publishing syncs only project changes to the application server. If you want fresh deployments, you can use the Clean operation by right-clicking the server and selecting Clean (redeploy) from the menu. This removes all deployed applications, and redeploys the projects in their entirety.
4. Application Server Operation and Debugging
From the Servers view, click to launch the selected server in the Run mode, the icon to launch the selected server in Debug mode, or the icon to launch in Profile mode. Alternatively, click the drop-down arrow on the MyEclipse toolbar, and select [your server]>Start, Debug, or Profile (if applicable) from the menu.
Starting an app server from the toolbar
The application server connector redirects the application server’s stdout and stderr streams to the Console view. Monitor the console for server start-up problems. The image below illustrates a successful startup of Tomcat.
Successful Tomcat startup process
4.1 Opening a Deployed Web Project in the Browser
After deploying your project, launch the web application by opening the Servers view. Right-click a deployed web project or web module (if it is part of an EAR), and select Open in web browser.
Opening a deployed project in the browser
This action saves you from having to remember the URL for your application that usually takes the form below:
http://<hostname>:<default port>/<web context root for project>
You don’t have to remember the port or hostname your server is running on, and by using the Open in Browser action, the correct URL opens in the MyEclipse Web Browser automatically.
Project application displayed in the browser
4.2 Debugging a Deployed Application
MyEclipse extends the Eclipse debugger platform to support JSP breakpoints and debug actions. Debugging a deployed Java EE application is similar to debugging a standard Java application.
From either the Java or JSP source editor, you enter breakpoints in the left margin. During application server execution when execution control encounters a breakpoint, the Debug perspective is invoked and debug information displayed. The application server must be launched in Debug mode for breakpoints to be enabled and execution to halt in a breakpoint context. See the Debugger Learning Center for more details about debugging applications.
JSP debugging session
4.3 Stopping an Application Server
From the Servers view, click to terminate the server’s execution. Alternatively, click the drop-down arrow on the main toolbar, and select [your server]>Stop. The application server connector begins the shutdown process for the application server instance.
Initiating Tomcat shutdown
As the application server terminates, you can observe thread termination of the application server’s process. In many cases, shutdown progress messages from the application server are output to the Console view.
5. Working with Custom Server Connector Configurations
Occasionally, you might have a need to launch an application server with an alternative configuration. In such cases, it is possible to create a second server instance with a custom launch configuration. You can configure multiple server connectors for the same server.
- Define a new server using the same runtime environment setting as the previously configured server of this type.
- Double-click the new server in the Servers view to open the server configuration.
Viewing server configuration
- Click the Open launch configuration link.
- Customize the various launch details as needed, and click OK.
Launch Configuration window
Now, you have a server instance with a specific launch configuration to which you can deploy projects.
Servers view with custom launch configuration