Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
Rick,
I've deployed and tested all the code for parts 1-4 of the tutorial. There were a couple of changes I had to make in order to get it to work on JBoss. The changes are detailed in the attached changes.txt. (show on this page RMH)
The changes mostly stem from JBoss's approach to creating tables. It seems that JBoss wants to treat each cmr field as an additional table column when it generates SQL to create tables. (That's why I got an SQLException before I changed the UserInfoContainedByUser relationship role column name from EMAIL to FK_USER_INFO).
I also finished the simple jsp testing gui (.war file attached). To make life easier in coding the gui, I used the Delegate pattern and created a UserManagementDelegate (source code attached) that creates a reference to a remote UserManagement session bean and passes calls to it onto the session bean.
Let me know what you think. (I think you ROCK! RMH)
Pete
Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
Here's a list of the things I did to deploy the tutorials on JBoss 3.0.1
Problem 0) Primary key cmp fields were listed twice for each entity in jbosscmp-jdbc.xml.
Fix: Removed duplicate entries.
Problem 1) 2002-08-14 13:35:56,609 ERROR [org.jboss.ejb.EjbModule] Initialization failed
org.jboss.deployment.DeploymentException: CMP field for key not found: field name=NAME
Fix: Edited jbosscmp-jdbc.xml file. The <ejb-relationship-role>.<key field>.<field-name>
attributes in this file were in uppercase and didn't match case with the field names in
the ejb-jar.xml file.
For example this:
<key-field>
<field-name>NAME</field-name>
<column-name>FK_GROUP_NAME</column-name>
</key-field>
was changed to this:
<key-field>
<field-name>name</field-name>
<column-name>FK_GROUP_NAME</column-name>
</key-field>
Problem 2) 2002-08-14 13:47:10,227 ERROR [org.jboss.ejb.EjbModule] Initialization failed
org.jboss.deployment.DeploymentException: Role: UserInAGroup with multiplicity many
using foreign-key mapping is not allowed to have key-fields
Fix: Edited jbosscmp-jdbc.xml file. Removed the UserInAGroup key fields.
Problem 3) 2002-08-14 14:55:08,852 ERROR [org.jboss.ejb.EjbModule] Starting failed
org.jboss.deployment.DeploymentException: Error while creating table; - nested throwable:
(java.sql.SQLException: Invalid argument value: Duplicate column name 'EMAIL')
Fix: Edited jbosscmp-jdbc.xml file. Changed the UserInfoContainedByUser
relationship role column name from EMAIL to FK_USER_INFO.
Added a column (FK_USER_INFO) to TBL_USER:
create table TBL_USER (
EMAIL varchar (100) primary key,
PASSWORD varchar (25),
FK_GROUP_NAME varchar (25),
FK_USER_INFO varchar (100),
ACTIVE int,
CONSTRAINT userfk FOREIGN KEY
(FK_GROUP_NAME)
REFERENCES TBL_GROUP(NAME)
);
Changed the constraint on TBL_USER_INFO to reference column added above:
create table TBL_USER_INFO(
...
CONSTRAINT UserinfoToUser FOREIGN KEY
(EMAIL)
REFERENCES TBL_USER(FK_USER_INFO)
...
Problem 4) 2002-08-15 02:46:53,706 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.
User.findLastNameLike] EJB-QL: SELECT DISTINCT OBJECT(user) FROM User user WHERE
user.userInfo.lastName LIKE ?1
2002-08-15 02:46:53,716 WARN [org.jboss.system.ServiceController] Problem starting
service jboss.j2ee:service=EJB,jndiName=User
org.jboss.deployment.DeploymentException: Error compiling ejbql; - nested throwable:
(org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "1" at line 1, column 79.
Was expecting:
<STRING_LITERAL> ...
Fix: Edited ejb-jar.xml file. Changed "LIKE" to "=". JBoss 3.0.1 does not support
EJB-QL "LIKE" expressions with input parameters.
Problem 5) No table specified for UserAssociatedWithRoles relation.
Fix: Added <relation-table-mapping> to jbosscmp-jdbc.xml ejb-relation
UserAssociatedWithRoles:
<relation-table-mapping>
<table-name>TBL_ROLE_USER</table-name>
</relation-table-mapping>
Problem 6) TBL_USER.FK_USER_INFO column was not set when adding full user
(user with info), and user.userInfo was not navigable.
Fix: Edited UserMamagementBean.addUser method by adding a call to
UserLocal.setUserInfo(UserInfoLocal info):
public void addUser(String email, String password, String firstName, String middleName, String lastName,
String dept, String workPhone, String extention, String homePhone,
boolean isEmployee, String groupName){
try {
UserLocal user = userHome.create(email, password);
//Associate userInfo to group
UserInfoLocal info = infoHome.create(firstName, middleName, lastName,
email, dept, workPhone, extention, homePhone, isEmployee);
//Pete added this call
user.setUserInfo(info);
//Add user to group
GroupLocal group = groupHome.findByGroupName(groupName);
user.setGroup(group);
} catch (CreateException e) {
throw new EJBException
("Unable to create the local user " + email, e);
} catch (FinderException e) {
throw new EJBException
("Unable to add user to the group " + groupName, e);
}
}
Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
Achim from Germany writes: "I read your white papers "Introducing EJB-CMP/CMR" part 1 and part 2.... These papers are the best start for EJB.... Now I'm very interested in part 3 (and 4), but I can't find them on the developerWorks Homepage ..." (They are out and ported to JBoss and WebLogic.)
Pete from North Carolina writes: "I've been working through your "Introducing EJB-CMP/CMR" tutorials. Great stuff. Well presented - simple and straight forward. Really learning a lot. "
Patrick from the U.S.A. writes: "Great Job on part 1 and 2 of your tutorial on CMP/CMR and EJB QL. When will part 3 and 4 be out.? Will it be able to run on JBoss Resin, and Orion." (It is done! Part 3 and 4 works with WebLogic and JBoss. I got the examples working with WebLogic and Peter got them working with JBoss. --Rick)
Chintan writes “...thank you for putting out fabulous quality CMP/CMR tutorial. This is the best tutorial I have ever seen. Complete, concise and clear. (Where is the source?) (The source code is at the bottom of this page.)”
Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
Hi Pete and Rick,
I just thought that I might make a small contribution by sending you the jboss port of the part 1-2 series of Rick's cmp/cmr tutorial
series. I couldn't find it on pete's website (I might have missed them... , I saw the part 3-4 port though ). Pete, if you don't have them on
your website, you can post them for all these guys who are just starting out ....
I customized the script for the client , run.bat to run for jboss and also customized the
build.xml, added a jboss.xml and jbosscmp-jdbc.xml
file in the session and entity descriptor folders.
I also use the build in db of jboss, hypersonic sql and added trace output for all the methods that can be followed on the jboss console.
Everything seems to work fine on my computer. Let me know if it works for you too.
Thanks Rick for the great tutorial !!!
(Sure... no problem --Rick )
Yin
CONTRIBUTION FROM YIN: http://www.rickhightower.com/jbossupdate.html/jbosssection4.zip
Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
You may have just won ten million dollars! Or, maybe a tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|