Wednesday, 6 May 2009

1-How to Develop Container-Managed-Persistence Entity Beans

This article is about how I managed to build CMP Entity Beans using the Developing Container-Managed Persistence Entity Beans example of tinptB ‘s Blog: EJB in 21 Days:
I appreciate her excellent English, which makes a soothing effect while trying to break through difficulties.

The difference of my work to TINPTB’s is first my work is complete and contains everything necessary to work.
TINPTB’s mission is more about teaching EJB’s thus she concentrates on providing the concise source necessary for creating them. He also provides necessary deployment descriptor scripts for both WebLogic and JBOSS. At this point her work begins to get questionable due to the different versions etc…

My solution works on Jdeveloper 11g(only the client not the deployment), WebLogic10.3, wlfullclient5, apache-ant-1.7.1 and mysql-essential-5.1.30-win32, mysql-connector-java-5.0.8 and Toad for MySQL 4.1 Freeware.

The first difficulty I had was the name used namely order is actually considered a key word by WebLogic 10.3,
Thus I had to change the CMP Entity Bean to XXXARS, ARS being the initials of my name.

Second, TINPTB does not need tomention that there has to be a file somewhere. He may be using the WebLogic console or some other tool instead…???

1- I created/copied the OrderXXX files as given in EJB in 21 Days. I had to change the library name(cmpex).
I also put the ejb-jar.xml, weblogic-ejb-jar.xml, weblogic-cmp-rdbms-jar.xml files into src/META-INF directory. I put the and also in the src directory. So, the directory structure is:
Bmpex ..........................META-INF ....ejb-jar.xml ..............weblogic-ejb-jar.xml .......weblogic-cmp-rdbms-jar.xml

At the same level with src lies:
Lib Build Deploy build.xml

But also, in your weblogic domain’s lib directory, by the way I use DefaultServer;
should include

2- I changes all names ‘order’ to ‘orderARS’. I changed ‘ch11’ lib names to ‘cmpex’. Most important,
There is a small discrepancy in the definition of
If I give data-source-name above it asks for the JNDI name. So, I entered the JNDI name there.
3- I deployed with WLST as my WebLogic console does not work (or exist at all for some mysterious reason).


deploy("CMPent","C:/CMPentity/deploy/CMPent.jar" "DefaultServer",securityModel="Advanced", block="true")

Here, the library CMPEntity is the place where I used a build.xml file with Ant to compile and create the CMPent.jar. I also used ANT RUN command to run the client here. You may find this build file towards the end of this BLOG entries series.

If something goes wrong about the data source definition or ejb’s make sure that the JNDI tree has corresponding entries. For that, you can use
and so on…