WildFlyでSpringBoot2.xを動かそうとすると、以下のエラーが発生しアプリが起動しません。
(ServerService Thread Pool -- 78) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsServiceImpl': Unsatisfied dependency expressed through field 'loginService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginService': Unsatisfied dependency expressed through field 'usersDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersDaoImpl' defined in VFS resource ["/Users/xxx/dev/eclipse/server/wildfly-20/standalone/deployments/WebApp.war/WEB-INF/classes/com/example/dao/UsersDaoImpl.class"]: Initialization of bean 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.NoSuchMethodException: com.example.dao.UsersDaoImpl$$EnhancerBySpringCGLIB$$31fd9af9.<init>()
どうもDIできてないのが原因ぽいです。
Java9以降で発生します。
対処方法は、設定ファイルに追記するだけなので簡単です。
対処方法
jboss-deployment-structure.xmlに依存関係の設定を追加する。
<?xml version="1.0"?><jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><deployment><dependencies><module name="jdk.unsupported"/></dependencies></deployment></jboss-deployment-structure>