> Markdown version of [Creating V7 and V14+ CDI applications side-by-side](https://vaadin.com/docs/v23/tools/mpr/configuration/mpr-cdi-tutorial). Section index: [llms.txt](https://vaadin.com/docs/v23/tools/llms.txt)

# Creating V7 and V14+ CDI applications side-by-side

If you have an application developed using Vaadin 7 and CDI, you have the option to keep your legacy code untouched and continue developing new pages with V14+.

You’re also able to use CDI beans, such as `SessionScoped` beans, in both V14+ and Vaadin 7 parts of your application. The following instructions are step-by-step guide on how to adopt this approach with Vaadin 14. The same instructions can be followed to do the same with Vaadin 15+. You only need to use the Vaadin version of your choice.

1. Add Vaadin 14 to your Maven dependencies.

   ```xml
   <dependencyManagement>
       <dependencies>
           <dependency>
               <groupId>com.vaadin</groupId>
               <artifactId>vaadin-bom</artifactId>
               <type>pom</type>
               <scope>import</scope>
               <version>23.6.19</version>
           </dependency>
       </dependencies>
   </dependencyManagement>
   <dependencies>
       <dependency>
           <groupId>com.vaadin</groupId>
           <artifactId>vaadin-core</artifactId>
       </dependency>
   </dependencies>
   ```

2. Exclude conflicted dependencies between Vaadin 7 and Vaadin 14 which are `jsoup` and `atmosphere-runtime` from Vaadin 7 in your `pom.xml`, like shown in the following example:

   ```xml
   <dependency>
       <groupId>com.vaadin</groupId>
       <artifactId>vaadin-server</artifactId>
       <version>${framework.7.version}</version>
       <exclusions>
           <exclusion>
               <groupId>com.vaadin.external.atmosphere</groupId>
               <artifactId>atmosphere-runtime</artifactId>
           </exclusion>
           <exclusion>
               <groupId>org.jsoup</groupId>
               <artifactId>jsoup</artifactId>
           </exclusion>
       </exclusions>
   </dependency>
   ```

3. Remove dependency of `vaadin-cdi 1.*` and add a dependency to `mpr-cdi-v7 1.0.0`.

   ```xml
   <dependency>
       <groupId>com.vaadin</groupId>
       <artifactId>mpr-cdi-v7</artifactId>
       <version>1.0.0</version>
   </dependency>
   ```

4. Add the `vaadin-cdi` dependency. The version isn’t needed as it’s defined by the `vaadin-bom`.

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

5. Since the root path of your application is managed by Vaadin 7, you need to define the Vaadin 14 servlet manually, and set its URL pattern to a value that doesn’t collide with any of the V7 servlets.

   ```java
   @WebServlet(name = "Flow Servlet", urlPatterns = {
           MyFlowServlet.FLOW_SERVLET_ROOT + "/*" })
   public class MyFlowServlet extends CdiVaadinServlet {
       public static final String FLOW_SERVLET_ROOT = "flow";
   }
   ```

6. Now, you can have both Vaadin 7 and Vaadin 14 parts of your application in one project. To navigate from Vaadin 7 part to Vaadin 14 part you can use the following line of code.

   ```java
   getUI().getPage().setLocation(MyFlowServlet.FLOW_SERVLET_ROOT);
   ```

   And, to navigate from Vaadin 14 part to a Vaadin 7 view you can for example use an `Anchor` like the below code.

   ```java
   Anchor anchor = new Anchor("/#!home", "Home");
   add(anchor);
   ```

7. To have shared data between Vaadin 14 and Vaadin 7 parts, you can use `SessionScoped` beans that are shared for both V7 and V14 applications.

   ```java
   @SessionScoped
   public class SecurityContext implements Serializable {
       private User currentUser = new User();

       public boolean signIn(String username, String password) {
           if (username == null || username.isEmpty())
               return false;

           currentUser.setUsername(username);

           return true;
       }
   }
   ```

`8F436CEA-E832-44CC-9641-4E6D84D91FED`
