diff --git a/.mvn/maven-build-cache-config.xml b/.mvn/maven-build-cache-config.xml index 77e235f74b92..6aed72f588ae 100644 --- a/.mvn/maven-build-cache-config.xml +++ b/.mvn/maven-build-cache-config.xml @@ -12,7 +12,7 @@ https://maven.apache.org/extensions/maven-build-cache-extension/maven-build-cach xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0 https://maven.apache.org/xsd/build-cache-config-1.0.0.xsd"> - true + false SHA-256 true diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 312d8f280d6e..1eae80e3ca5f 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -1433,6 +1433,13 @@ + + com.dotcms + tomcat-redis-session-manager + 1.3 + provided + + org.apache.tomcat diff --git a/bom/logging/pom.xml b/bom/logging/pom.xml index 333f10810332..fb2d98a93f0a 100644 --- a/bom/logging/pom.xml +++ b/bom/logging/pom.xml @@ -15,8 +15,8 @@ false bom - 2.20.0 - 2.0.7 + 2.23.1 + 2.0.9 @@ -27,30 +27,42 @@ Do not include incompatible artifacts e.g. --> org.apache.logging.log4j - log4j-core + log4j-api ${log4j.version} compile org.apache.logging.log4j - log4j-1.2-api + log4j-iostreams + ${log4j.version} + + + org.apache.logging.log4j + log4j-core ${log4j.version} compile + + + org.apache.logging.log4j + log4j-1.2-api + ${log4j.version} + runtime + org.apache.logging.log4j log4j-jcl ${log4j.version} - compile + runtime org.apache.logging.log4j log4j-slf4j2-impl ${log4j.version} - compile + runtime org.slf4j @@ -61,16 +73,16 @@ org.apache.logging.log4j - log4j-web + log4j-appserver ${log4j.version} - compile + runtime com.lmax disruptor 3.3.4 - compile + runtime diff --git a/dotCMS/pom.xml b/dotCMS/pom.xml index 143d68ffaf9d..f7fa0c97edfd 100644 --- a/dotCMS/pom.xml +++ b/dotCMS/pom.xml @@ -15,8 +15,6 @@ 2.29.0 ${project.basedir}/src/main/java ${project.basedir}/src/test/java - 2.36.0 - 1.16 0.14.1 1.10.6 ${basedir}/target/dist @@ -27,6 +25,8 @@ true dotserver/tomcat-${tomcat.version} ${assembly-directory}/${tomcat-dist-folder}/lib + ${assembly-directory}/${tomcat-dist-folder}/log4j2/lib + ${assembly-directory}/${tomcat-dist-folder}/session-manager/lib ${project.basedir}/src/main/resources/container/tomcat9 ${assembly-directory}/${tomcat-dist-folder}/webapps/ROOT ${project.build.directory}/${project.build.finalName}-war.war @@ -63,10 +63,6 @@ felix/core/undeployed felix/system/undeployed - 1.3 - 2.11.1 - 1.7.36 - 4.4.6 ${project.build.directory}/tomcat-run-data/${context.name} false @@ -88,6 +84,11 @@ zip provided + + com.dotcms + tomcat-redis-session-manager + provided + com.dotcms.plugins dotcms-system-bundles @@ -1351,21 +1352,30 @@ org.apache.logging.log4j log4j-jcl + runtime - + org.apache.logging.log4j - log4j-slf4j2-impl + log4j-jcl + runtime - + org.slf4j + slf4j-api + compile + + + org.apache.logging.log4j - log4j-web + log4j-appserver + provided com.lmax disruptor + runtime @@ -1402,6 +1412,12 @@ + + org.apache.tomcat + tomcat-catalina + ${tomcat.version} + provided + @@ -1535,37 +1551,69 @@ - com.dotcms - tomcat-redis-session-manager - ${tomcat.redis-session-manager.version} + org.apache.logging.log4j + log4j-api jar - true - ${tomcat-lib-folder} + false + ${tomcat-log4j-lib-folder} - org.apache.commons - commons-pool2 - ${commons-pool2.version} + org.apache.logging.log4j + log4j-core jar - true - ${tomcat-lib-folder} + false + ${tomcat-log4j-lib-folder} + + + org.apache.logging.log4j + log4j-appserver + jar + false + ${tomcat-log4j-lib-folder} + + + org.apache.logging.log4j + log4j-slf4j2-impl + jar + false + ${tomcat-log4j-lib-folder} org.slf4j slf4j-api - ${org.slfj4.version} + jar + false + ${tomcat-log4j-lib-folder} + + + com.dotcms + tomcat-redis-session-manager jar true - ${tomcat-lib-folder} + ${session-manager-lib-folder} + + + org.apache.commons + commons-pool2 + jar + true + ${session-manager-lib-folder} redis.clients jedis - ${jedis.version} jar true - ${tomcat-lib-folder} + ${session-manager-lib-folder} + + + + com.lmax + disruptor + true + ${tomcat-log4j-lib-folder} + @@ -1913,12 +1961,6 @@ ${tomcat9-overrides}/bin/setenv.sh bin - ${tomcat9-overrides}/conf/server.xml conf diff --git a/dotCMS/src/main/java/com/dotcms/business/bytebuddy/ByteBuddyFactory.java b/dotCMS/src/main/java/com/dotcms/business/bytebuddy/ByteBuddyFactory.java index f27bbf3fe8ce..93ee80d3ed3b 100644 --- a/dotCMS/src/main/java/com/dotcms/business/bytebuddy/ByteBuddyFactory.java +++ b/dotCMS/src/main/java/com/dotcms/business/bytebuddy/ByteBuddyFactory.java @@ -5,7 +5,6 @@ import com.dotcms.business.WrapInTransaction; import com.dotcms.util.EnterpriseFeature; import com.dotcms.util.LogTime; -import com.dotmarketing.util.Logger; import net.bytebuddy.agent.ByteBuddyAgent; import net.bytebuddy.agent.builder.AgentBuilder; import net.bytebuddy.asm.Advice; @@ -23,6 +22,8 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import static net.bytebuddy.matcher.ElementMatchers.declaresMethod; import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith; @@ -39,6 +40,9 @@ */ public class ByteBuddyFactory { + // Use base log4j logger here to prevent recursive issues with internal Logger class + private static final Logger LOGGER = LogManager.getLogger(ByteBuddyFactory.class); + private static final AtomicBoolean agentLoaded = new AtomicBoolean(false); private static final Map, Class> adviceMap = Map.of( WrapInTransaction.class, WrapInTransactionAdvice.class, @@ -69,16 +73,16 @@ public static void init() { if (!agentLoaded.get()) { try { premain(null, ByteBuddyAgent.install()); - Logger.info(ByteBuddyFactory.class, "Loaded ByteBuddy Advice"); + LOGGER.info("Loaded ByteBuddy Advice"); } catch (Exception e) { - Logger.error(ByteBuddyFactory.class, "Cannot install ByteBuddy Advice"); + LOGGER.error("Cannot install ByteBuddy Advice"); } } } public static void premain(final String arg, final Instrumentation inst) throws Exception { - Logger.info(ByteBuddyFactory.class, "Starting ByteBuddy Agent"); + LOGGER.info("Starting ByteBuddy Agent"); if (!agentLoaded.compareAndSet(false, true)) { return; } @@ -122,9 +126,9 @@ public ClassFileLocator classFileLocator(final ClassLoader classLoader, final Ja }) .installOn(inst); - Logger.info(ByteBuddyFactory.class, "ByteBuddy Initialized"); + LOGGER.info("ByteBuddy Initialized"); } catch (Exception e) { - Logger.error(ByteBuddyFactory.class, "Error Initializing ByteBuddy", e); + LOGGER.error("Error Initializing ByteBuddy", e); } diff --git a/dotCMS/src/main/java/com/dotmarketing/listeners/ContextLifecycleListener.java b/dotCMS/src/main/java/com/dotmarketing/listeners/ContextLifecycleListener.java index 431664eefd32..0cf3775d0d0c 100644 --- a/dotCMS/src/main/java/com/dotmarketing/listeners/ContextLifecycleListener.java +++ b/dotCMS/src/main/java/com/dotmarketing/listeners/ContextLifecycleListener.java @@ -7,10 +7,8 @@ import com.dotcms.util.AsciiArt; import com.dotmarketing.business.CacheLocator; import com.dotmarketing.common.reindex.ReindexThread; -import com.dotmarketing.loggers.Log4jUtil; import com.dotmarketing.quartz.QuartzUtils; import com.dotmarketing.util.Config; -import com.dotmarketing.util.ConfigUtils; import com.dotmarketing.util.Logger; import io.vavr.control.Try; @@ -18,7 +16,6 @@ import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.websocket.server.ServerContainer; -import java.io.File; /** * @@ -62,25 +59,6 @@ public void contextInitialized(ServletContextEvent arg0) { Config.setMyApp(arg0.getServletContext()); - - String path = null; - try { - - String contextPath = Config.CONTEXT.getRealPath("/"); - if ( !contextPath.endsWith( File.separator ) ) { - contextPath += File.separator; - } - File file = new File(contextPath + "WEB-INF" + File.separator + "log4j" + File.separator + "log4j2.xml"); - path = file.toURI().toString(); - - } catch (Exception e) { - Logger.error(this,e.getMessage(),e); - } - - //Initialises/reconfigures log4j based on a given log4j configuration file - Log4jUtil.initializeFromPath(path); - - installWebSocket(arg0.getServletContext()); } diff --git a/dotCMS/src/main/java/com/dotmarketing/loggers/Log4jUtil.java b/dotCMS/src/main/java/com/dotmarketing/loggers/Log4jUtil.java index ac941ba8604d..61d44a6929fd 100644 --- a/dotCMS/src/main/java/com/dotmarketing/loggers/Log4jUtil.java +++ b/dotCMS/src/main/java/com/dotmarketing/loggers/Log4jUtil.java @@ -27,15 +27,6 @@ public class Log4jUtil { private final static String LOG4J_CONTEXT_SELECTOR = "Log4jContextSelector"; - /** - * Configure default system properties - */ - public static void configureDefaultSystemProperties () { - if(!UtilMethods.isSet(System.getProperty(LOG4J_CONTEXT_SELECTOR))) { - System.setProperty(LOG4J_CONTEXT_SELECTOR, "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); - } - } - /** * Creates a ConsoleAppender in order to add it to the root logger */ @@ -128,33 +119,6 @@ public static void shutdown(LoggerContext context) { Configurator.shutdown(context); } - /** - * Initialises/reconfigures log4j based on a given log4j configuration file - * - * @param log4jConfigFilePath - */ - public static void initializeFromPath ( String log4jConfigFilePath ) { - - if ( log4jConfigFilePath != null ) { - - try { - - configureDefaultSystemProperties(); - LoggerContext loggerContext = (LoggerContext) LogManager.getContext(false); - - if ( !loggerContext.isInitialized() || loggerContext.isStopped() ) { - Configurator.initialize(null, log4jConfigFilePath); - } else { - loggerContext.setConfigLocation(URI.create(log4jConfigFilePath)); - loggerContext.reconfigure(); - } - } catch ( Exception e ) { - LogManager.getLogger().error("Error initializing log for " + log4jConfigFilePath + " configuration file.", e); - } - LogManager.getLogger().info("Async Logger enabled: "+ AsyncLoggerContextSelector.isSelected()); - } - } - /** * Returns the current dotCMS logger context * diff --git a/dotCMS/src/main/java/com/dotmarketing/util/Logger.java b/dotCMS/src/main/java/com/dotmarketing/util/Logger.java index b71305280cad..6a26004ce18b 100644 --- a/dotCMS/src/main/java/com/dotmarketing/util/Logger.java +++ b/dotCMS/src/main/java/com/dotmarketing/util/Logger.java @@ -6,19 +6,13 @@ package com.dotmarketing.util; import java.io.File; -import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; -import com.dotcms.api.system.event.Payload; -import com.dotcms.api.system.event.SystemEventType; -import com.dotcms.rest.ResponseEntityView; import com.dotcms.rest.api.v1.system.logger.ChangeLoggerLevelEvent; -import com.dotcms.rest.api.v1.system.logger.LoggerView; -import com.dotmarketing.business.APILocator; import com.liferay.util.StringPool; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; @@ -26,7 +20,6 @@ import org.apache.velocity.tools.view.tools.ViewTool; import com.dotcms.business.expiring.ExpiringMap; import com.dotcms.business.expiring.ExpiringMapBuilder; -import com.dotmarketing.loggers.Log4jUtil; import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.RemovalCause; @@ -35,17 +28,11 @@ import io.vavr.Lazy; import io.vavr.control.Try; -import javax.ws.rs.core.Response; - /** * @author David Torres */ public class Logger { - static { - Log4jUtil.configureDefaultSystemProperties(); - } - /** * Caffeine Cache is going to be much more performant concurrently than a hashmap */ diff --git a/dotCMS/src/main/resources/container/tomcat9/bin/setenv.bat b/dotCMS/src/main/resources/container/tomcat9/bin/setenv.bat index 11db0ce193ff..907b1ad54e3d 100644 --- a/dotCMS/src/main/resources/container/tomcat9/bin/setenv.bat +++ b/dotCMS/src/main/resources/container/tomcat9/bin/setenv.bat @@ -1,5 +1,6 @@ @echo off +rem Set CATALINA_OPTS with multiple options set "CATALINA_OPTS=%CATALINA_OPTS% -Dfile.encoding=UTF8" set "CATALINA_OPTS=%CATALINA_OPTS% --illegal-access=deny" set "CATALINA_OPTS=%CATALINA_OPTS% --add-opens java.base/java.lang=ALL-UNNAMED" @@ -26,4 +27,33 @@ set "CATALINA_OPTS=%CATALINA_OPTS% --add-opens java.base/sun.util.locale=ALL-UNN set "CATALINA_OPTS=%CATALINA_OPTS% -Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl" set "CATALINA_OPTS=%CATALINA_OPTS% -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl" set "CATALINA_OPTS=%CATALINA_OPTS% -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl" -set "CATALINA_OPTS=%CATALINA_OPTS% -Dorg.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.EnvironmentPropertySource" \ No newline at end of file +set "CATALINA_OPTS=%CATALINA_OPTS% -Dorg.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.EnvironmentPropertySource" + + +rem Check if log4j2.configurationFile is already set +echo %CATALINA_OPTS% | findstr /C:"-Dlog4j2.configurationFile" >nul +if %errorlevel% neq 0 ( + echo Setting log4j2.configurationFile=%TOMCAT_HOME%\webapps\ROOT\WEB-INF\log4j\log4j2.xml + set "CATALINA_OPTS=%CATALINA_OPTS% -Dlog4j2.configurationFile=%TOMCAT_HOME%\webapps\ROOT\WEB-INF\log4j\log4j2.xml" +) else ( + echo Log4j configuration already set +) + +rem Check if Log4jContextSelector is already set +echo %CATALINA_OPTS% | findstr /C:"-DLog4jContextSelector" >nul +if %errorlevel% neq 0 ( + echo Setting Log4jContextSelector to org.apache.logging.log4j.core.async.BasicAsyncLoggerContextSelector + set "CATALINA_OPTS=%CATALINA_OPTS% -DLog4jContextSelector=org.apache.logging.log4j.core.async.BasicAsyncLoggerContextSelector" +) else ( + echo Log4jContextSelector already set +) + +rem Set the CLASSPATH +set "ADDITIONAL_CLASSPATH=%CATALINA_HOME%\log4j2\lib\*;%CATALINA_HOME%\session-manager\lib\*" +if "%CLASSPATH%" neq "" ( + set "CLASSPATH=%CLASSPATH%;%ADDITIONAL_CLASSPATH%" +) else ( + set "CLASSPATH=%ADDITIONAL_CLASSPATH%" +) + +set CLASSPATH \ No newline at end of file diff --git a/dotCMS/src/main/resources/container/tomcat9/bin/setenv.sh b/dotCMS/src/main/resources/container/tomcat9/bin/setenv.sh index 664f84a73b82..1d6d02d4ad80 100644 --- a/dotCMS/src/main/resources/container/tomcat9/bin/setenv.sh +++ b/dotCMS/src/main/resources/container/tomcat9/bin/setenv.sh @@ -1,3 +1,5 @@ +#!/bin/sh + export CATALINA_OPTS="$CATALINA_OPTS -Dfile.encoding=UTF8" export CATALINA_OPTS="$CATALINA_OPTS --illegal-access=deny" export CATALINA_OPTS="$CATALINA_OPTS --add-opens java.base/java.lang=ALL-UNNAMED" @@ -27,3 +29,29 @@ export CATALINA_OPTS="$CATALINA_OPTS -Djavax.xml.transform.TransformerFactory=co export CATALINA_OPTS="$CATALINA_OPTS -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl" export CATALINA_OPTS="$CATALINA_OPTS -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl" export CATALINA_OPTS="$CATALINA_OPTS -Dorg.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.EnvironmentPropertySource" + + +if echo "$CATALINA_OPTS" | grep -q '\-Dlog4j2\.configurationFile'; then + echo "Log4j configuration already set" +else + echo "Setting log4j2.configurationFile=$TOMCAT_HOME/webapps/ROOT/WEB-INF/log4j/log4j2.xml" + export CATALINA_OPTS="$CATALINA_OPTS -Dlog4j2.configurationFile=$TOMCAT_HOME/webapps/ROOT/WEB-INF/log4j/log4j2.xml" +fi + +if echo "$CATALINA_OPTS" | grep -q '\-DLog4jContextSelector'; then + echo "Log4jContextSelector already set" +else + echo "Setting Log4jContextSelector to org.apache.logging.log4j.core.async.BasicAsyncLoggerContextSelector" + export CATALINA_OPTS="$CATALINA_OPTS -DLog4jContextSelector=org.apache.logging.log4j.core.async.BasicAsyncLoggerContextSelector" +fi + +ADDITIONAL_CLASSPATH="$CATALINA_HOME/log4j2/lib/*:$CATALINA_HOME/session-manager/lib/*" + +if [ -n "$CLASSPATH" ]; then + CLASSPATH="$CLASSPATH:$ADDITIONAL_CLASSPATH" +else + CLASSPATH="$ADDITIONAL_CLASSPATH" +fi + +export CLASSPATH + diff --git a/dotCMS/src/main/resources/log4j.properties b/dotCMS/src/main/resources/log4j.properties deleted file mode 100644 index 2eb14485eebe..000000000000 --- a/dotCMS/src/main/resources/log4j.properties +++ /dev/null @@ -1,4 +0,0 @@ -##This is NOT the file where logging should be configured. You should config in the WEB-INF/log4j -log4j.rootLogger=INFO, CONSOLE -log4j.appender.CONSOLE=org.apache.logging.log4j.core.appender.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.logging.log4j.core.layout.XmlLayout diff --git a/dotcms-integration/ant-tasks.xml b/dotcms-integration/ant-tasks.xml index 6e459d3222ab..3d446dc46809 100644 --- a/dotcms-integration/ant-tasks.xml +++ b/dotcms-integration/ant-tasks.xml @@ -10,7 +10,7 @@ - + @@ -72,7 +72,7 @@ - + diff --git a/dotcms-postman/pom.xml b/dotcms-postman/pom.xml index 57c26cd6d645..8957e0ff6835 100644 --- a/dotcms-postman/pom.xml +++ b/dotcms-postman/pom.xml @@ -113,7 +113,7 @@ - WireMock: + [WireMock] green diff --git a/parent/pom.xml b/parent/pom.xml index be41efd3b0bd..2c94adbf8d21 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -306,7 +306,7 @@ listening on IPv4 address "0.0.0.0", port 5432 - DB: + [DB] magenta @@ -345,7 +345,7 @@ 5000 - ES: + [ES] cyan @@ -392,7 +392,7 @@ opensearch:es - DOTCMS: + [DOTCMS] cyan @@ -708,6 +708,13 @@ false + + + org.apache.maven.surefire + surefire-junit47 + ${version.failsafe.plugin} + + org.apache.maven.plugins @@ -861,6 +868,13 @@ true + + + org.apache.maven.surefire + surefire-junit47 + ${version.surefire.plugin} + + org.apache.maven.plugins