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

Defer creating logger in StandardWebSocketHandlerAdapter #25427

Closed
quaff opened this issue Jul 20, 2020 · 2 comments
Closed

Defer creating logger in StandardWebSocketHandlerAdapter #25427

quaff opened this issue Jul 20, 2020 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Milestone

Comments

@quaff
Copy link
Contributor

quaff commented Jul 20, 2020

It's similar to #23655
Open Liberty will load class org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter before starting of application, it trigger log4j2 initialization before web application initialization, system property lookup will not using value set at WebApplicationInitializer::onStartup.

here is stack trace:

[err]   at org.apache.logging.log4j.core.lookup.SystemPropertiesLookup.lookup(SystemPropertiesLookup.java:45)
[err]   at org.apache.logging.log4j.core.lookup.AbstractLookup.lookup(AbstractLookup.java:33)
[err]   at org.apache.logging.log4j.core.lookup.Interpolator.lookup(Interpolator.java:198)
[err]   at org.apache.logging.log4j.core.lookup.StrSubstitutor.resolveVariable(StrSubstitutor.java:1060)
[err]   at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:982)
[err]   at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:878)
[err]   at org.apache.logging.log4j.core.lookup.StrSubstitutor.replace(StrSubstitutor.java:433)
[err]   at org.apache.logging.log4j.core.config.plugins.visitors.PluginBuilderAttributeVisitor.visit(PluginBuilderAttributeVisitor.java:49)
[err]   at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:185)
[err]   at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:121)
[err]   at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1002)
[err]   at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:942)
[err]   at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:934)
[err]   at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:552)
[err]   at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
[err]   at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:288)
[err]   at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:579)
[err]   at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:651)
[err]   at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:668)
[err]   at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
[err]   at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
[err]   at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
[err]   at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
[err]   at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:138)
[err]   at org.apache.logging.log4j.jcl.LogAdapter.getContext(LogAdapter.java:39)
[err]   at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:48)
[err]   at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:40)
[err]   at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:55)
[err]   at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
[err]   at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.<clinit>(StandardWebSocketHandlerAdapter.java:45)
[err]   at java.lang.Class.forName0(Native Method)
[err]   at java.lang.Class.forName(Class.java:348)
[err]   at com.ibm.ws.webcontainer.osgi.webapp.WebApp.addClassToHandlesTypesStartupSet(WebApp.java:1093)
[err]   at [internal classes]
[err]   at com.ibm.ws.webcontainer.osgi.WebContainer.access$000(WebContainer.java:110)
[err]   at com.ibm.ws.webcontainer.osgi.WebContainer$2.run(WebContainer.java:951)
@quaff
Copy link
Contributor Author

quaff commented Jul 20, 2020

Superseded by #25428

@quaff quaff closed this as completed Jul 20, 2020
@rstoyanchev rstoyanchev added status: superseded An issue that has been superseded by another and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 20, 2020
@jhoeller
Copy link
Contributor

Reopening it for a change towards a non-static logger field, as suggested on the PR.

@jhoeller jhoeller reopened this Jul 20, 2020
@jhoeller jhoeller changed the title Defer creating StandardWebSocketHandlerAdapter.logger to avoid early log4j2 initializing Defer creating logger in StandardWebSocketHandlerAdapter Jul 20, 2020
@jhoeller jhoeller self-assigned this Jul 20, 2020
@jhoeller jhoeller added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement and removed status: superseded An issue that has been superseded by another labels Jul 20, 2020
@jhoeller jhoeller added this to the 5.2.8 milestone Jul 20, 2020
@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.1.x labels Jul 20, 2020
jhoeller added a commit that referenced this issue Jul 20, 2020
jhoeller added a commit that referenced this issue Jul 20, 2020
jhoeller added a commit that referenced this issue Jul 20, 2020
FelixFly pushed a commit to FelixFly/spring-framework that referenced this issue Aug 16, 2020
zx20110729 pushed a commit to zx20110729/spring-framework that referenced this issue Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants