Cache entry not in use

夙愿已清 提交于 2019-12-23 10:52:44

问题


We have a web application using the following technologies: JSF 2.0, EJB 3.1, JPA 2.0, JBoss AS 7.1 Final

Sometimes we get the following exception out of nowhere:

09:46:29,664 ERROR [org.jboss.ejb3.invocation] (http-10.99.0.10-10.99.0.10-8080-14) JBAS014134: EJB Invocation failed on component VehicleServiceBean for method public abstract java.util.List com.hji.common.service.VehicleService.findVehiclesBySearchCriteriaAndImporterIds(com.hji.common.domain.repository.VehicleRepository$VehicleSearchCriteria,java.lang.String,java.util.List,boolean): java.lang.IllegalStateException: JBAS014531: Cache entry {[36, -111,
-104, -128, 61, -17, 73, 29, -101, 52, -7, -106, 46, -3, 44, -22]} is not in use
          at org.jboss.as.ejb3.cache.impl.backing.NonPassivatingBackingCacheImpl.release(NonPassivatingBackingCacheImpl.java:134) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
          at org.jboss.as.ejb3.cache.impl.backing.NonPassivatingBackingCacheImpl.release(NonPassivatingBackingCacheImpl.java:56) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
          at org.jboss.as.ejb3.cache.spi.impl.AbstractCache.release(AbstractCache.java:76) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
          at org.jboss.as.ejb3.cache.spi.impl.AbstractCache.release(AbstractCache.java:39) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
          at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.releaseInstance(StatefulSessionSynchronizationInterceptor.java:197) ...
**Caused by: java.lang.IllegalStateException: JBAS014531: Cache entry {[36, -111, -104, -128, 61, -17, 73, 29, -101, 52, -7, -106, 46, -3, 44, -22]} is not in use**
          at org.jboss.as.ejb3.cache.impl.backing.NonPassivatingBackingCacheImpl.release(NonPassivatingBackingCacheImpl.java:134) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
          at org.jboss.as.ejb3.cache.impl.backing.NonPassivatingBackingCacheImpl.release(NonPassivatingBackingCacheImpl.java:56) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
          at org.jboss.as.ejb3.cache.spi.impl.AbstractCache.release(AbstractCache.java:76) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final]
          at org.jboss.as.ejb3.cache.spi.impl.AbstractCache.release(AbstractCache.java:39) [jboss-as-ejb3-7.1.0.Final.jar:7.1.0.Final] ...

I have been searching the web for some time now but couldn't find any solution. Does anybody know this kind of error?


回答1:


I've been looking around as I've got a similar problem. I've only found two possible explanations: either your stateful bean has timed-out (defaults to 5000 seconds on AS7.1), or you're passing a reference to the SFSB from one thread to another - which (it is suggested on the jboss forum isn't allowed. If the former, either increase the timeout or catch the exception. If the latter, have jboss inject the stateful bean wherever it's needed rather than passing it around.

The problem I'm having is that it's not either of those for me. I only have one stateful bean in the test setup, which is injected separately into the various stateless beans - and I can generate the exception within a few seconds of starting the test run. I'm still trying to track-down where I'm going wrong - if you've found an alternative solution to your problem could you post it please?

Rgds, James

I've narrowed-it down to concurrent access - I can make lots of sequential requests, but only a few "concurrent" ones before this occurs. (I put concurrent in quotes because I am synchroising on a lock held by the @SessionScoped ejb so the only possible concurrent call is to the getLock() method I've created on it).

I'm totally confused over whether Weld allows or prevents concurrent access to @SessionScoped @Stateful EJBs. I read that that Seam serializes the access (and Weld is born out of Seam) but don't know whether that's actually the case. If it is, then something else is causing my bean to die. It's easily reproducable through concurrent access from separate @Stateless beans though.




回答2:


Ok I can provide what I think is a more accurate answer now. I wasn't able to give-up on allowing the concurrent access to the stateful ejb because my app uses ajax, so concurrent calls are inevitable. I can't remember where I found the reference, but I understand that concurrent access to a stateful bean should be serialised by the container under EJB3.1 - so I should have been fine.

I ended up trying to trace my way through the JBoss AS7 source, and think I found the problem (currently under discussion here on the jboss AS7 forum). It appears to be a bug - jboss only synchronises access if your call is within an active transaction (BMT or CMT). If it is not, then the synchronisation fails - and it's not possible (as far as I can figure) to synchronize or lock yourself, because you only ever get access to a proxies to the bean, not the underlying instance itself. Synchronising on a proxy is useless for anything other than the thread(s) that the proxy exists in.

The workaround for now is to ensure all calls that could be concurrent are wrapped in a transaction. I was pleasantly surprised to find that the performance overhead of opening and closing a transaction so frequently on an EXTENDED PersistenceContext was very small - but I've not really pushed it very hard :)

I suspect the issue affects all AS7 versions, but have only confirmed it on AS7.1.



来源:https://stackoverflow.com/questions/9426193/cache-entry-not-in-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!