# CDI is not available

**URL:** <https://forum.payara.fish/t/cdi-is-not-available/626>\
**Category:** Technical Discussion\
**Created:** [May 24, 2023, 3:31pm UTC](https://forum.payara.fish/t/cdi-is-not-available/626 "2023-05-24T15:31:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![brad](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.payara.fish/brad/32/207_2.png) [@brad](https://forum.payara.fish/u/brad)\
**Post date:** [May 24, 2023, 3:31pm UTC](https://forum.payara.fish/t/cdi-is-not-available/626/1 "2023-05-24T15:31:47Z")

</div>

I have a bunch of spring framework6 java/kotlin web applications that I maintain. They are currently on a payara5 server getting ready to move to payara6. For this move we are moving to JDK17/EE10. I’ve ran into an error when deploying any of the spring apps into payara6.

> java.lang.IllegalStateException: CDI is not available

We are only using springs dependency injection. CDI has never been configured, but Payara6 seems to want to require this. If I add a blank beans.xml file to the project, it deploys without any issues. After a bit of googling, [I found a post on StackOverFlow](https://stackoverflow.com/questions/74643532/cdi-not-available-exception-deploying-a-springframework-application-to-payara) where someone indicated they talked to a Spring developer where he indicated this was a Payara issue. So I guess I’m just hoping this is on the radar, or if there’s already something I can do to prevent from having to add a blank file to all the projects?

---

<div class="post-metadata">

**Author:** ![brad](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.payara.fish/brad/32/207_2.png) [@brad](https://forum.payara.fish/u/brad)\
**Post date:** [May 24, 2023, 4:09pm UTC](https://forum.payara.fish/t/cdi-is-not-available/626/2 "2023-05-24T16:09:44Z")

</div>

I found this post. [Record requires ASM8 - #11 by dtewari](https://forum.payara.fish/t/record-requires-asm8/501/11)  
Looks like it’s “fixed”. But maybe not quite working the way it should?

---

<div class="post-metadata">

**Author:** ![Cistox](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.payara.fish/cistox/32/202_2.png) [@Cistox](https://forum.payara.fish/u/Cistox)\
**Post date:** [June 1, 2023, 1:53pm UTC](https://forum.payara.fish/t/cdi-is-not-available/626/3 "2023-06-01T13:53:42Z")

</div>

Hi Brad,  
you should remove the “Implicid CDI” flag available when you deploy.

---

<div class="post-metadata">

**Author:** ![brad](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.payara.fish/brad/32/207_2.png) [@brad](https://forum.payara.fish/u/brad)\
**Post date:** [June 2, 2023, 7:16pm UTC](https://forum.payara.fish/t/cdi-is-not-available/626/4 "2023-06-02T19:16:42Z")

</div>

I’m sorry, where is this option?

_edit_  
Nevermind, I see this is an option to change after deploying the app in the application settings. It looks like you can add the option to a glassfish-application.xml file. Is there a way to disable this server wide?

---

<div class="post-metadata">

**Author:** ![Cistox](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.payara.fish/cistox/32/202_2.png) [@Cistox](https://forum.payara.fish/u/Cistox)\
**Post date:** [June 4, 2023, 9:41am UTC](https://forum.payara.fish/t/cdi-is-not-available/626/5 "2023-06-04T09:41:18Z")

</div>

No you need to set this option during the deployment. Either from command-line or the admin UI.

---

<div class="post-metadata">

**Author:** ![brad](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.payara.fish/brad/32/207_2.png) [@brad](https://forum.payara.fish/u/brad)\
**Post date:** [June 6, 2023, 3:51am UTC](https://forum.payara.fish/t/cdi-is-not-available/626/6 "2023-06-06T03:51:56Z")

</div>

Looks like we’ll be adding this on our deploy scripts. Thank you Cistox!

---

<div class="post-metadata">

**Author:** ![brad](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.payara.fish/brad/32/207_2.png) [@brad](https://forum.payara.fish/u/brad)\
**Post date:** [June 12, 2023, 5:24pm UTC](https://forum.payara.fish/t/cdi-is-not-available/626/7 "2023-06-12T17:24:33Z")

</div>

So we have tried adding the beans.xml with the option of bean-discovery-mode=“none”. This does not work.

```auto
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
       version="4.0" bean-discovery-mode="none">

</beans>

```

I have also added the glassfish-application.xml with the xml option to disable implicit cdi. Although, this looks like it may be for EAR applications only? We are running WAR files for our apps.

```auto
<glassfish-application>
  <enable-implicit-cdi>false</enable-implicit-cdi>
</glassfish-application>

```

The deploy command with the option is not working either.

```auto
./asadmin deploy --property enableImplicitCdi=false

```

I am not sure what the exact command should be. I’ve also tried the following properties.  
enable-implicit-cdi=false  
implicitCdiEnabled=false

The only thing working for me at the moment is to add a blank beans.xml file.

---

<div class="post-metadata">

**Author:** ![gbarnard](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@gbarnard](https://forum.payara.fish/u/gbarnard)\
**Post date:** [June 15, 2023, 3:23pm UTC](https://forum.payara.fish/t/cdi-is-not-available/626/8 "2023-06-15T15:23:51Z")

</div>

Hi, Brad. That was me who got an email from Juergen. I just tried Payara 6.2023 and am still getting “CDI is not available” deploying my Spring Web MVC application. Also, sent a contact us message.

Looks like I’ll be trying Tomcat next.

I’m seeing posts from Google about GF should never be used in production. SInce Payara is built on GF, I wonder about Payara’s ability to stay in the WebServer game, especially with problems like this.

---

<div class="post-metadata">

**Author:** ![StageIsSet](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@StageIsSet](https://forum.payara.fish/u/StageIsSet)\
**Post date:** [July 25, 2023, 11:15am UTC](https://forum.payara.fish/t/cdi-is-not-available/626/9 "2023-07-25T11:15:10Z")

</div>

Anyone found a fix for this error? I’m waiting for this to be able to upgrade Spring

---

<div class="post-metadata">

**Author:** ![brad](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.payara.fish/brad/32/207_2.png) [@brad](https://forum.payara.fish/u/brad)\
**Post date:** [July 30, 2023, 2:48am UTC](https://forum.payara.fish/t/cdi-is-not-available/626/10 "2023-07-30T02:48:48Z")

</div>

Hi StageIsSet,  
The current work around that I’m aware of is to add a beans.xml file in the same directory as your web.xml/glassfish-web.xml. This file can be blank too. That should solve the CDI error on deployment.
