Pivotal Knowledge Base

Follow

Spring: Class-Loading Issues in z/OS IBM JDK

Environment
 
 Product  Version
 Spring  3.x

Purpose

This article aims to provide an informational aspect regarding the use of the Spring 3.x application in a z/OS IBM JDK environment.

Symptom

Upgrading from Spring 2.5.x to Spring 3.x can raise some issues at classloading level if used in a z/OS IBM JDK together with the Websphere Application Server. Exceptions which were spotted are similar to "IllegalArgumentException: Object is not an instance of declaring class."

Spring 3.x packaging introduces the new org.springframework.asm module which was not present in 2.5.x branch. This is a re-packaged version of the ASM open source library. Spring's component scanning feature makes use of this module and the following behavior has been observed in a z/OS IBM JDK usage, under Websphere Application Server:

 java.lang.IllegalStateException: Could not obtain annotation attribute values
at org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes(AnnotationUtils.java:306)
at org.springframework.core.type.classreading.AnnotationAttributesReadingVisitor.visitEnd(AnnotationAttributesReadingVisitor.java:135)
at org.springframework.asm.ClassReader.a(Unknown Source)
at org.springframework.asm.ClassReader.accept(Unknown Source)
at org.springframework.asm.ClassReader.accept(Unknown Source)
at org.springframework.core.type.classreading.SimpleMetadataReader.getAnnotationMetadata(SimpleMetadataReader.java:79)
at org.springframework.core.type.filter.AnnotationTypeFilter.matchSelf(AnnotationTypeFilter.java:68)
at org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter.match(AbstractTypeHierarchyTraversingFilter.java:55)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.isCandidateComponent(ClassPathScanningCandidateComponentProvider.java:280)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:214)
... 30 more
Caused by:
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes(AnnotationUtils.java:283) 

Cause

-Xshareclasses JVM option is something that is specific to the z/OS operating system and, by default, is turned on.

Resolution

Check -Xshareclasses JVM option and see if this behavior persists after setting it to "none": -Xshareclasses:none.

Additional Information

 
 

Comments

Powered by Zendesk