You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Upgrade to Objenesis 2.6 for Google App Engine Standard on Java 8 and for better JDK 9 support [SPR-15600] #20159
App Engine Standard for Java 8 (currently in Alpha) lifted the old sandbox/API restrictions. We can now use Objenesis as-is. A recent patch was merged into Objensis to take this new environment into account.
Objenesis 2.6 will behave as it used to on GAE on Java 7 which is
Call no constructor if the class is serializable
Call the no-arg constructor otherwise
And then, there is 3 things I should have mention a long time ago:
Maybe shading Objenesis isn't a good idea. Objenesis has a stable API. It hasn't changed for years. Only the code under the hood is changing. So not shading would allow users to update easily.
Right now, Objenesis is static in ConfigurationClassEnhancer. So there is no way to easily specify a custom strategy even though SpringObjenesis allows it. It would be useful to change that to get flexibility
SpringObjenesis seems to contain some (not all) stuff that could go down in Objenesis directly. I will have a better look but you can file an issue (or PR) about it
I was trying to deploy a simple Hello World style Spring Boot app to the new Java 8 runtime for Google App Engine, and also faced this issue with Objenesis.
For reference, here was the huge stacktrace I got:
javax.servlet.ServletContext log: 2 Spring WebApplicationInitializers detected on classpath
javax.servlet.ServletContext log: Initializing Spring embedded WebApplicationContext
Failed startup of context c.g.a.r.j.AppEngineWebAppContext@3ebdf556{/,file:///base/data/home/apps/s~spring-boot-jpa-demo/20170622t160815.402154028493911964/,UNAVAILABLE}{/base/data/home/apps/s~spring-boot-jpa-demo/20170622t160815.402154028493911964}
java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:68)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:330)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1406)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1368)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:522)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:244)
at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:182)
at com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:96)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:661)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:621)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:591)
at com.google.apphosting.runtime.JavaRuntime$NullSandboxRequestRunnable.run(JavaRuntime.java:787)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:263)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
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:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151)
at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131)
at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:140)
at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:63)
... 17 more
Caused by: org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:217)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:109)
at org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver.buildLazyResolutionProxy(ContextAnnotationAutowireCandidateResolver.java:100)
at org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver.getLazyResolutionProxyIfNecessary(ContextAnnotationAutowireCandidateResolver.java:45)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1063)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
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:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1316)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1282)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1180)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1096)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:659)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
... 37 more
Caused by: org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:76)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:201)
... 61 more
Caused by: java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
at java.lang.Class.newInstance(Class.java:428)
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:73)
... 62 more
Caused by: java.lang.NoSuchMethodException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15.<init>()
at java.lang.Class.getConstructor0(Class.java:3084)
at java.lang.Class.newInstance(Class.java:413)
... 63 more
Uncaught exception from servlet
java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:68)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:330)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1406)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1368)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:522)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:244)
at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:182)
at com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:96)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:661)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:621)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:591)
at com.google.apphosting.runtime.JavaRuntime$NullSandboxRequestRunnable.run(JavaRuntime.java:787)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:263)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
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:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151)
at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131)
at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:140)
at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:63)
... 17 more
Caused by: org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:217)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:109)
at org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver.buildLazyResolutionProxy(ContextAnnotationAutowireCandidateResolver.java:100)
at org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver.getLazyResolutionProxyIfNecessary(ContextAnnotationAutowireCandidateResolver.java:45)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1063)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
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:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1316)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1282)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1180)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1096)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:659)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
... 37 more
Caused by: org.springframework.aop.framework.AopConfigException: Unable to instantiate proxy using Objenesis, and regular proxy instantiation via default constructor fails as well; nested exception is java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:76)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:201)
... 61 more
Caused by: java.lang.InstantiationException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15
at java.lang.Class.newInstance(Class.java:428)
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:73)
... 62 more
Caused by: java.lang.NoSuchMethodException: org.springframework.boot.autoconfigure.web.HttpMessageConverters$$EnhancerBySpringCGLIB$$3ba87c15.<init>()
at java.lang.Class.getConstructor0(Class.java:3084)
at java.lang.Class.newInstance(Class.java:413)
... 63 more
HttpMessageConverters is part of Spring Boot - and other classes may have the same issue (in Boot or other projects) so I'm not sure fixing that case will really solve the issue.
Phil Webb, since that HttpMessageConverters class lives in Spring Boot: Any chance to add such a default constructor? And why is it being proxied in the first place... What kind of AOP advice is actually being applied to it?
Henri Tremblay, thanks for reaching out! We are primarily shading Objenesis as a user convenience, avoiding a dependency on an extra artifact, and moving Objenesis out of the user's face to begin with. It also avoids dependency resolution conflicts with Objenesis dependencies from other libraries, guaranteeing that Spring is always running against a current enough Objenesis version for its own purposes. It does come at the price of having to wait for a new Spring Framework version in order to upgrade Objenesis, but well, since most Spring users are not even aware of Objenesis, I do not expect regular Spring users to have a desire to manually upgrade Objenesis there... or be aware of the need to do so for certain new platforms in the first place. We're usually picking up new Objenesis versions within a few weeks, so it's not too bad a compromise. I've been waiting for 2.6 to be released already: cool to have it out now, we'll pick it up for 4.3.10 right away.
In ConfigurationClassEnhancer, we're only using Objenesis for a very specific purpose (intermediate proxies for FactoryBean references on @Bean methods), so making it explicitly configurable doesn't seem necessary. It's also not explicitly configurable in other places, e.g. in ObjenesisCglibAopProxy.
It's worth noting that the framework does not strictly require Objenesis to work since we fall back to the default constructor otherwise (assuming that it is a side-effect-free constructor then). The only painful point is a class that doesn't have a default constructor despite being used as a proxy class: Such design effectively makes it require Objenesis, unfortunately...
Phil Webb, while we're at it, can we move the Spring Boot 1.5.5 target date a bit closer to Spring Framework 4.3.10: e.g. to July 18th, going along with Boot 2.0 M3?
Thanks for the explanations Juergen Hoeller. Indeed Objenesis is a mysterious library. I just know that people are not that quick at migrating Spring versions. But it's your call anyway. I thought there was a central point of usage.
The more people are using constructor injection the less chance there is that they will have a default constructor no? Unless they have the habit of adding a private one.
There is really no reason for us to create a default constructor there I am afraid. As Brian Clozel point out, there are probably a lot of other cases like that.
Objenesis 2.6 is in Spring Framework master and therefore 5.0.0.BUILD-SNAPSHOT now. I'll keep this ticket open until it's upgraded in the 4.3.x branch as well.
Juergen Hoeller I've moved the 1.5.5 release date to July 20. It might be a bit of a light release, but I think the dependency upgrade alone makes it worthwhile.
While waiting, here is a cute hack to make it work right now. If it can be of any help. It could even go in the real SpringObjenesis.java version. But I'm not sure the shading plugin will like that.
Activity
spring-projects-issues commentedon Jun 22, 2017
Henri Tremblay commented
Just wanted to add a precision:
And then, there is 3 things I should have mention a long time ago:
spring-projects-issues commentedon Jun 22, 2017
Guillaume Laforge commented
I was trying to deploy a simple Hello World style Spring Boot app to the new Java 8 runtime for Google App Engine, and also faced this issue with Objenesis.
For reference, here was the huge stacktrace I got:
spring-projects-issues commentedon Jun 22, 2017
Henri Tremblay commented
Yes. This class isn't serializable nor has a no-arg constructor. So it won't work on GAE with Objenesis before 2.6. And won't work on GAE on Java 1.7.
To get GAE 1.7 support, I think a new private constructor should be added.
spring-projects-issues commentedon Jun 22, 2017
Brian Clozel commented
HttpMessageConvertersis part of Spring Boot - and other classes may have the same issue (in Boot or other projects) so I'm not sure fixing that case will really solve the issue.spring-projects-issues commentedon Jun 22, 2017
Juergen Hoeller commented
Phil Webb, since that
HttpMessageConvertersclass lives in Spring Boot: Any chance to add such a default constructor? And why is it being proxied in the first place... What kind of AOP advice is actually being applied to it?Henri Tremblay, thanks for reaching out! We are primarily shading Objenesis as a user convenience, avoiding a dependency on an extra artifact, and moving Objenesis out of the user's face to begin with. It also avoids dependency resolution conflicts with Objenesis dependencies from other libraries, guaranteeing that Spring is always running against a current enough Objenesis version for its own purposes. It does come at the price of having to wait for a new Spring Framework version in order to upgrade Objenesis, but well, since most Spring users are not even aware of Objenesis, I do not expect regular Spring users to have a desire to manually upgrade Objenesis there... or be aware of the need to do so for certain new platforms in the first place. We're usually picking up new Objenesis versions within a few weeks, so it's not too bad a compromise. I've been waiting for 2.6 to be released already: cool to have it out now, we'll pick it up for 4.3.10 right away.
In
ConfigurationClassEnhancer, we're only using Objenesis for a very specific purpose (intermediate proxies forFactoryBeanreferences on@Beanmethods), so making it explicitly configurable doesn't seem necessary. It's also not explicitly configurable in other places, e.g. inObjenesisCglibAopProxy.It's worth noting that the framework does not strictly require Objenesis to work since we fall back to the default constructor otherwise (assuming that it is a side-effect-free constructor then). The only painful point is a class that doesn't have a default constructor despite being used as a proxy class: Such design effectively makes it require Objenesis, unfortunately...
spring-projects-issues commentedon Jun 22, 2017
Juergen Hoeller commented
Phil Webb, while we're at it, can we move the Spring Boot 1.5.5 target date a bit closer to Spring Framework 4.3.10: e.g. to July 18th, going along with Boot 2.0 M3?
spring-projects-issues commentedon Jun 24, 2017
Henri Tremblay commented
Thanks for the explanations Juergen Hoeller. Indeed Objenesis is a mysterious library. I just know that people are not that quick at migrating Spring versions. But it's your call anyway. I thought there was a central point of usage.
The more people are using constructor injection the less chance there is that they will have a default constructor no? Unless they have the habit of adding a private one.
spring-projects-issues commentedon Jun 26, 2017
Stéphane Nicoll commented
Indeed.
There is really no reason for us to create a default constructor there I am afraid. As Brian Clozel point out, there are probably a lot of other cases like that.
spring-projects-issues commentedon Jun 26, 2017
Juergen Hoeller commented
Objenesis 2.6 is in Spring Framework master and therefore
5.0.0.BUILD-SNAPSHOTnow. I'll keep this ticket open until it's upgraded in the 4.3.x branch as well.spring-projects-issues commentedon Jun 26, 2017
Guillaume Laforge commented
Wonderful, thank you Jürgen!
spring-projects-issues commentedon Jun 28, 2017
Phil Webb commented
Juergen Hoeller I've moved the 1.5.5 release date to July 20. It might be a bit of a light release, but I think the dependency upgrade alone makes it worthwhile.
spring-projects-issues commentedon Jun 28, 2017
Guillaume Laforge commented
Good to know about the associated Boot release! Nice!
spring-projects-issues commentedon Jun 28, 2017
Henri Tremblay commented
While waiting, here is a cute hack to make it work right now. If it can be of any help. It could even go in the real
SpringObjenesis.javaversion. But I'm not sure the shading plugin will like that.