Skip to Content
avatar image
Former Member

Facing problem in Cache implementation for local Object in EJB3 on SAP Server.


I am trying to implement Cache mechanism for lookup table records, to avoid hit to database for non-changing data.

I have followed three approaches to achieve this mechanism but facing following issues.

1) Used @Singleton annotation to create singleton ejb bean having HashMap to store DB records.

@EJB annotation is giving error at run time on SAP server. EJB container is falling to Inject singleton bean at run time.

Giving following error. Failed - Could not get a value to be injected from factory.

2) Used generic way to access Cache HashMap by declaring it Static and declaring public synchronized method to access it.

Here Java virtual machine used by SAP server is creating multiple instances of static HashMap object for random user. It is not maintaining single object instance for life of application. It is not following Singleton Design pattern of EJB.

3) Used the SAP EJB Container - application/session context to store the cache HashMap in it.

This approach is giving following run time error. It is failing to get context data.

NoSuchMethodError for SessionContext.getContextdata().

I have tried all above approach to implement Cache.

Please suggest me how i can implement Cache mechanism in SAP Server environment to to store data in local HashMap object for avoiding redundant hit to database ?



capture.jpg (64.1 kB)
ejb-1.jpg (24.8 kB)
ejb2.jpg (80.6 kB)
ejb3.jpg (15.0 kB)
ejb4.jpg (66.8 kB)
ejb5.jpg (29.0 kB)
ejb6.jpg (38.9 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers