Sun Java System Application Server

Samples Index

# The EJB 3.1 Automatic Timer Sample Application - Test Code

Standalone Java Client
Here's an example of a plain Java client that runs outside of a Java EE container. In this case, it does a global JNDI lookup since dependency injection is not available outside of a Java EE component.
public class AutomaticTimerJavaClient {
public static void main(String args[]) {
try {
StatelessSession sless =
(StatelessSession) ic.lookup("java:global/automatic-timer-ejb/StatelessSessionBean");
System.out.println("Waiting for the timer to expire");
Thread.sleep(7000);
List<String> result = sless.getRecords();
System.out.println("Got " + result.size() + " log records:");
for (String s : result) {
System.out.println(s);
}
} catch(Exception e) {
e.printStackTrace();
}
}
}

## Building, Deploying, and Running the Java Client

Following are the instructions for building, deploying, and running the Java Client.

1. Setup your build environment and Configure the application server with which the build system has to work by following the common build instructions.
2. `test_dir` is the sample application test directory: `install_dir/samples/foo/test`
3. ````Change directory to `test_dir.`
4. Make sure the JavaDB database is started. If not, refer to common build instructions.
5. Build, and Run the test using the target runtest``

`app_dir>` ant runtest

6. The runtest target depends on hello-stateless-ejb so make sure that the ejb code is built and deployed prior to running this target.
7. In build.xml, the property 'extra.classpath' points to ejb classes on which this test code depends and the property 'runjavaclient.class.name' points to the Java Client class name which is invoked as a result of running ant runtest.
8. Use the target clean to remove the temporary directories like build and dist.

   `app_dir> ant clean`

## Troubleshooting

If you have problems when running the application, refer to troubleshooting document.

Copyright © 1997-2010 Oracle and/or its affiliates. All rights reserved.