0

I am getting the following error when I upgrade from Java8 to Java9 Spring boot application. Is any annotation in the spring-web-5.0.0.RELEASE and spring-webmvc-5.0.0.RELEASE that are not supported by Java 9. I am unable to make out from the error received in the application.

2017-10-31 14:18:39.767 ERROR [org.springframework.boot.SpringApplication] [main] [] Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1704)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:756)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233)
    at com.tsys.enterprise.issuing.account.application.Main.main(Main.java:30)
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
    at java.base/sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
    at java.base/sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
    at java.base/sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
    at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
    at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
    at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
    at java.base/java.lang.Class.createAnnotationData(Class.java:3730)
    at java.base/java.lang.Class.annotationData(Class.java:3719)
    at java.base/java.lang.Class.createAnnotationData(Class.java:3735)
    at java.base/java.lang.Class.annotationData(Class.java:3719)
    at java.base/java.lang.Class.getAnnotation(Class.java:3624)
    at java.base/java.lang.reflect.AnnotatedElement.isAnnotationPresent(AnnotatedElement.java:262)
    at java.base/java.lang.Class.isAnnotationPresent(Class.java:3634)
    at org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation(AnnotatedElementUtils.java:610)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.isHandler(RequestMappingHandlerMapping.java:177)
    at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:217)
    at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:188)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:129)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1763)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1700)
SSNM
  • 1
  • Do you have this application working with Java 8 and it fails only when you're changing the Java version? – Stephane Nicoll Oct 31 '17 at 19:41
  • Im excited to see this working with thymeleaf and I will surely migrate to j9 and boot2 – Antoniossss Oct 31 '17 at 20:18
  • Yes, that's correct. It works fine with Java8. – SSNM Oct 31 '17 at 20:32
  • You may have a mixed version of dependencies or something broken/unusual in your build. Can you share a minimal sample that reproduces the issue? (Both Spring 5 and Spring Boot 2 are fine with Java 9 and this exception is unrelated to the change of JDK as far as I know) – Stephane Nicoll Nov 01 '17 at 06:28
  • I found the same problem in [this](https://github.com/spring-projects/spring-boot/issues/4579) issue on github. Make sure that you are not facing the same problem. Otherwise please provide additional information regarding your issue. – Anastasios Vlasopoulos Nov 04 '17 at 17:35

1 Answers1

0

If you see this other ticket sun.reflect.annotation.TypeNotPresentExceptionProxy exception after adding EntityListeners

The exception that you´re having TypeNotPresentExceptionProxy it could be you have an annotation which a class that is not in the classPath.

On of the greatest/annoying features of Java 9 is the module system, where now you will have to specify in your module-info some package if you want to use it.

Your requestMappingHandlerMapping class contains any annotation that can prove my theory?

paul
  • 12,873
  • 23
  • 91
  • 153
  • The "RequestMappingHandlerMapping" from the Spring MVC class is a annotation by itself. – SSNM Nov 03 '17 at 19:43