DevPortal

How do I prepare and deploy Web applications?


Table of Contents


How do I prepare and deploy Web applications?

A Web application contains application resources such as servlets, JSPs and JSP tag libraries, and static resources such as HTML pages and image files. A Web application can also define links to resources outside the application such as EJBs. Web applications are deployed on Pramati Web Container, which manages the execution of Web components. Server supports deployment of Servlets 2.4 and JSP 2.0 components.

When you install and start Server, the Web container is installed and started by default. You can configure a node in a cluster to be a pure Web node.

Note: To view Web container details, select Monitor > Web Server in the Explore panel of the Console.

How do I package Web applications?

Web applications can be deployed on Server as .war or .ear files. A .ear contains a .war that may contain the Web deployment descriptor, Web resources, utility classes, and supporting classes.

How do I deploy Web applications?

Web applications can be deployed on Server as standard .war or .ear files. Using the Deploy Tool, set properties such as resource references, resource environment references, and security role references to get applications in a ready-to-deploy state.

How do I run Web applications?

Web components such as JSPs, servlets, HTML pages, image files, and stylesheets can be deployed and run as applications. These applications can also be run in an exploded form.

Package these files as .war or .ear files and deploy them on Server. Application-related information is extracted to the document root. When a client makes a request, the application is accessed from this location.

An open structured application need not be packaged into .war or .ear files. You only need to copy the application files to the Server document root. You can also deploy exploded directories. Instead of copying, Pramati Server serves the application from the deployed directory.

How do I set Web Properties?

Once you have opened an archive in the Deploy Tool, click the Web Properties node in the explore panel to set properties for the .war files. Web applications are handled according to the Servlet 2.4 specification, which describes a standard manner of grouping the various components of a Web-based application, such as JSPs, HTTP Servlets, HTML pages, and image files.

A Web application can also access external resources such as EJBs and JSP tag libraries. A server can host any number of Web applications.

How do I set General Properties?

Click the General tab in the Web Properties node to open the General panel. This panel contains the following attributes:

The context root should be unique for a virtual host in the Server namespace. The context root is the root under which the archive content is available. To modify the context root name, click the name and type the new context root name. To avoid using any context root while accessing the application, use the context root ‘/’. You can access the application with http://<host>:port.

How do I set Environment Properties?

Click Environment tab in the Web Properties node to open the Environment Properties panel. You can assign environment values to defined environment entries. This enables applications to access resources and external information easily without requiring explicit knowledge of how external information is named or organized.

How do I set .war Properties?

Clicking on the .war node on the left panel displays the information corresponding to the tree node selected on the right window. This displays all the details of the Web components in the .war file like Name, Date, Time, Size, Ratio, Packed, Path, and context root of the .war.

How do I set EJB References?

When you click the EJB References tab in the Web Properties node, the EJB References panel is displayed, which is used to declare references to enterprise beans. This panel contains the following attributes:

When you select the Web archive row in this panel, the EJB-ref type, the bean interfaces, and an optional description are displayed. The description field is editable.

How do I set Resource References?

Click the Resource Ref tab in the Web Properties node to view the Resource Reference panel. All the defined resources are obtained from the Server.

This panel contains the following attributes:

When you select a .war node, the resource type, the resource authorization, and an optional description are displayed. The following types of resources can be directly mapped to the Server:

If the resource is bound by a .rar, the type may be any other type representing the JCA connection factory class.

How do I set Resource Environment References?

Click the Res Env Ref tab in the Web Properties node. This panel contains a declaration of the Web application’s reference to an administered object that is associated with a resource in the resource’s environment.

It contains the resource environment reference name and an indication of the resource environment reference type expected by the Web application code. For JMS, the resource environment reference can be selected from javax.jms.Queue and javax.jms.Topic. The drop-down list displays only resource environment type objects.

The deployer can select the value assigned to the .war’s resource environment reference.

How do I set Security Role References?

The Security related views are available only if the selected application contains references to Security.

To open the Security panel, click the Security node in the Deploy Tool. Assign realm roles to the security roles defined in the wars. The available realm roles are obtained from the Security service. This panel contains the following attributes:

Note: If you face a problem, check Monitor > Logs in the Console.

Table 1: Realm attributes

AttributesDescription
RealmSpecifies the realm name.
ModuleDisplays the WAR name or the application-level role name in the security role.
Role NameDisplays all the role names that have already been defined for the application.
Role LinkSpecifies the name of the security role.

How do I Map multiple Roles?

There might be a situation when you define a method-permission element in the ejb-jar.xml. The element specifies that one or more security roles are allowed to invoke one or more enterprise bean methods. The method-permission element consists of an optional description, a list of security role names or an indicator to state that the method is unchecked for authorization, and a list of method elements.

The security roles used in the method-permission element must be defined in the security-role elements of the deployment descriptor, and the methods must be methods defined in the enterprise bean's component and/or home interfaces.

You can map roles to multiple realms using the Deploy Tool. To do so, use the following steps:

  1. Start the Deploy Tool.
  2. Select an archive using Open.
  3. In the left-hand panel, click Security, and then select Application Level Role Mapping.
  4. Select a Role to be mapped.
  5. Assign the Role to an available Group. Use >> to move the Group to the Selected list.
  6. Assign the Role to an available User. Use >> to move the User to the Selected list.
  7. Click Save.
  8. Perform the steps for each Role you wish to map. This can be done for the different realms available as a drop-down list by selecting the desired realms and roles.
  9. Upon saving the archive, the changes made are reflected in the pramati-j2ee-server.xml:
    	<role-mapping>
    	  <module-name>ejb_secEbmp_sec_ejb.jar</module-name>
    	  <role-name>VP<role-name>
    	  <role-link>
    		<group-principal>everybody<group-principal>
    		<group-principal>administrator<group-principal>
    		<user-principal>root</user-principal>
    	  </role-link>
    	</role-mapping>
    	

How do I view deployed Web Clients?

When you deploy an archive on Server, the following structure and files are created:

When you undeploy the application, all these files are removed from the specified location.

What are Pramati Server Web Logs?

You can monitor Server activities by enabling the Web activity logging and analyzing this data to get useful information. Once the service is enabled, the Server:

How do I log Web activity?

When the Server starts, you can specify if the Web activities are to be logged. To log Web activities, open the web-config.xml file. The log file is located at <install_dir>/server/nodes/<node_name>/config.

In the web-log parent tag, set the value of log-on tag to true. For example:

<web-log>
	<log-on>true<log-on>
	<dir-path>$NODE_DIR\abc<dir-path>
</weblog>

Note: You can set this option before starting the Server.

What is the Log Format used by Pramati Server?

Pramati Server uses the Apache Combined Log Format (CLF) to log Web activities. The format string consists of percent directives which indicate the information that Server can log. Literal characters can be placed in the format string and are directly copied into the log output. A back-slash should precede the quote character to prevent it from being interpreted as the end of the format string. The format string may also contain the special control characters \n for new-line and \t for tab.

In Apache CLF, information is stored in the format string as: "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"

Table 2: Values for Apache combined log format

ValueDescription
hThe IP address of the client (remote host) which made the request to the server.
lRemote log name.
uThe userid of the person requesting for the document as determined by http authentication. The same value is typically provided to CGI scripts in the REMOTE_USER environment variable.
tThe time at which Server finished processing the request.
rThe request line from the client enclosed in double quotes. Contains information regarding the method used by the client, the name and type of resource, and the protocol used.
sThe status code sent back to the client by Server. Code begining with 2 indicates that the request resulted in a successful response, code begining with 3 indicates a redirection, code beginning with 4 indicates that an error has been caused by the client, codes beginning with 5 indicates an error in the server
bThis indicates the size of the object returned to the client. This does not include the response headers.
(Referer)iThe "Referer" HTTP request header. This gives information about all the sites and files that the client has accessed.
(User agent)iThe User-Agent HTTP request header. The client browser identifies itself with this information.

For example:

127.0.0.1 - username [10/Mar/2002:13:55:36 -0700] "GET /pramati.gif HTTP/1.0" 200 2326
"http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"

How do I monitor Web Activity Reports?

When logging of Web activity is initiated, a log file is generated. The information in this file is stored in the CLF. The log file is located at the path specified while setting the value of log-on tag to true.

Note: The contents are purged when the file size is big before logging new information in this file. This is taken care of by the operating system. The server automatically saves the contents of this file before purging.

For example:

127.0.0.1 - username [10/Mar/2002:13:55:36 -0700] "GET /pramati.gif HTTP/1.0" 200 2326
"http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"

How do I use Log Analyzers?

Log analyzers are used to analyze the log file information. Some analyzers available free or at a price are:
http://www.mrunix.net/webalizer (free)
http://www.thefreecountry.com/webmaster/loganalyzers.shtml (free)
http://www.softjam.co.uk/acatalog/Log_Analysers.html (at a price)

How do I manually log Web Activity using Servlet APIs?

To log information regarding a specific activity being performed for an application, you can use standard Servlet APIs that allow a fuller control over what is to be logged. The generic servlet class that has to be used for this purpose is javax.servlet Class GenericServlet.

To use the APIs, the com.pramati.web.logging property should be set to true. To set this property, while starting the Server, at the java prompt, type:

java -Dcom.pramati.web.logging=true com.pramati.Server -verbose

To log whatever information is passed into the Server Logs, you can call any of the following two methods:

public void log(java.lang.String message, java.lang.Throwable t)

This method writes an explanatory message and a stack trace for a given throwable exception to the servlet log file, prepended by the servlet's name.

Table 3: Parameters for generating servlet logs

ParametersDescription
messageA string that describes the error or exception.
tThe java.lang.Throwable error or exception.

public void log(java.lang.String msg)

This method writes the specified message to a server log file, prepended by the servlet's name.

Table 4: Parameters for generating servlet logs

ParametersDescription
msgA string specifying the message to be written to the log file.

The log file gets saved at <install_dir>/server/nodes/<node_name>/logs.

What is Enhanced Logging?

Deploy Tool now logs messages, errors, and debug statements. The logs can be viewed from View Menu > View Logs.

By default, the Deploy Tool's log file is located at <user.dir>/Temp/DeployTool/logs/DeployToolTrace.log. The location of the file can be changed by setting the system property com.pramati.deploytooltracefile to point to a properties file that contains the new location or by using the option tracefile command line to point to the tracefile.props containing the logging options.


© Pramati Technologies 2007 Runs on Pramati Server | Feedback | Legal