title: "JNDI already in use" during redeployment on WebLogic 12c
body: <p>We are facing a strange behavior from weblogic 12c during re-deployments.</p>
  
  <p>During a first deployment of a specific war, the process runs smoothly but during the second deployment, (if the war is already deployed on WL) we got the following error</p>
  
  <p>We are a team of 10 developers. This error only happens in the PCs of 3/10 persons, and not every time. It is absolutely non-deterministic behavior. The common pattern is that after a server restart you can make 1-2 redeployments of the appliation and then, the problem appears again and stays forever! We tried cleaning the cache, but no luck. The only thing we can do is to restart the server and redeploy the app. </p>
  
  <p>Java: 1.8.0_172</p>
  
  <p>ejb-jar.xml: NOT using.</p>
  
  <p>LoanTypeService is a Stateless EJB. Even if I delete it, another EJB will fail. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;Warning&gt; &lt;Deployer&gt; &lt;BEA-149078&gt; &lt;Stack trace for message 149004
  weblogic.application.ModuleException: Error deploying the EJB LoanTypeService(Application: moduleName, EJBComponent: moduleName.war), the JNDI name java:global/moduleName/LoanTypeService is already in use. You must set a different JNDI name in the weblogic-ejb-jar.xml deployment descriptor or corresponding annotation for this EJB before it can be deployed.
          at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
          at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
          at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:192)
          at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:187)
          at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:83)
          Truncated. see log file for complete stacktrace
  Caused By: Error deploying the EJB LoanTypeService(Application: moduleName, EJBComponent: moduleName.war), the JNDI name java:global/moduleName/LoanTypeService is already in use. You must set a different JNDI name in the weblogic-ejb-jar.xml deployment descriptor or corresponding annotation for this EJB before it can be deployed.
          at weblogic.ejb.container.deployer.SessionBeanInfoImpl.prepare(SessionBeanInfoImpl.java:502)
          at weblogic.ejb.container.deployer.EJBDeployer.setupBeanInfos(EJBDeployer.java:580)
          at weblogic.ejb.container.deployer.EJBDeployer.prepare(EJBDeployer.java:733)
          at weblogic.ejb.container.deployer.EjbModuleExtension.postPrepare(EjbModuleExtension.java:101)
          at weblogic.application.internal.ExtensibleModuleWrapper$PrepareStateChange.next(ExtensibleModuleWrapper.java:297)
          Truncated. see log file for complete stacktrace</code></pre>
  </div>
  </div>
  </p>
  
  <p>I know that there is already a <a href="https://stackoverflow.com/questions/31546768/jndi-name-is-already-in-use-in-weblogic-12c-with-ejb3?rq=1">similar question</a>, but stopping WL and cleaning cache is obviously not an option.</p>