File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes JBoss CMP read ahead cache problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JBoss CMP read ahead cache problem" Watch "JBoss CMP read ahead cache problem" New topic
Author

JBoss CMP read ahead cache problem

mri wu
Greenhorn

Joined: Apr 02, 2004
Posts: 1
I have a application which was deployed on OC4J application server and now need to be migrated to JBoss. After I change all the CMP ejb beans and successfully depoyed to JBoss 3.2.3 I found that the speed is extremly slow. By using profiling tool I found it was a JBoss CMP beans cause the peformance issue. Every time a JSp call CMP bean's get method will cause a database SQL call (n+1 issue). the simple snippet is like:

Object objRef = initialContext.lookup("ejb/LocalSessionActivitiesEJB");
SessionActivitiesHome home = (SessionActivitiesHome) objRef;
Collection collection = home.findAll();
for (Iterator iterator = collection.iterator(); iterator.hasNext() {
SessionActivities sa= (SessionActivities) iterator.next();
String id = sa.getName();
}
The detailed log related to cache act(enable TRACE):
==================================
JSP call to CMP:
Executing SQL: SELECT t0_s.ID FROM SESSION_ACTIVITIES t0_s
Add finder results: entity=SessionActivities results=[[.101.], [.102.], [.647.]] readahead=[JDBCReadAheadMetaData : strategy=on-load, pageSize=240, eagerLoadGroup=*]
RESET PERSISTENCE CONTEXT: id=[.101.]
load data: entity=SessionActivities pk=[.101.]
No preload data found: entity=SessionActivities pk=[.101.]
Default eager-load for entity: readahead=null
Executing SQL: SELECT MANDATORY_IND, COMPLETED_IND, ACT_COMMENTS, PLANNED_START_DATE, PLANNED_END_DATE, ACTUAL_START_DATE, ACTUAL_END_DATE, SESSACT_SEQ, SESSACT_TYPE, ROLE_ROLE, SESSACTTYP_ID, SESS_ID, AGEN_UID, TASK_1_ID, SESSUSR_USERID, SWIN_ID, EXTWIN_ID FROM SESSION_ACTIVITIES WHERE (ID=?)
Set parameter: index=1, jdbcType=INTEGER, value=101
RESET PERSISTENCE CONTEXT: id=[.102.]
load data: entity=SessionActivities pk=[.102.]
No preload data found: entity=SessionActivities pk=[.102.]
Default eager-load for entity: readahead=null
Executing SQL: SELECT MANDATORY_IND, COMPLETED_IND, ACT_COMMENTS, PLANNED_START_DATE, PLANNED_END_DATE, ACTUAL_START_DATE, ACTUAL_END_DATE, SESSACT_SEQ, SESSACT_TYPE, ROLE_ROLE, SESSACTTYP_ID, SESS_ID, AGEN_UID, TASK_1_ID, SESSUSR_USERID, SWIN_ID, EXTWIN_ID FROM SESSION_ACTIVITIES WHERE (ID=?)
Set parameter: index=1, jdbcType=INTEGER, value=102
Store command NOT executed. Entity is not dirty: pk=[.102.]
...
======================
Session bean call to CMP
Executing SQL: SELECT t0_s.ID FROM SESSION_ACTIVITIES t0_s
Add finder results: entity=SessionActivities results=[[.101.], [.102.], [.647.]] readahead=[JDBCReadAheadMetaData : strategy=on-load, pageSize=240, eagerLoadGroup=*]
RESET PERSISTENCE CONTEXT: id=[.101.]
load data: entity=SessionActivities pk=[.101.]
No preload data found: entity=SessionActivities pk=[.101.]
Eager-load for entity: readahead=[JDBCReadAheadMetaData : strategy=on-load, pageSize=240, eagerLoadGroup=*]
Executing SQL: SELECT ID, MANDATORY_IND, COMPLETED_IND, ACT_COMMENTS, PLANNED_START_DATE, PLANNED_END_DATE, ACTUAL_START_DATE, ACTUAL_END_DATE, SESSACT_SEQ, SESSACT_TYPE, ROLE_ROLE, SESSACTTYP_ID, SESS_ID, AGEN_UID, TASK_1_ID, SESSUSR_USERID, SWIN_ID, EXTWIN_ID FROM SESSION_ACTIVITIES WHERE (ID=?) OR (ID=?) OR (ID=?)
Set parameter: index=1, jdbcType=INTEGER, value=101
Set parameter: index=2, jdbcType=INTEGER, value=102
...(other Set parameter )
Add preload data: entity=SessionActivities pk=[.101.] field=mandatory_ind
Add preload data: entity=SessionActivities pk=[.101.] field=completed_ind
...(other Add preload )
RESET PERSISTENCE CONTEXT: id=[.102.]
load data: entity=SessionActivities pk=[.101.]
Preloading data: entity=SessionActivities pk=[.101.] cmpField=agen_uid
Preloading data: entity=SessionActivities pk=[.101.] cmpField=sess_id
... (other Preloading)
...
==================================
OC4J doean't have this issue before and will cache the database data even call a CMP from JSP but it seems JBoss will ONLY cache (using on-find or on-load strateg) database data when you call a CMP withing the same EJB container which mean you have to call a CMP from a session bean. I noticed here that JSP page can get Local EJB home and interface and EJB contaoner should smart enough to enable cache. Who can confirm that this is a not bug and I need some extra configuratrion? I hope I don't have to rewrite the old code to change all calls from JSP/ CMP to JSP/Session bean /CMP and this will be a nightmare to me(huge change). All I want is the running version and reasonable peformance. Is any way I can avoid to change the whole jsp file and enjoy the JBoss CMp cache benefit? Thanks in advance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JBoss CMP read ahead cache problem