WELD-000227: Bean identifier index inconsistency detected - the distributed container probably doesn't work with identical applications

…衆ロ難τιáo~ 提交于 2019-11-29 04:35:06
BalusC

org.jboss.weld.exceptions.IllegalStateException: WELD-000227: Bean identifier index inconsistency detected - the distributed container probably doesn't work with identical applications

This exception will be thrown when a Weld/CDI proxy instance of a serializable class has incompatibly changed after deserialization (e.g. after Tomcat restart). Most likely you have during developing edited a serializable session or view scoped managed bean while not having touched the serialVersionUID. Or, you have added/updated/removed a CDI-associated library. In case you're using Tomcat in Eclipse, rightclick the Tomcat server entry in Eclipse's Servers view and choose Clean Tomcat Work Directory. This will wipe out serialized sessions and thus also solve this exception.

Everytime when you make incompatible changes in a serializable class, such as adding new instance fields, then you need to re-generate the serialVersionUID value (in case you're IDE-generating the value), or to increment its value with 1 (in case you're using a default 1L).

This is thus not necessarily a bug in Weld, but it should in my opinion just have discarded the incompatible proxy instance, created a new one and printed a warning message instead of blocking the request altogether with this exception.

If you're actually busy developing and facing this exception everytime, consider turning off session persistence in the server. How to do this depends on the server used. In your case of Tomcat 7, refer section "Disable Session Persistence" in the documentation of The Manager Component.

The specific message "the distributed container probably doesn't work with identical applications" is by the way referring to the possible case when you're running the web application in a clustered environment with session sharing (e.g. cloud) whereby apparently at least one server has a different version of the web application. Such situation will in production cause this exception.

See also:

That's a bug in Weld. https://issues.jboss.org/browse/WELD-1887

You should be able to work around by disabling session passivation on shutdown in Tomcat.

It may be over two years since the last answer was posted, but this may also happen if you forget to implement Serializable in an Entity class.

(Java 8, Glassfish 4)

@Entity
@Table(name="questions")
public class Question { 
  ......
}

Error org.jboss.weld.exceptions.IllegalStateException: WELD-000227: Bean identifier index inconsistency detected - the distributed container probably doesn't work with identical applications

@Entity
@Table(name="questions")
public class Question implements Serializable { 
  ......
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!