Running Java thin client applications

You can run Java thin client applications on machines installed with either a WebSphere® Application Client installation or a WebSphere Application Server installation.

About this task

Important: Java thin clients are not packaged with JDBC provider classes. For example, the WebSphere Application Server Version 7.0 Java thin client is not packaged with Apache Derby 10.2 classes. Likewise, the version 6.1 Java thin client is not packaged with Cloudscape® Version 5.1, Cloudscape Version 10.0, or Cloudscape version 10.1 classes. Therefore, to utilize the JDBC provider classes (such as Apache Derby, Oracle, DB2®, Informix®, or Sybase) on a Java thin client, you must:
  1. Add the classes to your Java thin client application environment.
  2. Make the classes visible to the Java thin client application. To do this, add the path to the classes in the client classpath within the script that launched the client program.
Otherwise, any attempt to load a database class (such as through the JNDI lookup of a datasource) results in a ClassNotFoundException.
The Java invocation to run a Java thin client application varies between a client and a server. If your Java thin client application needs to run on both a client installation and a server installation, follow the steps in the Running a Java thin client application on a server machine topic.

Procedure

Example

Your Java thin application client no longer needs additional code to set security providers if you have enabled security for your WebSphere Application Server instance. This code found in IBM® i Java thin or pluggable application clients should be removed to prevent migration and compatibility problems. The java.security file from your WebSphere instance in the properties directory is now used to configure the security providers.
Running the thin or pluggable application client with security enabled. The following code examples illustrates how security providers were set programmatically in the main() method and occurred prior to any code that accessed enterprise beans:
import java.security.*;
  ...
  if (System.getProperty("os.name").equals("OS/400®")) {

    // Set the default provider list first.
    Provider jceProv = null;
    Provider jsseProv = null;
    Provider sunProv = null;

    // Allow for when the Provider is not needed, when 
    // it is not in the client application's classpath.
    try {
      jceProv = new com.ibm.crypto.provider.IBMJCE();
    }
    catch (Exception ex) {
	ex.printStackTrace();
    throw new Exception("Unable to acquire provider.");
	}

    try {
      jsseProv = new com.ibm.jsse.JSSEProvider();
    }
    catch (Exception ex) {
	ex.printStackTrace();
    throw new Exception("Unable to acquire provider.");
	}

    try {
      sunProv = new sun.security.provider.Sun();
    }
    catch (Exception ex) {
	ex.printStackTrace();
    throw new Exception("Unable to acquire provider.");
	}

    // Enable providers early and ahead of other providers
    // for consistent performance and function.
    if ( (null != sunProv) && (1 != Security.insertProviderAt(sunProv, 1)) ) {
      Security.removeProvider(sunProv.getName());
      Security.insertProviderAt(sunProv, 1);
    }
    if ( (null != jceProv) && (2 != Security.insertProviderAt(jceProv, 2)) ) {
      Security.removeProvider(jceProv.getName());
      Security.insertProviderAt(jceProv, 2);
    }
    if ( (null != jsseProv) && (3 != Security.insertProviderAt(jsseProv, 3)) ) {
      Security.removeProvider(jsseProv.getName());
      Security.insertProviderAt(jsseProv, 3);
    }

    // Adjust default ordering based on admin/startstd properties file.
    // Maximum allowed in property file is 20.
    String provName;
    Class  provClass;
    Object provObj =  null;

    for (int i = 0; i < 21; i++) {
      provName = System.getProperty("os400.security.provider."+ i);

      if (null != provName) {

        try {
          provClass = Class.forName(provName);
          provObj = provClass.newInstance();
        }
        catch (Exception ex) {
          // provider not found
          continue;
        }

        if (i != Security.insertProviderAt((Provider) provObj, i)) {

          // index 0 adds to end of existing list
          if (i != 0) {
            Security.removeProvider(((Provider) provObj).getName());
            Security.insertProviderAt((Provider) provObj, i);
          }
        }
      } // end if (null != provName)
    } // end for (int i = 0; i < 21; i++)
  } // end if ("os.name").equals("OS/400")
For examples of Java thin client applications, refer to the Samples section of the information center.



In this information ...


IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic Task topic    

Terms of Use | Feedback

Last updatedLast updated: Sep 19, 2011 6:15:55 PM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=matt&product=was-express-dist&topic=tcli_runjavathin
File name: tcli_runjavathin.html