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

org.apache.logging.log4j.core.LoggerContext cannot be cast to de.hybris.platform.util.logging.log4j2.HybrisLoggerContext #11

Open
TONYHOKAN opened this issue Apr 4, 2020 · 3 comments

Comments

@TONYHOKAN
Copy link

Thanks for you sample about to use Hikari connection pool.

I am trying your sample to integrate with our code, which is hybris 1811 upgrade from 5.2 so bundle with many legacy code like logger is using log4j.

During server startup HybrisStorefrontContextLoaderListener throw exception:
Any idea how to fix?

ront.filters.HybrisStorefrontContextLoaderListener]
java.lang.ExceptionInInitializerError
        at de.hybris.platform.core.ClassLoaderUtils.executeWithWebClassLoaderParentIfNeeded(ClassLoaderUtils.java:42)
        at de.hybris.platform.spring.HybrisContextLoaderListener.startRegistry(HybrisContextLoaderListener.java:325)
        at de.hybris.platform.spring.HybrisContextLoaderListener.doInitWebApplicationContext(HybrisContextLoaderListener.java:211)
        at de.hybris.platform.spring.HybrisContextLoaderListener.initWebApplicationContext(HybrisContextLoaderListener.java:199)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
        at de.hybris.platform.spring.HybrisContextLoaderListener.contextInitialized(HybrisContextLoaderListener.java:95)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4792)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassCastException: org.apache.logging.log4j.core.LoggerContext cannot be cast to de.hybris.platform.util.logging.log4j2.HybrisLoggerContext
        at de.hybris.platform.util.logging.HybrisLogger.setLevel(HybrisLogger.java:512)
        at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:753)
        at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:672)
        at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)
        at de.hybris.platform.core.Log4JUtils.readConfig(Log4JUtils.java:103)
        at de.hybris.platform.core.Log4JUtils.startup(Log4JUtils.java:56)
        at de.hybris.platform.core.Registry.lambda$0(Registry.java:81)
        at de.hybris.platform.core.ClassLoaderUtils.executeWithWebClassLoaderParentIfNeeded(ClassLoaderUtils.java:42)
        at de.hybris.platform.core.Registry.<clinit>(Registry.java:79)
        ... 15 more

Apr 04, 2020 5:18:16 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
Apr 04, 2020 5:18:16 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors
@ppodgorsek
Copy link
Owner

Hi @TONYHOKAN ,

Here is a link to the official SAP Help documentation which might help you with the transition from log4j to log4j2:
https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/1811/en-US/42d818c7bac44eed9ab01757472b9dbc.html?q=log4j2

The switch was done in the Commerce platform a few years back.

Btw, is there a reason to upgrade to 1811 instead of the latest 1905?

@TONYHOKAN
Copy link
Author

Hi @ppodgorsek

As you see we have many legacy dependency and when we start planing upgrade, 1811 is latest version so all test plan only cover 1811.

For the log4j2 doc, that suggests

It is not necessary to change the existing code that uses the Log4j API because all logs are redirected to Log4j 2.
so we just keep all old log4 logger and work fine until now.

i just think will this work if remove all log4 jar dependency but the doc do not cover more about totally remove old log4 jar.

@ppodgorsek
Copy link
Owner

Hi @TONYHOKAN ,
Could you check where the org.apache.logging.log4j.core.LoggerContext is being used in your code/configuration please?
The log4j JAR should only be in the platform folder but maybe Hybris 5.2 was still including such JARs in the custom extensions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants