Flow: Vaadin 19: InvalidRouteLayoutConfigurationException: Only one target for an exception should be defined

Created on 24 Feb 2021  路  4Comments  路  Source: vaadin/flow

I have the same problem from https://github.com/vaadin/flow/issues/8948 in Vaadin 19.0.0.beta4.

When starting my simple app on Tomcat:
com.vaadin.flow.server.InvalidRouteLayoutConfigurationException: Only one target for an exception should be defined. Found 'pl.portal.webbase.app.ui.view.error.ErrorNotFoundView' and 'com.vaadin.flow.spring.router.SpringRouteNotFoundError' for exception 'com.vaadin.flow.router.NotFoundException'

I know it was fixed but is the fix added to Vaadin 19 code?

High Major bug spring workaround

All 4 comments

Hi @darmro,
Vaadin 19.0.x uses the vaadin-spring 16.0.x series, and as you mentioned, that regression was fixed in vaadin-spring 14.0.2. So if you are experiencing this issue with Vaadin 19.0.x, would you please add more details about the environment along with a minimal example that can reproduce the issue?

Hi, test is rather simple.
I entered Vaadin page, choose "Start building -> Vaadin 18", run app builder, changed Vaadin version to 19. Then imported app as a war into my eclipse, added only one class ErrorNotFoundView extends RouteNotFoundError, run app war on Tomcat 9 and ...

2021-03-01 16:51:38.331 ERROR 42516 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaadinApplicationContextInitializer' defined in class path resource [com/vaadin/flow/spring/VaadinApplicationConfiguration.class]: Initialization of bean failed; nested exception is com.vaadin.flow.server.InvalidRouteLayoutConfigurationException: Only one target for an exception should be defined. Found 'com.example.application.views.ErrorNotFoundView' and 'com.vaadin.flow.spring.router.SpringRouteNotFoundError' for exception 'com.vaadin.flow.router.NotFoundException'

Source code:
my-app.zip

The workaround for this is to extend SpringRouteNotFoundError instead of RouteNotFoundError
I would guess that the issue is that it's run as a war on tomcat which means that the route initialization is done by the ServletContextInitializer instead of the VaadinServletContextInitializer which doesn't know about the special spring class andthus fails on duplicate error handlers.

As there is a simple workaround and this is not on the critical path of trying things, I don't see this as a blocker. Related to https://github.com/vaadin/spring/pull/657

Was this page helpful?
0 / 5 - 0 ratings