且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

EJB weblogic.ejb20.cache.CacheFullException

更新时间:2023-09-13 23:44:04

10000对于 max-beans-in-cache 并且从日志中,似乎应用程序试图调用最多85785个EJB实例。



我建议您的代码中重新编写一个。



您的代码正在执行

  com.nextjet.enterprise.locationcode.locationcode.LocationCode_v2epgs_ELOImpl 
.getLocationCodeData()

这主要是一个读操作?或者您是否同时进行写入和读取?



如果主要执行读取操作,则可以通过两种方式重构此方法来减少EJB开销



1)阅读Oracle关于调整EJB设置和并发性数据库选项的建议,特别是Read-Mostly模式



http://docs.oracle.com/cd/E13222_01/ wls / docs81 / ejb / entity.html#ChoosingaConcurrencyStrategy



2)如果你主要是读取 - 那么根本不使用Entity EJB。使用正在使用直接JDBC调用的FastLaneReader模式来获取SELECT的数据,您可以使用目前的EJB进行写入操作。这样,可以减少max-beans-in-cache



在Sun Design Patterns网站上给出了一个非常详细的例子。



http://java.sun.com/blueprints/patterns/FastLaneReader.html


I am working on one application using EJB1.2. previously running fine but from past few days I am getting following exception

Exception in ejbLoad:: weblogic.ejb20.cache.CacheFullException: size=85783, target=5000, incr=1 at weblogic.ejb20.cache.EntityCache$SizeTracker.shrinkNext(JI)Lweblogic.ejb20.cache.EntityCache$MRUElement;(EntityCache.java:438) at weblogic.ejb20.cache.EntityCache.put
(Ljavax.transaction.Transaction;Lweblogic.ejb20.cache.CacheKey;Ljavax.ejb.EntityBean;Lweblogic.ejb20.interfaces.CachingManager;)V(EntityCache.java:141) at weblogic.ejb20.manager.DBManager.getReadyBean(Ljavax.transaction.Transaction;Ljava.lang.Object;)Ljavax.ejb.EntityBean;(DBManager.java:332) at 
    weblogic.ejb20.manager.DBManager.preInvoke(Lweblogic.ejb20.internal.InvocationWrapper;)Ljavax.ejb.EnterpriseBean;(DBManager.java:249) at 
    weblogic.ejb20.internal.BaseEJBLocalObject.preInvoke(Lweblogic.ejb20.internal.InvocationWrapper;)Lweblogic.ejb20.internal.InvocationWrapper;(BaseEJBLocalObject.java:228) at weblogic.ejb20.internal.EntityEJBLocalObject.preInvoke(Lweblogic.ejb20.internal.MethodDescriptor;Lweblogic.security.service.ContextHandler;)Lweblogic.ejb20.internal.InvocationWrapper;(EntityEJBLocalObject.java:72) at com.nextjet.enterprise.locationcode.locationcode.LocationCode_v2epgs_ELOImpl.getLocationCodeData()Lcom.nextjet.enterprise.locationcode.LocationCodeData;(LocationCode_v2epgs_ELOImpl.java:28) at com.nextjet.enterprise.locationcode.locationcodemanager.LocationCodeManagerBean.loadShippingAddress(Ljava.lang.Long;Ljava.lang.String;)Lcom.nextjet.enterprise.locationcode.LocationCodeView;(LocationCodeManagerBean.java:538) at com.nextjet.enterprise.locationcode.locationcodemanager.LocationCodeManagerBean.doSearchShippingAddresses(Ljava.lang.String;)Lcom.nextjet.enterprise.locationcode.LocationCodeSearchResult;(LocationCodeManagerBean.java:514) at com.nextjet.enterprise.locationcode.locationcodemanager.LocationCodeManagerBean.lookupAccountShipping.....

For now I am changing value of <max-beans-in-cache> in weblogic-ejb-jar.xml

I am changing the above value to <max-beans-in-cache>100000</max-beans-in-cache>

is it the only solution for this kind of exception or could there be a data related issue from database?

10000 is quite a high value for max-beans-in-cache and from the log it seems the application tried to make a call for up to 85785 instances of the EJB.

I would suggest some refactoring in your code.

Your code is doing

com.nextjet.enterprise.locationcode.locationcode.LocationCode_v2epgs_ELOImpl
.getLocationCodeData()

Is this is mainly a read operation ? Or are you doing simultaneous writes and reads?

You could refactor this in 2 ways to reduce the EJB overheads if it is mainly doing read operations.

1) Read Oracle's recommendation on tuning the EJB settings and database options for concurrency, especially the Read-Mostly pattern

http://docs.oracle.com/cd/E13222_01/wls/docs81/ejb/entity.html#ChoosingaConcurrencyStrategy

2) If you are mainly doing reads - then dont use Entity EJBs at all. Use the FastLaneReader pattern which is using a direct JDBC call to fetch the data for SELECT, and you can do writes using the EJBs as at present. In this way, the max-beans-in-cache can be reduced

A very detailed example is given on the Sun Design Patterns site

http://java.sun.com/blueprints/patterns/FastLaneReader.html