> Markdown version of [Running a Vaadin Legacy CDI application with MPR and Flow](https://vaadin.com/docs/v23/tools/mpr/introduction/3-cdi). Section index: [llms.txt](https://vaadin.com/docs/v23/tools/llms.txt)

# Step 3 - Running a Vaadin Legacy CDI application with MPR and Flow

> **Note:** This step is needed in case your Vaadin 7 or 8 application uses CDI. If it isn’t the case, go back to the [framework selection](https://vaadin.com/docs/v23/tools/mpr/introduction/3-legacy-uis.md).

## <a id="updating-to-the-correct-cdi-version"></a>Updating to the correct CDI version

Remove any version from `com.vaadin:vaadin-cdi` as the proper Vaadin 14 compatible version for it’s managed by the `vaadin-bom`:

```xml
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-cdi</artifactId>
</dependency>
```

<!-- vale Vaadin.Abbr = NO -->

## <a id="handling-of-cdiui-annotation"></a>Handling of CDIUI annotation

<!-- vale Vaadin.Abbr = YES -->

Instead of `@CDIUI` use `@Route`.

```java
@CDIUI
@Theme("valo")
public class TodoUI extends UI {
    @Override
    protected void init(VaadinRequest vaadinRequest) {
        setContent(new HorizontalLayout());
    }
}
```

can for instance be replaced with

```java
@Route("")
public class TodoUI extends Div implements HasLegacyComponents {
    @PostConstruct
    private void buildLayouts() {
        setSizeFull();
        add(new HorizontalLayout());
    }
}
```

> **Note:** Annotations in the UI, such as `@Theme` and `@Title` and so on, are dealt with later on in the tutorial. Most of them have similar counterpart in either Flow or MPR.

## <a id="what-to-do-with-cdi-views"></a>What to do with CDI Views

Any `@CDIView` should be updated to a Flow Route by wrapping them as a `MprRouteAdapter<? extends View>` or re-writing it to be a Flow Component. See [Upgrading Views to Flow Routes](https://vaadin.com/docs/v23/tools/mpr/introduction/3-navigator.md#no-navigator)

## <a id="what-to-do-with-viewscopes"></a>What to do with ViewScopes

All ViewScopes should be changed to RouteScopes e.g.

- `@ViewScoped` to `@RouteScoped`

- `@NormalViewScoped` to `@NormalRouteScoped`

> **Note:** In some projects CDI has ignored the archive and not instantiated objects as expected. This is fixed by adding a `beans.xml` (empty is fine) file to `src/main/webapp/WEB_INF`.

## <a id="next-step"></a>Next step

- [Step 4 - Configuring UI parameters →](https://vaadin.com/docs/v23/tools/mpr/introduction/4-ui-parameters.md)

`5092446E-699F-40C4-A994-D5804AF8C7B3`
