title: org.jboss.weld.exceptions.IllegalStateException: WELD-000227 after every change in code
body: <p>I'm developing a webapp with NetBeans and Glassfish 4.1.1. and I'm using JSF and CDI to manage the backing beans for the facelets. Since shortly after changing anything in the code I always get an Internal Server Error with this IllegalStateException after 'successful' deploying and running the app via the browser:</p>
  
  <pre><code>org.jboss.weld.exceptions.IllegalStateException: WELD-000227: Bean 
  
  identifier index inconsistency detected - the distributed container 
  
  probably does not work with identical applications
  </code></pre>
  
  <p>I can get rid of it by doing a clean &amp; build and redeploying. But NetBeans is redeploying automatically after every save anyway. So I then still have to click on clean and build and then on redeploy myself ALWAYS after any little change, it makes me crazy!</p>
  
  <p>So is there any setting I can change on glassfish server to avoid this, or can I tell NetBeans to clean &amp; build before autodeploy?</p>
  
  <p>It was not always like this, recently I updated glassfish it may be that it appeared only after that, I don't remember exactly anymore.</p>
  
  <p>Thanks in advance! It costs me so much time..</p>
  
  <p><strong>SOLVED</strong></p>
  
  <p>I googled again for hours and found the solution: I set a new system property in glassfish</p>
  
  <p>org.jboss.weld.serialization.beanIdentifierIndexOptimization = <strong>false</strong></p>
  
  <p>to avoid the appearing inconsistencies as explained in the WELD reference here:</p>
  
  <p><a href="https://docs.jboss.org/weld/reference/latest/en-US/html/configure.html#_bean_identifier_index_optimization" rel="noreferrer">https://docs.jboss.org/weld/reference/latest/en-US/html/configure.html#_bean_identifier_index_optimization</a></p>