Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct DispatcherServlet initialization sample webmvc.adoc #25965

Closed
chrshnv opened this issue Oct 23, 2020 · 4 comments
Closed

Correct DispatcherServlet initialization sample webmvc.adoc #25965

chrshnv opened this issue Oct 23, 2020 · 4 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: documentation A documentation task type: task A general task
Milestone

Comments

@chrshnv
Copy link

chrshnv commented Oct 23, 2020

Affects: 5.2.9


The example uses ac.refresh(); but throws an exception. Everything works perfectly without it.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 23, 2020
@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label Oct 23, 2020
@bclozel
Copy link
Member

bclozel commented Oct 23, 2020

Could you give us a bit more information?
I don't know where that line comes from (could you provide a URL?) nor what the exception is. If it's a simple typo, a pull request fixing that problem would be very welcome.

@sbrannen
Copy link
Member

I think the issue is that the WebApplicationContext created in the MyWebApplicationInitializer example in webmvc.adoc should not actually invoke refresh() on the application context, since refresh occurs later -- for example, in org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(...).

The example in the class-level Javadoc for WebApplicationInitializer also does not invoke refresh() on the created application context.

@chereshnyabtw, is that what you are referring to?

@sbrannen sbrannen added in: web Issues in web modules (web, webmvc, webflux, websocket) type: documentation A documentation task labels Oct 23, 2020
@chrshnv
Copy link
Author

chrshnv commented Oct 23, 2020

I mean, spring-mvc can't get servlet context with ac.refresh().

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 23, 2020
@rstoyanchev rstoyanchev self-assigned this Oct 26, 2020
@rstoyanchev rstoyanchev added type: task A general task and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 26, 2020
@rstoyanchev rstoyanchev added this to the 5.2.10 milestone Oct 26, 2020
@rstoyanchev
Copy link
Contributor

Indeed, as per the Javadoc, refresh should not be called unless the application has done all the initialization that the constructor would do, or otherwise if it is refreshed it is assumed it has been done.

@rstoyanchev rstoyanchev changed the title Spring-webmvc documentation error. Correct DispatcherServlet initialization sample webmvc.adoc Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: documentation A documentation task type: task A general task
Projects
None yet
Development

No branches or pull requests

5 participants