[SWS-877] Support @Repeatable in @PayloadRoot and @SoapAction Created: 18/Jul/14  Updated: 08/Apr/15  Resolved: 08/Apr/15

Status: Resolved
Project: Spring Web Services
Component/s: None
Affects Version/s: None
Fix Version/s: 2.2.1

Type: Improvement Priority: Minor
Reporter: Arjen Poutsma Assignee: Arjen Poutsma
Resolution: Complete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relate
is related to SPR-12889 AnnotatedElementUtils should lenientl... Closed

 Description   

Support the JDK 8 @Repeatable annotation in the @SoapAction and @PayloadRoot annotations.



 Comments   
Comment by Gyula Szalai [ 02/Apr/15 ]

Because of this mod, our Java6 based project won't run with spring-ws 2.2.1. Is it intentional?

Comment by Arjen Poutsma [ 02/Apr/15 ]

Gyula Szalai no, it is not. What is the error/stacktrace you are getting?

Comment by Gyula Szalai [ 03/Apr/15 ]

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ValamiEndpointImpl' defined in URL [jar:file:/valami-ws-1.0.0-SNAPSHOT.jar!/hu/vanio/valami/ws/ValamiEndpointImpl.class]: Post-processing failed of bean type [class hu.vanio.valami.ws.ValamiEndpointImpl] failed; nested exception is java.lang.IllegalStateException: Failed to introspect annotations: public hu.vanio.valami.schema.ValamiValasz hu.vanio.valami.ws.ValamiEndpointImpl.valamiLekerdezes(hu.vanio.valami.schema.ValamiKeres) throws java.lang.Exception
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:936) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) [spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) [spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) [spring-boot-1.2.3.RELEASE.jar!/:1.2.3.RELEASE]
	at hu.vanio.valami.ValamiWsApplication.main(ValamiWsApplication.java:19) [valami-ws-1.0.0-SNAPSHOT.jar!/:1.0.0-SNAPSHOT]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:6.0]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45) ~[na:6.0]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) ~[na:6.0]
	at java.lang.reflect.Method.invoke(Method.java:599) ~[na:6.0]
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) [valami-ws-1.0.0-SNAPSHOT.jar!/:1.0.0-SNAPSHOT]
	at java.lang.Thread.run(Thread.java:735) [na:6.0]
Caused by: java.lang.IllegalStateException: Failed to introspect annotations: public hu.vanio.valami.schema.ValamiValasz hu.vanio.valami.ws.ValamiEndpointImpl.valamiLekerdezes(hu.vanio.valami.schema.ValamiKeres) throws java.lang.Exception
	at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:166) ~[spring-core-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(AnnotatedElementUtils.java:91) ~[spring-core-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(AnnotatedElementUtils.java:85) ~[spring-core-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.findAutowiredAnnotation(AutowiredAnnotationBeanPostProcessor.java:434) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.buildAutowiringMetadata(AutowiredAnnotationBeanPostProcessor.java:407) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.findAutowiringMetadata(AutowiredAnnotationBeanPostProcessor.java:370) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(AutowiredAnnotationBeanPostProcessor.java:233) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:931) ~[spring-beans-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	... 19 common frames omitted
Caused by: java.lang.TypeNotPresentException: Type java.lang.annotation.Repeatable not present
	at com.ibm.oti.reflect.AnnotationHelper.getAnnotation(AnnotationHelper.java:38) ~[na:na]
	at com.ibm.oti.reflect.AnnotationHelper.getDeclaredAnnotations(AnnotationHelper.java:50) ~[na:na]
	at java.lang.Class.getDeclaredAnnotations(Class.java:1628) ~[na:6.0]
	at java.lang.Class.getAnnotations(Class.java:1589) ~[na:6.0]
	at org.springframework.core.annotation.AnnotatedElementUtils.doProcess(AnnotatedElementUtils.java:192) ~[spring-core-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.core.annotation.AnnotatedElementUtils.doProcess(AnnotatedElementUtils.java:209) ~[spring-core-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:162) ~[spring-core-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
	... 26 common frames omitted
Caused by: java.lang.ClassNotFoundException: java.lang.annotation.Repeatable
	at java.lang.Class.forNameImpl(Native Method) ~[na:6.0]
	at java.lang.Class.forName(Class.java:169) ~[na:6.0]
	at com.ibm.oti.reflect.AnnotationHelper.getAnnotation(AnnotationHelper.java:33) ~[na:na]
	... 32 common frames omitted

Comment by Gyula Szalai [ 03/Apr/15 ]

It's a Spring Boot application, that runs on AIX 5.3 and IBM Java6.
This error appeared after upgrading Spring-Boot from 1.2.2 to 1.2.3.
At first, I thought it was caused by the newer spring-core version,
but after fiddling around a bit, it turned out that if we downgraded spring-ws
to 2.2.0 the problem disappeared.

Comment by Arjen Poutsma [ 03/Apr/15 ]

I am not convinced that this is a Spring-WS bug, as our use of Repeatable is identical to what Spring does:

https://github.com/spring-projects/spring-framework/blob/master/spring-context/src/main/java/org/springframework/context/annotation/PropertySource.java#L147

This should work under JDK 6 or 7, since annotations that cannot be found in the JDK should simply be ignored. It seems more likely that this is some sort of annotation-introspection bug that occurs in IBM JDKs. I will ask around and investigate further.

Comment by Gyula Szalai [ 03/Apr/15 ]

OK, thank you in advance.

Comment by Juergen Hoeller [ 03/Apr/15 ]

Indeed, Spring Web Services uses the same approach as some of the annotations in Spring Framework 4.x itself. Let's rather revisit Spring's core AnnotatedElementUtils to be more defensive towards TypeNotPresentExceptions, in particular when calling Class.getDeclaredAnnotations() instead of Class.getAnnotations(). Could you please create a corresponding SPR issue for this?

For better or for worse, IBM's JDK 6 is pretty special there, having peculiar rules with respect to nested type resolution within method bodies as well. Note that as of JDK 7, IBM's JDKs are derived from OpenJDK and therefore naturally more in line with Oracle's established JDK behavior. If you have any chance to do so, you could run this on IBM JDK 7, just to see whether the problem goes away...

Actually, it might even help to upgrade to the latest IBM JDK 6 version, assuming you might be using an older variant there?

Juergen

Comment by Gyula Szalai [ 03/Apr/15 ]

Thanks J├╝rgen! Actually we used a very-very old IBM JDK6 version. Unfortunately this server is stuck
with AIX 5.3 so, JDK6 is the maximum. Our ops team upgraded it to the latest (2014dec)
version and the problem has vanished

Shall I file an SPR issue or it can be closed?

Comment by Juergen Hoeller [ 03/Apr/15 ]

Alright, I'm glad to hear that it works for you now

No need to create an SPR issue for this one then. I'm nevertheless going to revisit our annotation introspection exception handling but will do so under a different umbrella.

Juergen

Generated at Thu Dec 14 17:06:30 UTC 2017 using JIRA 6.4.14#64029-sha1:ae256fe0fbb912241490ff1cecfb323ea0905ca5.