Upgrading 23-24 how to change RouteUtil.getRoutePath

In our VaadinWebSecurity implementation we have the following code in setLoginView()

	Optional<Route> route = AnnotationReader.getAnnotationFor(flowLoginView,
			Route.class);

	if (route.isEmpty()) {
	    throw new IllegalArgumentException(
			    "Unable find a @Route annotation on the login view "
					    + flowLoginView.getName());
	}

	String loginPath = RouteUtil.getRoutePath(flowLoginView, route.get());
	if (!loginPath.startsWith("/")) {
	    loginPath = "/" + loginPath;
	}

The call to RouteUtil.getRoutePath() changed to require a context that I don’t have. What is the equivalent in Vaadin 24?

I tried using RouteConfiguration.forApplicationScope().getUrl(flowLoginView), but got

Caused by: java.lang.NullPointerException: Cannot invoke "com.vaadin.flow.server.VaadinService.getContext()" because the return value of "com.vaadin.flow.server.VaadinService.getCurrent()" is null

The code that you gave looks similar to what VaadinWebSecurity::setLoginView implements internally in latest Vaadin 24 branch.
See how the context is created and how the RouteUtil is used here flow/vaadin-spring/src/main/java/com/vaadin/flow/spring/security/VaadinWebSecurity.java at 9f4ecebd9faa9e298d7700dec185730069febbbe · vaadin/flow · GitHub.

But the more important question - why do you need to repeat the code that Vaadin already runs in setLoginView?

If you otherwise give us a reason why you want to fetch the url path from the Login view route object, I’d hopefully get the problem you are trying to solve and could suggest you another solution.