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

Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration when starting spring boot on Wildfly 11,12,13. [SPR-16990] #21528

Closed
spring-issuemaster opened this Issue Jul 2, 2018 · 6 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

spring-issuemaster commented Jul 2, 2018

Giuseppe M Pereira opened SPR-16990 and commented

Bug report

//  "WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host.\"/dynamo-application-0.0.1-SNAPSHOT\"" => "java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
    Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
    Caused by: org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
    Caused by: org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
    Caused by: java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
    Caused by: java.lang.NoSuchMethodException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15.<init>()"},

Getting following exception when loading spring boot war on wildfly 13. However, it works if I start my project with maven from the console with mvn spring-boot:run as jar build.


Affects: 5.0.7

Referenced from: commits spring-projects/spring-boot@58e886f

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Jul 9, 2018

Brian Clozel commented

Hi Giuseppe M Pereira,

Could you create a small project that reproduces the issue? (a zipped project that you can attach here, or a github project that I can clone).

I've just successfully deployed a Spring Boot project on Wildfly 13. Here's what I did:

  1. Downloaded a skeleton project from start.spring.io with curl https://start.spring.io/starter.zip -o wildfly-sample.zip -d dependencies=web -d baseDir=wildfly-sample -d packaging=war
  2. Unzipped and created a HelloController that outputs "Hello Wildfly" for /
  3. Ran mvn package and deployed the resulting war in the deployments folder
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Jul 16, 2018

Pawel Puterla commented

Brian Clozel, Giuseppe M Pereira

I can confirm similar problem -> in a service without  noarg constructor, using JAVA 9 on wildfly 13 - fails.

The same Wildfly on JAVA 1.8 -> ok

 

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Jul 16, 2018

Brian Clozel commented

Juergen Hoeller and I have been looking at this - it seems WildFly (actually, JBoss Modules) is not exposing sun.reflect nor jdk.internal packages with JDK9+.

Launching a Spring Boot application with Spring MVC support fails because of the following:

Unable to instantiate proxy using Objenesis, falling back to regular proxy construction: org.springframework.objenesis.ObjenesisException: java.lang.ClassNotFoundException: sun.reflect.ReflectionFactory 

I've opened MODULES-373 to find out more about this - the JBoss Modules team answered that developers need to declare the jdk.unsupported module as a Dependency (see reference documentation).

 I managed to run a Spring Boot application by updating my project build:

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-war-plugin</artifactId>
	<configuration>
		<archive>
			<manifestEntries>
				<Dependencies>jdk.unsupported</Dependencies>
			</manifestEntries>
		</archive>
	</configuration>
</plugin>

In addition to that, the Spring Boot team is working on relaxing the reflection arrangement to avoid this advanced use case triggered by the Spring Boot infrastructure - but this does not guarantee that this case cannot be triggered by the application itself, so declaring that dependency is still advised.

I'm closing this issue, as this a configuration issue that WildFly users need to take into account.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 8, 2018

Stefano Paganucci commented

Hi Brian Clozel,

does this mean that Objenesis needs access to unsupported APIs to work correctly?

Do you think that accessing unsupported APIs is risky in some way?

Kind regards,

Stefano.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 8, 2018

Juergen Hoeller commented

From my perspective, the only real risk is that sun.reflect.ReflectionFactory (as used by Objenesis) might not be available in certain Java runtime environments. There is no analogous supported API, so if it is not present, we simply cannot support non-default constructors on CGLIB proxies. The core framework is structured that way already, with appropriate fallbacks in place; however, if certain application configurations happen to require target-class proxies on classes without a default constructor, we have no way to fall back.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 12, 2018

Stefano Paganucci commented

Thank you so much Juergen Hoeller for the explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment