Workbook 2 delta

Build an Deploy the Example Programs

The difference for this chapter that instead of JBOSS_HOME, APPSERV_HOME must be set to the location of your application server.

Jboss specifics delta

No GlassFish specific files are need in this example. The persistence.xml file has been adapted to suit the needs of the environment as created for GlassFish with Oracle, in such way that database tables are automatically created and dropped when beans are deployed.

Remote JNDI binding

When a session bean with a remote interface is deployed, GlassFish creates an entry in the global JNDI namespace. The remote interface name that is automatically created is equal to the name of the remote interface.

com.titan.travelagent.TravelAgentRemote

This leads to conflicts if multiple beans implement the same remote interface, when this is the case it is necessary to explicitly assign names to beans.

persistence.xml

The updated persistence.xml is compatible with the oracle database and GlassFish application server. Although the property name is different the meaning is equivalent to the configuration as described for Jboss.

Resetting the database

The database can simply be reset by running the normal clean target while the application server is running. Because of the contents of the persistence.xml file the database table will be dropped when an application is undeployed.

Please note, the exercise should be undeployed before starting the next exercise. (This is also valid for future exercises)

Browsing the database

The database can be browsed (and modified via the database homepage in my case this homepage can be accessed using http://127.0.0.1:8080/apex, login and select the object browser.

Exercise 4.2: JNDI Binding with Annotations

(JBOSS_HOME -> APPSERV_HOME)

Using @RemoteBinding

Instead of using @RemoteBinding the mappedName argument of the @Stateless annotation is used.

@Stateless(mappedName="TravelAgent")

This use is according to the suggestion in the javadoc of the Stateless annotation.

Exercise 4.3: JNDI Binding with XML

(JBOSS_HOME -> APPSERV_HOME)

jboss.xml

Instead of jboss.xml a file named sun-ejb-jar.xml is used, the contents is also slightly different.

By default the name is equal to the name of the class, if wanted the name argument of the @Stateless annotation can be used to give another name (which in turn can also be used in the xml file.

As demonstrated in the exercise the XML binding overrides the binding using the mappedName argument in the annotation.




Back to the index Further to Workbook 3


UUIDs and information about UUIDs
If you have improvements, contact information on the homepage of this host.
The uptime of this host