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

HandshakeWebSocketService causes early initialization of LogFactory when creating native image #31322

Closed
msosa opened this issue Sep 27, 2023 · 1 comment
Assignees
Labels
for: external-project Needs a fix in external project status: declined A suggestion or change that we don't feel we should currently apply

Comments

@msosa
Copy link

msosa commented Sep 27, 2023

Affects: 6.0.12 (spring boot 3.1.x)


I recently upgraded my project to use Spring Boot 3.1.x(from 3.0.x) and I am getting an error when trying to build a native image. The stack from the build error is

 [creator]     Error: Classes that should be initialized at run time got initialized during image building:
    [creator]      org.apache.commons.logging.LogFactory was unintentionally initialized at build time. org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService caused initialization of this class with the following trace: 
    [creator]     	at org.apache.commons.logging.LogFactory.<clinit>(LogFactory.java:136)
    [creator]     	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Unknown Source)
    [creator]     	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    [creator]     	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    [creator]     	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    [creator]     	at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
    [creator]     	at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347)
    [creator]     	at java.lang.Class.newInstance(Class.java:645)
    [creator]     	at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1047)
    [creator]     	at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:960)
    [creator]     	at java.security.AccessController.executePrivileged(AccessController.java:776)
    [creator]     	at java.security.AccessController.doPrivileged(AccessController.java:318)
    [creator]     	at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:957)
    [creator]     	at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:552)
    [creator]     	at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
    [creator]     	at org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService.<clinit>(HandshakeWebSocketService.java:100)

In my sample repo I am getting this error by adding implementation("com.twilio.sdk:twilio:9.12.0"). The library must be using the spring websockets which cause this error. Let me know if since I can only repo it by using another library if I will need to figure out another way to repro purely using HandshakeWebSocketService

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 27, 2023
@sbrannen sbrannen added the theme: aot An issue related to Ahead-of-time processing label Sep 27, 2023
@snicoll snicoll removed the theme: aot An issue related to Ahead-of-time processing label Oct 16, 2023
@sdeleuze
Copy link
Contributor

This error looks similar to the one discussed in #30575, in order to fix it, you should exclude the transitive dependency on commons-logging:commons-logging. After discussing with @snicoll, I have created spring-projects/spring-boot#37890 to see if we could have such exclude done automatically by Spring Boot or not.

@sdeleuze sdeleuze closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2023
@sdeleuze sdeleuze self-assigned this Oct 16, 2023
@sdeleuze sdeleuze added status: declined A suggestion or change that we don't feel we should currently apply for: external-project Needs a fix in external project and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project Needs a fix in external project status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

5 participants