Module CSC7321—CSN: Middleware and software architecture for Internet distributed applications

Portail informatique

JavaEE Lab 1 — Stateless and Stateful Beans

For this lab, we use the Glassfish JakartaEE reference implementation, provided by the Eclipse Foundation.

Check the installation of JAVA, Maven, net tools, and Eclipse

Before installing Glassfish, if not already done, check your installation of JAVA, Maven, net tools, and Eclipse in the installation page

Installation of Glassfish 6

Get glassfish 6. On a machine in B313 or 3A401, you can get it using a copy:

cp ~chabrido/glassfish-6.1.0.zip .

On your own machine, you can download it. Download glassfish-6.1.0.zip.

unzip glassfish-6.1.0.zip; rm -rf glassfish-6.1.0.zip

Add the following lines to your ~/.bashrc file.

GLASSFISH_HOME=$HOME/glassfish6 CLASSPATH=$CLASSPATH:.:$HOME/glassfish6/glassfish/lib/*:$HOME/glassfish6/glassfish/lib/appserv-rt.jar:$HOME/glassfish6/glassfish/lib/javaee.jar #DERBY PATH=$HOME/glassfish6/glassfish/bin:$HOME/glassfish6/javadb/bin:$PATH export GLASSFISH_HOME PATH CLASSPATH

Open a new terminal so that your environment variables get properly set allowing you to use glassfish.

Documentation on Glassfish

Latest available documentations

The latest documents on glassfish are available here.

Glassfish basic features

See the glassfish quickstart guide to discover more on the basic features of glassfish.

Verify installation and start the glassfish application server

Verify your installation with:

asadmin help

It should display information on the available administration command for glassfish.

If this is not the case, check that the environment configuration has been permanently added to your account. For this purpose, the configuration lines have to be added to your shell configuration file (e.g., $HOME/.bashrc for the bash shell). You also need to start a new session by opening a new terminal window or force a lecture of your configuration file with the command:

. $HOME/.bashrc

Launching glassfish

Start the server by entering this command:
$ asadmin start-domain domain1

When the start up process has completed, many lines appear with the last one being as follows: "Command start-domain executed successfully."

Launching glassfish in verbose mode

You may want to start glassfish in verbose mode to display messages emitted on the server side. In that case, the terminal window will work in interactive mode and the server can be stopped using CTRL C.
$ asadmin start-domain -v domain1

Is glassfish running?

Check that the glassfish application server is running. In a web navigator window, try to access to URL: http://localhost:8080. You should get an information page and no error message.

Stop the application server

With the following command:
$ asadmin stop-domain domain1

Programming with Session Beans

Get the source code of the examples

Download the examples from examples-ejb.zip

Study the code of the examples

Read carefully the explanations on the different sample versions.

Once a component has been deployed, you can check it is currently available in the list of running components:

$ asadmin list-applications

CALCULATOR application

Based on the given examples, develop a client-server system for a calculator application offering at least 10 different methods. The interface of this calculator should offer both synchronous and asynchronous methods using the Future mechanism.

The implementation has to be done using only session beans on the server side.

Develop a complete working calculator solution following these steps:

  • First write the interface and the implementation of the required EJB components.
  • Then write the code of a client application.
  • Test and validate the behavior of your application.
  • Return your source code (in a zip archive) on Moodle as assignment 1.