10.2. Use CDI


10.2.1. First Steps

10.2.1.1. Enable CDI

Summary

Contexts and Dependency Injection (CDI) is one of the core technologies in JBoss EAP 6, and is enabled by default. If for some reason it is disabled and you need to enable it, follow this procedure.

Procedure 10.1. Enable CDI in JBoss EAP 6

  1. Check to see if the CDI subsystem details are commented out of the configuration file.

    A subsystem can be disabled by commenting out the relevant section of the domain.xml or standalone.xml configuration files, or by removing the relevant section altogether.
    To find the CDI subsystem in EAP_HOME/domain/configuration/domain.xml or EAP_HOME/standalone/configuration/standalone.xml, search them for the following string. If it exists, it is located inside the <extensions> section.
    <extension module="org.jboss.as.weld"/>
    The following line must also be present in the profile you are using. Profiles are in individual <profile> elements within the <profiles> section.
    <subsystem xmlns="urn:jboss:domain:weld:1.0"/>
  2. Before editing any files, stop JBoss EAP 6.

    JBoss EAP 6 modifies the configuration files during the time it is running, so you must stop the server before you edit the configuration files directly.
  3. Edit the configuration file to restore the CDI subsystem.

    If the CDI subsystem was commented out, remove the comments.
    If it was removed entirely, restore it by adding this line to the file in a new line directly above the </extensions> tag:
    <extension module="org.jboss.as.weld"/>
  4. You also need to add the following line to the relevant profile in the <profiles> section.
    <subsystem xmlns="urn:jboss:domain:weld:1.0"/>
  5. Restart JBoss EAP 6.

    Start JBoss EAP 6 with your updated configuration.
Result

JBoss EAP 6 starts with the CDI subsystem enabled.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.