가끔, 내 생각과는 다르게 IDE에서 멋대로 코드를 포맷팅하는 경우가 있다.

그런 때에 사용할 수 있는 기능이 있다.

인텔레제이 2017.x 기준 [Preference > Editor > Code Style] 에서 'Formatter Control'을 체크하면 된다.

이렇게 작성한 코드도

@Test
public void formatterOff() throws Exception {
List<String> arrays = new ArrayList<>(); arrays.add("Test"); arrays.add("Formatter");
}

포맷팅을 하면

@Test
public void formatterOff() throws Exception {
List<String> arrays = new ArrayList<>();
arrays.add("Test");
arrays.add("Formatter");
}

처럼 되지만 //@formatter:off~//@formatter:on 을 이용하면

@Test
public void formatterOff() throws Exception {
//@formatter:off
List<String> arrays1 = new ArrayList<>(); arrays1.add("Test"); arrays1.add("Formatter");
//@formatter:on

List<String> arrays2 = new ArrayList<>(); arrays2.add("Test"); arrays2.add("Formatter");
}

이런 코드가

@Test
public void formatterOff() throws Exception {
//@formatter:off
List<String> arrays1 = new ArrayList<>(); arrays1.add("Test"); arrays1.add("Formatter");
//@formatter:on

List<String> arrays2 = new ArrayList<>();
arrays2.add("Test");
arrays2.add("Formatter");
}

이렇게 변경된다.


메서드 체이닝을 이용해서 작성하는 경우에 유용하다.

현재 회사에서는 Spring Boot + AWS Beanstalk 조합으로 서비스를 운영하고 있다. 빈즈톡을 이용하여 로드밸런싱 처리를 할 때 nginx 를 사용하고자 하는 경우 빈즈톡에서 사용하는 인스턴스 내에서 nginx 설정을 변경해도 반영되지 않는 문제가 발생한다.

AWS 의 개발가이드가 완전히 한국어화가 되지 않았기 때문에 찾아보기도 이해하기도 쉽지 않다.

이에 프로젝트 내에 빈즈톡과 관련된 설정파일을 두어 배포시 빈즈톡 내에 위치한 nginx 설정 파일 /etc/nginx/conf.d 에 위치하도록 할 수 있다.

적용방법

  1. 프로젝트 내에 aws 설정파일(.conf) 를 둘 디렉토리를 지정하라.

    • ex) $ mkdir boot-spring-boot/aws

  2. boot-spring-boot/aws 하위에 .ebextensions/nginx/conf.d/elasticbeanstalk 디렉토리를 생성한다.

엘라스틱 빈즈톡의 기본 nginx 를 확장하기 위해서는 .ebextensions/nginx/conf.d/ 폴더에 .conf 설정파일을 추가하면 된다. 그러면 자동으로 엘라스틱 빈즈톡의 nginx 구성에 .ebextensions/nginx/conf.d/ 에 있는 .conf 파일들이 추가된다.

~/workspace/boot-spring-boot/aws/
`-- .ebextensions
    `-- nginx
        `-- conf.d
            |-- elasticbeanstalk
            |   `-- 00_server.conf
            `-- boot-spring-boot.conf

conf.d 폴더에 있는 .conf 파일들은 기본 구성의 http 블럭에 포함되며, conf.d/elasticbeanstalk 폴더에 있는 파일의 내용은 http 블록 내에 server 블록에 포함된다.

엘라스틱 빈즈톡의 기본 nginx 구성을 완전히 덮어쓰기 위해서는 .ebextensions/nginx/nginx.conf 으로 구성을 추가하면 된다.

~/workspace/boot-spring-boot/aws/
`-- .ebextensions
    `-- nginx
        `-- nginx.conf

nginx 에서 파일업로드 사이즈를 10M로 올려보자.

  1. 프로젝트 내에 aws/.ebextensions/nginx/conf.d/elasticbeanstalk 폴더를 생성

  2. 00_server.conf 파일 생성

  3. 00_server.conf 내에 client_max_body_size 10M; 를 추가한다.

  4. 스프링 부트 패키징 시 .ebextensions/nginx/conf.d/elasticbeanstalk 폴더가 포함되어 배포되도록 만든다.

build.gradle 에 다음과 같은 태스크를 만들어 실행하면 손쉽게 가능해진다.

task awsEBZip(type: Zip, dependsOn: 'bootRepackage') {
from '../aws' // .ebextensions 위치
from 'build/libs/' + jar.archiveName bootRepackage 된 파일 위치
baseName = 'boot-spring-boot-' + jar.version // 재생성한 파일명
}


해외 기업의 웹서비스를 이용하는 기능을 개발하고 있다. 이 과정에서 낯설은 wsdl 생성과정 및 SOAP 사용방법을 정리해보고자 한다.

wsimport 는 JAX-WS 에 적합한 산출물을 생성하는 도구다. wsdl(Web Services Description Language) 을 불러와 그 파일을 기준으로 자바 코드를 생성한다.

사용방법

사용방법은 간단하다(물론 옵션은 여러가지가 있다. 상황에 따라 적절한 옵션을 추가하자).

$ wsimport {wsdl-url}

선택사항

$ wsimport
wsimport
Missing WSDL_URI
Usage: wsimport [options] <WSDL_URI>
where [options] include:
-b <path> specify jaxws/jaxb binding files or additional schemas
(Each <path> must have its own -b)
-B<jaxbOption> Pass this option to JAXB schema compiler
-catalog <file> specify catalog file to resolve external entity references
supports TR9401, XCatalog, and OASIS XML Catalog format.
-classpath <path> specify where to find user class files and wsimport extensions
-cp <path> specify where to find user class files and wsimport extensions
-d <directory> specify where to place generated output files
-encoding <encoding> specify character encoding used by source files
-extension allow vendor extensions - functionality not specified
by the specification. Use of extensions may
result in applications that are not portable or
may not interoperate with other implementations
-help display help
-httpproxy:<proxy> set a HTTP proxy. Format is [user[:password]@]proxyHost:proxyPort
(port defaults to 8080)
-J<javacOption> pass this option to javac
-keep keep generated files
-p <pkg> specifies the target package
-quiet suppress wsimport output
-s <directory> specify where to place generated source files
-target <version> generate code as per the given JAXWS spec version
Defaults to 2.2, Accepted values are 2.0, 2.1 and 2.2
e.g. 2.0 will generate compliant code for JAXWS 2.0 spec
-verbose output messages about what the compiler is doing
-version print version information
-fullversion print full version information
-wsdllocation <location> @WebServiceClient.wsdlLocation value
-clientjar <jarfile> creates the jar file of the generated artifacts along with the
WSDL metadata required for invoking the web service.
-generateJWS generate stubbed JWS implementation file
-implDestDir <directory> specify where to generate JWS implementation file
-implServiceName <name> local portion of service name for generated JWS implementation
-implPortName <name> local portion of port name for generated JWS implementation
Extensions:
-XadditionalHeaders map headers not bound to request or response message to
Java method parameters
-Xauthfile file to carry authorization information in the format
http://username:password@example.org/stock?wsdl
-Xdebug print debug information
-Xno-addressing-databinding enable binding of W3C EndpointReferenceType to Java
-Xnocompile do not compile generated Java files
-XdisableAuthenticator disable Authenticator used by JAX-WS RI,
-Xauthfile option will be ignored if set
-XdisableSSLHostnameVerification disable the SSL Hostname verification while fetching
wsdls
Examples:
wsimport stock.wsdl -b stock.xml -b stock.xjb
wsimport -d generated http://example.org/stock?wsdl

실습

http://www.webservicex.com/globalweather.asmx?WSDL 을 기준으로 테스트를 해보자.

$ wsimport -verbose -keep -extension http://www.webservicex.com/globalweather.asmx\?WSDL

라고 실행하면

parsing WSDL...
[WARNING] SOAP port "GlobalWeatherSoap12": uses a non-standard SOAP 1.2 binding.
line 199 of http://www.webservicex.com/globalweather.asmx?WSDL
[WARNING] Port "GlobalWeatherHttpGet" is not a SOAP port, it has no soap:address
line 202 of http://www.webservicex.com/globalweather.asmx?WSDL
[WARNING] port "GlobalWeatherHttpGet": not a standard SOAP port. The generated artifacts may not work with JAX-WS runtime.
line 202 of http://www.webservicex.com/globalweather.asmx?WSDL
[WARNING] Port "GlobalWeatherHttpPost" is not a SOAP port, it has no soap:address
line 205 of http://www.webservicex.com/globalweather.asmx?WSDL
[WARNING] port "GlobalWeatherHttpPost": not a standard SOAP port. The generated artifacts may not work with JAX-WS runtime.
line 205 of http://www.webservicex.com/globalweather.asmx?WSDL
Generating code...
net/webservicex/GetCitiesByCountry.java
net/webservicex/GetCitiesByCountryResponse.java
net/webservicex/GetWeather.java
net/webservicex/GetWeatherResponse.java
net/webservicex/GlobalWeather.java
net/webservicex/GlobalWeatherHttpGet.java
net/webservicex/GlobalWeatherHttpPost.java
net/webservicex/GlobalWeatherSoap.java
net/webservicex/ObjectFactory.java
net/webservicex/package-info.java
Compiling code...
javac -d /private/tmp/test-ws/. -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/classes -Xbootclasspath/p:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/rt.jar /private/tmp/test-ws/./net/webservicex/GetCitiesByCountry.java /private/tmp/test-ws/./net/webservicex/GetCitiesByCountryResponse.java /private/tmp/test-ws/./net/webservicex/GetWeather.java /private/tmp/test-ws/./net/webservicex/GetWeatherResponse.java /private/tmp/test-ws/./net/webservicex/GlobalWeather.java /private/tmp/test-ws/./net/webservicex/GlobalWeatherHttpGet.java /private/tmp/test-ws/./net/webservicex/GlobalWeatherHttpPost.java /private/tmp/test-ws/./net/webservicex/GlobalWeatherSoap.java /private/tmp/test-ws/./net/webservicex/ObjectFactory.java /private/tmp/test-ws/./net/webservicex/package-info.java

처럼 실행되어 있는 것을 볼 수 있을 것이다. 대상으로 하는 wsdl 파일을 내려받은 후에 이파일을 기준으로 자바코드를 생성하는 과정을 확인할 수 있다. 그리고 내려받은 자바코드를 컴파일하는 것까지 처리해준다.

생성된 디렉토리의 구조는 다음과 같다.

.
├── globalweather.asmx?WSDL
└── net
    └── webservicex
        ├── GetCitiesByCountry.class
        ├── GetCitiesByCountry.java
        ├── GetCitiesByCountryResponse.class
        ├── GetCitiesByCountryResponse.java
        ├── GetWeather.class
        ├── GetWeather.java
        ├── GetWeatherResponse.class
        ├── GetWeatherResponse.java
        ├── GlobalWeather.class
        ├── GlobalWeather.java
        ├── GlobalWeatherHttpGet.class
        ├── GlobalWeatherHttpGet.java
        ├── GlobalWeatherHttpPost.class
        ├── GlobalWeatherHttpPost.java
        ├── GlobalWeatherSoap.class
        ├── GlobalWeatherSoap.java
        ├── ObjectFactory.class
        ├── ObjectFactory.java
        ├── package-info.class
        └── package-info.java


AWS Beanstalk configuration with SpringBoot

AWS 빈즈토크(Beanstalk, 줄여서 빈즈톡)에 스프링 부트 애플리케이션을 배포하는 것과 관련해서는 위의 내용을 참조하기 바란다.


결론부터 내리자면

시스템에서 환경변수는 언더코어('_')를 사용하는데 스프링 부트 속성은 마침표('.')를 사용한다. 이를 궁휼히 여긴 스프링부트 팀에서 언더코어로 정의된 환경변수 중 스프링 부트 속성들에 대해서 주입해주는 기능을 넣었다.

ex) SPRING_DATASOURCE_URL => spring.datasource.url 

스프링 부트를 jar 형태로 aws 배포할 때는 시스템 환경변수만 적용되니 언더스코어로 스프링 부트 속성을 정의하면 적용된다.



스프링 부트 외부 구성(External configuration) 기능 설명

스프링 부트는 구동과 관련하여 외부에서 속성값을 받아 실행시 적용하는 외부 구성(External configuration) 기능을 지원한다. 스프링 부트에서 사용할 수 있는 OS 환경변수가 몇가지 있다.

  • SPRING_APPLICATION_JSONspring.application.json

  • SERVER_PORTserver.port 와 동일

  • SPRING_PROFILES_ACTIVEspring.profiles.active 와 동일

  • SPRING_APPLICATION_JSON: JSON 형태로 외부구성 값을 전달받는 기능

이는 로컬환경에서 jar 를 실행할 때에도 다음처럼 적용가능하다. 아래 세 가지 방법 모두 동일하게 실행된다.

$ java -jar -Dspring.application.json='{"spring.profiles.active": "dev"}' -jar my-app.jar
$ java -jar my-app.jar --spring.application.json='{"spring.profiles.active": "dev"}'
$ java -jar my-app.jar --SPRING_APPLICATION_JSON='{"spring.profiles.active": "dev"}'

AWS 빈즈토크 구성

애플리케이션 생성

  1. [Create New Application] 생성

  2. 'Web Server Environment' [Create web server] 생성

    • Predefined configurationJava

    • Environment typeLoad Balancing, auto scaling

  3. Select a source for your application version. (나중에 S3 형태로 선택"

  4. 환경설정은 여러분의 몫

Configuration - Softwar configuration

  • 스프링 부트 기본포트는 8080, 빈즈톡에서는 5000번을 듣는다. 둘이 어긋나는 부분이 있으니 환경변수를 지정하여 스프링 부트 앱의 포트번호를 지정한다.

기본 환경속성은 다음과 같다.

Environment Properties

Property NameProperty Value

GRADLE_HOME

/usr/local/gradle

JAVA_HOME

/usr/lib/jvm/java

M2

/usr/local/apache-maven/bin

M2_HOME

/usr/local/apache-maven

SERVER_PORT

5000

여기에 스프링 부트 환경변수에 해당하는 환경속성들을 추가해야한다.

  • SPRING_DATASOURCE_URL: jdbc:mysql://{url}/ebdb

  • SPRING_DATASOURCE_USERNAME: {username}

  • SPRING_DATASOURCE_PASSWORD: {password}

  • SPRING_JPA_HIBERNATE_DDL_AUTO: update // 변경가능

  • SPRING_JPA_DATABASE_PLATFORM: org.hibernate.dialect.MySQL5Dialect // 변경가능

기본적인 실행환경에 대해서는 스프링 프로파일 을 이용해서 구분짓도록 한다. application.properties 혹은 application.yml 의 기본적인 구성을 다음과 같이 했다면…​

# 기본적용공간 
server:
  error:
    whitelabel:
      enabled: false
    include-stacktrace: always
 
---
spring: #local
  profiles: local
  datasource:
    url: jdbc:mysql:localhost:3306/local
    username: honeymon
    password: gooddeveloper
  jpa:
    show-sql: true
    hibernate.ddl-auto: update
aws:
  s3.url: https://s3.aws.com/local-honeymon
 
---
spring: #test
  profiles: test
  datasource:
    url: jdbc:mysql:localhost:3306/test
    username: honeymon
    password: goodtester
  jpa:
    show-sql: true
    hibernate.ddl-auto: create-drop
aws:
  s3.url: https://s3.aws.com/test-honeymon
 
---
spring: #dev
  profiles: dev
  datasource:
    url: jdbc:mysql:localhost:3306/dev
    username: honeymon
    password: goodman
  jpa:
    show-sql: false
    hibernate.ddl-auto: validate
aws:
  s3.url: https://s3.aws.com/dev-honeymon
 
---
spring:
  profiles: prod

빈즈톡으로 운영서버에 배포하면서 prod 프로파일을 실행하고 싶다. 그런데 이때 변경되어야 할 정보들이 몇가지 있다. 보이는가?

spring.datasource.urlspring.datasource.usernamespring.datasource.passwordspring.jpa.hibernate.ddl-auto 등이 보인다.

스프링 부트의 자동 구성(Auto-Configuration) 은 외부 구성을 통해서 값을 변경하는 게 가능하다. 그런데 빈즈 토크에서는 외부 구성을 설정해도 java -jar 실행을 해도 외부 설정값을 실행인자로 전달하지 않는 것으로 보인다. 이런 기능적인 제약을 해소하기 위해 제공하는 환경 변수들이 있다.

  • SPRING_DATASOURCE_URL=jdbc:mysql://{rdb}/ebdb // spring.datasource.url 대응

  • SPRING_DATASOURCE_USERNAME=<username> // spring.datasource.username 대응

  • SPRING_DATASOURCE_PASSWORD=<password> // spring.datasource.password 대응

  • SPRING_JPA_HIBERNATE_DDL_AUTO=update // spring.jpa.hibernate.ddl-auto 대응

  • SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.MySQL5Dialect // spring.jpa.database-platform 대응

-


5가지 환경변수는 배포하는 환경에 따라 크게 달라질 수 있는 부분이기 제공하는 듯 하다. 대부분의 운영체제에서는 환경변수에서 . 로 명명하는 것을 허용하지 않고 언더스코어(_) 로 사용한다. 스프링부트에서는 이에 대한 지원을 하고 있다. 즉, spring.datasource.url 가 SPRING_DATASOURCE_URL 와 대응된다는 것이다. 그러니 빈즈톡에서는 환경변수를 SPRING_DATASOURCE_URL 로 지정해도 스프링 부트에서 알아서 spring.datasource.url 에 대입해주는 것이다.

String url = System.getProperty("SPRING_DATASOURCE_URL");
String username = System.getProperty("SPRING_DATASOURCE_USERNAME");
String username = System.getProperty("SPRING_DATASOURCE_PASSWORD");

짱 좋군.

스프링 부트를 jar 형태로 배포하고, 빈즈톡에서는 Java 애플리케이션 서버로 배포하기 위한 설정은 위의 '환경변수'를 정의하는 것으로 간단하게 구성이 가능하다.

이제 손쉽게!! 빈즈톡에 스프링부트 애플리케이션을 jar로 배포하면서 외부 구성을 변경하는 시도를 해볼 수 있을 것이다.


변경:

  • org.hibernate:hibernate-validator:5.4.0.Final → org.hibernate:hibernate-validator:5.3.6.Final

  • javax.el:javax.el-api:2.2.5 → org.glassfish:javax.el

해결방법힌트:

spring-boot.1.5.1 Reference document 에 기재된 버전에 맞춤

문제발생지점:

java.lang.IllegalStateException: Failed to load ApplicationContext
     at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
     at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
     at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189)
     at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)
     at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
     at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
     at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
     at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
     at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
     at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
     at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
     at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:498)
     at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
     at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
     at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
     at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
     at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
     at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:498)
     at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
     at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
     at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377)
     at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
     at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
     at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcValidator' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.validation.Validator]: Factory method 'mvcValidator' threw exception; nested exception is javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
     at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
     at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
     at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
     at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
     at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
     ... 45 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcValidator' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.validation.Validator]: Factory method 'mvcValidator' threw exception; nested exception is javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
     at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
     at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
     ... 62 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcValidator' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.validation.Validator]: Factory method 'mvcValidator' threw exception; nested exception is javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
     at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
     at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:381)
     at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$c8b21c0c.mvcValidator(<generated>)
     at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.getConfigurableWebBindingInitializer(WebMvcConfigurationSupport.java:567)
     at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration.getConfigurableWebBindingInitializer(WebMvcAutoConfiguration.java:410)
     at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.requestMappingHandlerAdapter(WebMvcConfigurationSupport.java:526)
     at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration.requestMappingHandlerAdapter(WebMvcAutoConfiguration.java:372)
     at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$c8b21c0c.CGLIB$requestMappingHandlerAdapter$3(<generated>)
     at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$c8b21c0c$$FastClassBySpringCGLIB$$bbc0971f.invoke(<generated>)
     at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
     at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
     at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$c8b21c0c.requestMappingHandlerAdapter(<generated>)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:498)
     at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
     ... 63 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.validation.Validator]: Factory method 'mvcValidator' threw exception; nested exception is javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
     at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
     at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
     ... 87 more
Caused by: javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
     at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.buildExpressionFactory(ResourceBundleMessageInterpolator.java:102)
     at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:45)
     at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean$HibernateValidatorDelegate.buildMessageInterpolator(LocalValidatorFactoryBean.java:418)
     at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.setValidationMessageSource(LocalValidatorFactoryBean.java:160)
     at org.springframework.web.servlet.config.annotation.WebMvcConfigurerComposite.getValidator(WebMvcConfigurerComposite.java:165)
     at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration.getValidator(DelegatingWebMvcConfiguration.java:137)
     at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.mvcValidator(WebMvcConfigurationSupport.java:614)
     at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$c8b21c0c.CGLIB$mvcValidator$41(<generated>)
     at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$c8b21c0c$$FastClassBySpringCGLIB$$bbc0971f.invoke(<generated>)
     at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
     at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
     at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$c8b21c0c.mvcValidator(<generated>)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:498)
     at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
     ... 88 more
Caused by: javax.el.ELException: Provider com.sun.el.ExpressionFactoryImpl not found
     at javax.el.FactoryFinder.newInstance(FactoryFinder.java:101)
     at javax.el.FactoryFinder.find(FactoryFinder.java:197)
     at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:189)
     at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:160)
     at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.buildExpressionFactory(ResourceBundleMessageInterpolator.java:98)
     ... 105 more
Caused by: java.lang.ClassNotFoundException: com.sun.el.ExpressionFactoryImpl
     at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
     at javax.el.FactoryFinder.newInstance(FactoryFinder.java:87)
     ... 109 more


+ Recent posts