Sun Java System Application Server
|
Samples
Index
The EJB 3.0 Stateless Session Bean 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 StatelessJavaClient {
public static void main(String args[]) {
try {
InitialContext ic = new InitialContext();
StatelessSession sless = (StatelessSession)
ic.lookup("javaee_samples.hello.stateless.StatelessSession");
System.out.println("StatelessSession bean says : " + sless.hello());
} catch(Exception e) {
e.printStackTrace();
}
}
}
Building, Deploying, and Running the Java Client
Following are the instructions for building, deploying, and running
the Java Client.
- Setup your build environment and Configure the application
server with which the build system has to work by following the
common build instructions.
test_dir
is the sample application test
directory: install_dir/samples/foo/test
Change directory to test_dir.
- Build, and Run the test using the target runtest
app_dir>
ant
runtest
- The runtest target depends on hello-stateless-ejb so make sure
that the ejb code is built and deployed prior to running this target.
- 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.
- 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.