Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PropertyEditorRegistrySupport throws ExceptionInInitializerError when on endorsed classpath [SPR-11780] #16402

Closed
spring-projects-issues opened this issue May 13, 2014 · 3 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented May 13, 2014

Christoph Leuzinger opened SPR-11780 and commented

We encounter a java.lang.ExceptionInInitializerError when running our application with the Spring libraries on the JVM endorsed classpath:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor': Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1076)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1021)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:88)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
...

This is due to the following piece of code in PropertyEditorRegistrySupport (line 92):

zoneIdClass = PropertyEditorRegistrySupport.class.getClassLoader().loadClass("java.time.ZoneId");

The class loader is null, because PropertyEditorRegistrySupport has been loaded by the bootstrap class loader. The resolution is to either remove the Spring libraries from the endorsed classpath, or to work around the problem by using the system class loader to obtain the zoneId:

ClassLoader classLoader = PropertyEditorRegistrySupport.class.getClassLoader();
if (classLoader == null)
{
  classLoader = ClassLoader.getSystemClassLoader();
}
zoneIdClass = classLoader.loadClass("java.time.ZoneId");

Affects: 4.0.4

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented May 15, 2014

Juergen Hoeller commented

Good catch! We've done a deep pass through the codebase for such Class.getClassLoader() calls in 4.0.4 already (see #16343), but seems we missed a few spots. Fixed for 4.0.5 now, along with similar calls in the spring-orm module.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This fix is available in the latest 4.0.5 and 4.1.0 snapshots now. Please give it a try and let us know whether it works for you...

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Christoph Leuzinger commented

Thanks, our issue does not occur with the 4.0.5 SNAPSHOT anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants