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

Add additional guard for web application detection in AOT #14147

Closed
dsyer opened this issue Aug 20, 2018 · 6 comments
Closed

Add additional guard for web application detection in AOT #14147

dsyer opened this issue Aug 20, 2018 · 6 comments
Assignees
Labels
for: external-project For an external project and not something we can fix theme: aot An issue related to Ahead-of-time processing

Comments

@dsyer
Copy link
Member

dsyer commented Aug 20, 2018

This code in SpringApplication blows up at runtime in a native image when WebApplicationContext is not on the classpath:

	private boolean isWebApplicationContext(Class<?> applicationContextClass) {
		try {
			return WebApplicationContext.class.isAssignableFrom(applicationContextClass);
		}
		catch (NoClassDefFoundError ex) {
			return false;
		}
	}

Probably we could add an additional check that WebApplicationContext is present before we check for isAssignableFrom() it?

Adding this check worked for me:

	    if (!ClassUtils.isPresent("org.springframework.web.context.WebApplicationContext", null)) {
	        return false;
	    }

but it didn't work to simply catch Throwable.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 20, 2018
@snicoll
Copy link
Member

snicoll commented Aug 20, 2018

That's a pattern we use in other places so if that becomes problematic, I'd prefer to understand where this is coming from.

@dsyer
Copy link
Member Author

dsyer commented Aug 20, 2018

I haven't seen that pattern anywhere else in Spring or Spring Boot, which isn't to say that it's something we necessarily have to fix here. I opened oracle/graal#622, so we can see what they say over there before we do anything, I guess.

@snicoll
Copy link
Member

snicoll commented Aug 20, 2018

There is OnBeanCondition that does that or am I missing something?

@snicoll snicoll added the status: blocked An issue that's blocked on an external project change label Aug 20, 2018
@dsyer
Copy link
Member Author

dsyer commented Aug 20, 2018

OnBeanCondition does not call isAssignableFrom(). Am I missing something?

@snicoll
Copy link
Member

snicoll commented Aug 20, 2018

No but I surely was. Sorry.

@snicoll snicoll added the for: team-attention An issue we'd like other members of the team to review label Aug 27, 2018
@philwebb philwebb self-assigned this Aug 29, 2018
@philwebb
Copy link
Member

See #14157 (comment). Closing for now and awaiting the result of oracle/graal#622

@philwebb philwebb added for: external-project For an external project and not something we can fix and removed for: team-attention An issue we'd like other members of the team to review status: blocked An issue that's blocked on an external project change status: waiting-for-triage An issue we've not yet triaged labels Aug 29, 2018
@mbhave mbhave added the theme: aot An issue related to Ahead-of-time processing label Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix theme: aot An issue related to Ahead-of-time processing
Projects
None yet
Development

No branches or pull requests

5 participants