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

Storage Sample - Native Support : org.apache.commons.logging.LogFactoryService was unintentionally initialized at build time #3147

Closed
burkedavison opened this issue Aug 22, 2024 · 2 comments · Fixed by #3195
Assignees
Labels
priority: p2 type: bug Something isn't working

Comments

@burkedavison
Copy link
Member

https://github.com/GoogleCloudPlatform/spring-cloud-gcp/actions/runs/10497506583/job/29080521773?pr=3146
and
https://github.com/GoogleCloudPlatform/spring-cloud-gcp/actions/runs/10490437549/job/29057183715

Error: Classes that should be initialized at run time got initialized during image building:
 org.apache.commons.logging.LogFactoryService was unintentionally initialized at build time. To see why org.apache.commons.logging.LogFactoryService got initialized use --trace-class-initialization=org.apache.commons.logging.LogFactoryService
org.apache.commons.logging.LogFactory was unintentionally initialized at build time. To see why org.apache.commons.logging.LogFactory got initialized use --trace-class-initialization=org.apache.commons.logging.LogFactory
To see how the classes got initialized, use --trace-class-initialization=org.apache.commons.logging.LogFactoryService,org.apache.commons.logging.LogFactory
@mpeddada1
Copy link
Contributor

Also porting comment from #3105 (comment) on initial investigation:

Failure: org.apache.commons.logging.LogFactory was unintentionally initialized at build time

Using --trace-class-initialization=org.apache.commons.logging.LogFactory,org.apache.commons.logging.LogFactoryService locally shows that that the build time initialization is being caused by org.springframework.beans.factory.support.DisposableBeanAdapter:

Error: Classes that should be initialized at run time got initialized during image building:
 org.apache.commons.logging.LogFactory was unintentionally initialized at build time. org.springframework.beans.factory.support.DisposableBeanAdapter caused initialization of this class with the following trace: 
	at org.apache.commons.logging.LogFactory.<clinit>(LogFactory.java:136)
	at jdk.internal.misc.Unsafe.ensureClassInitialized0(Unknown Source)
	at jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160)
	at jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:300)
	at jdk.internal.reflect.MethodHandleAccessorFactory.newConstructorAccessor(MethodHandleAccessorFactory.java:103)
	at jdk.internal.reflect.ReflectionFactory.newConstructorAccessor(ReflectionFactory.java:200)
	at java.lang.reflect.Constructor.acquireConstructorAccessor(Constructor.java:549)
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
	at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:304)
	at java.lang.Class.newInstance(Class.java:725)
	at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1047)
	at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:960)
	at java.security.AccessController.executePrivileged(AccessController.java:778)
	at java.security.AccessController.doPrivileged(AccessController.java:319)
	at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:957)
	at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:552)
	at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
	at org.springframework.beans.factory.support.DisposableBeanAdapter.<clinit>(DisposableBeanAdapter.java:76)

org.apache.commons.logging.LogFactoryService was unintentionally initialized at build time. org.springframework.beans.factory.support.DisposableBeanAdapter caused initialization of this class with the following trace: 
	at org.apache.commons.logging.LogFactoryService.<clinit>(LogFactoryService.java)
	at jdk.internal.misc.Unsafe.ensureClassInitialized0(Unknown Source)
	at jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160)
	at jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:300)
	at jdk.internal.reflect.MethodHandleAccessorFactory.newConstructorAccessor(MethodHandleAccessorFactory.java:103)
	at jdk.internal.reflect.ReflectionFactory.newConstructorAccessor(ReflectionFactory.java:200)
	at java.lang.reflect.Constructor.acquireConstructorAccessor(Constructor.java:549)
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
	at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:304)
	at java.lang.Class.newInstance(Class.java:725)
	at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1047)
	at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:960)
	at java.security.AccessController.executePrivileged(AccessController.java:778)
	at java.security.AccessController.doPrivileged(AccessController.java:319)
	at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:957)
	at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:552)
	at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
	at org.springframework.beans.factory.support.DisposableBeanAdapter.<clinit>(DisposableBeanAdapter.java:76)

Solution: Add Args=--initialize-at-build-time=org.apache.commons.logging.LogFactory,org.apache.commons.logging.LogFactoryService to both spring-cloud-gcp-integration-storage-sample and spring-cloud-gcp-storage-resource-sample.

@mpeddada1
Copy link
Contributor

Build time failures with org.apache.commons.logging.LogFactory and org.apache.commons.logging.LogFactoryService is a known issue with spring framework especially when the application is bringing a commons-logging dependency either directly or transitively: spring-projects/spring-framework#30575. However, it is interesting that this recently started occurring.

Next question: After what dependency update did this failure first start occurring?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 type: bug Something isn't working
Projects
None yet
2 participants