本文介绍了WELD-000227:检测到Bean标识符索引不一致-分布式容器可能不适用于相同的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在eclipse IDE中重新启动服务器并重新加载页面后,我将Tomcat v7与Weld v2.2.9.Final和myFaces v2.2.7结合使用,却收到此错误。我不知道为什么这个错误出现在我身上。它必须与http请求等连接。如果我打开关闭浏览器,它将开始工作。I am using tomcat v7 with Weld v2.2.9.Final and myFaces v2.2.7 after restart server in eclipse IDE and reload page I getting this error. I have no clue why this error appear to me. It has to be connected with http request or so. If I open close browser it start work.SEVERE: Exception sending request initialized lifecycle event to listener instance of class org.jboss.weld.environment.servlet.Listenerorg.jboss.weld.exceptions.IllegalStateException: WELD-000227: Bean identifier index inconsistency detected - the distributed container probably doesn't work with identical applications at org.jboss.weld.context.http.HttpSessionContextImpl.checkBeanIdentifierIndexConsistency(HttpSessionContextImpl.java:88) at org.jboss.weld.context.http.HttpSessionContextImpl.associate(HttpSessionContextImpl.java:42) at org.jboss.weld.context.http.HttpSessionContextImpl.associate(HttpSessionContextImpl.java:19) at org.jboss.weld.servlet.HttpContextLifecycle.requestInitialized(HttpContextLifecycle.java:217) at org.jboss.weld.servlet.WeldInitialListener.requestInitialized(WeldInitialListener.java:160) at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.requestInitialized(ForwardingServletListener.java:42) at org.apache.catalina.core.StandardContext.fireRequestInitEvent(StandardContext.java:6189) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) 推荐答案 当反序列化后,可序列化类的Weld / CDI代理实例发生不兼容更改时,将抛出此异常Tomcat重新启动后)。您很可能在开发过程中编辑了可序列化的会话或查看了范围内的托管Bean,而没有碰过 serialVersionUID 。或者,您已经添加/更新/删除了与CDI相关的库。如果您在Eclipse中使用Tomcat,请在Eclipse的服务器视图中右键单击Tomcat服务器条目,然后选择清洁Tomcat工作目录。 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.每次在可序列化类中进行不兼容的更改(例如添加新的实例字段)时,您都需要重新生成 serialVersionUID 值(如果您正在用IDE生成该值),或者将其值增加1(如果您使用默认的 1L )。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).因此,这不一定是Weld中的错误,但我认为它应该已经丢弃了不兼容的内容代理实例,创建了一个新实例,并打印了警告消息,而不是完全将此请求与该异常一起阻止。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.如果您实际上正忙于开发并每次都遇到此异常,考虑关闭服务器中的会话持久性。如何执行此操作取决于所使用的服务器。对于Tomcat 7,请参考 禁用会话持久性中的管理器组件。 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.特定消息分布式容器可能不适用于相同的应用程序 顺便说一句,在具有会话共享(例如云)的群集环境中重新运行Web应用程序,从而显然至少一个服务器具有Web应用程序的不同版本。这种情况会在生产中导致此异常。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. Java-什么时候必须更改serialVersionUID? org.jboss.weld.exceptions.IllegalStateException:每次更改代码后,WELD-000227 Java - When do I have to change the serialVersionUID?org.jboss.weld.exceptions.IllegalStateException: WELD-000227 after every change in code 这篇关于WELD-000227:检测到Bean标识符索引不一致-分布式容器可能不适用于相同的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-23 21:57