Skip to main content

Demo EJB3 Application

3 replies [Last post]
Joined: 2005-01-15

Hi All,

I have registered a new project called ejb3demo (pending approval) - the goal of this project will be to build a demo application using the latest features of EJB 3.0, Java EE 5, JAX-WS, JAXB, etc. I am particularly interested in using this as a testbed for ideas, for prototyping patterns that lead to:

1) Simplicity in design
2) Ease of development/deployment
3) Portability - both within J2EE containers and outside J2EE containers.

Would you interested in collaborating on this project?



ps: I started this project mainly for my own education, and it seemed a good idea to share the process with others who are also learning about all the new stuff.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2005-01-15


Here is a link to the sample projects I am working on:

The JAR file contains following projects:
tpcc-persist - contains Entity classes
tpcc-session - Session beans implementating Data Access layer.
tpcc-j2se - Programs that run under J2SE.
tpcc-ea - Builds and deploys EAR file.
tpcc-client - Demonstrates accessing the session beans from J2EE application client.

Note that I am trying to experiment with how to reuse the EJB3 persistent entities and the EJB3 session beans, both within and outside the J2EE container.

I welcome comments and participants who would like to help me with the development.

Thanks and Regards


Joined: 2003-06-10

Great project!
Can you tell us what is working and what is not working so far? This might guide some of the community members to give some help in the non working areas...


Joined: 2005-01-15

> Can you tell us what is working and what is not
> working so far? This might guide some of the
> community members to give some help in the non
> working areas...

Okay, here is one problem. I have a simple web application that allows users to add, modify Warehouses. I am using persist() for adding new instances, and merge() for updating existing instances. However, when I invoke merge, I get an error because the EntityManager attempts to use INSERT statement rather than UPDATE.

My web application is using a Data Access Layer that is implemented as EJB Session Bean. The update cycle is as follows:

1. Get a list of Warehouses in the system.
2. Allow user to pick one for updating.
3. Display selected Warehouse and allow user to modify it.
4. When the user saves the updated warehouse, persist it using a call to merge(). The merge call is in the Data Access Layer, of course.

Initially, I was not using the original Warehouse object returned by the Data Access Layer - I was creating a new instance and then trying to merge it. This caused an Optimistlic locking exception. I then changed the code to use the Warehouse object returned by the Data Access Layer and updated this. Now I am getting an Exception because the EntityManager is attempting to INSERT the data rather than UPDATE it.

I think that it is a mistake to have two interfaces that are overlapping in functionality. I think that persist() should always do an INSERT and merge() should always do an UPDATE. As it stands now, the behaviour is unpredictable and I think will be a source of confusion to developers.