Legacy Knowledge Base
Published Sep. 10, 2025

Resolving 'BadPaddingExceptions' in the Console Logs

Written By

Justin Choi

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

This article addresses a situation where customers might encounter a BadPaddingException in the logs. This occurs if customers have two instances on the same domain; when a user tries to access another instance on the same domain, the exception will be thrown.

2018-05-31 03:10:32.353 WARN  [http-nio-8443-exec-30][RememberMeAutoLogin:52] com.liferay.portal.kernel.exception.SystemException: com.liferay.petra.encryptor.EncryptorException: com.liferay.petra.encryptor.EncryptorException: javax.crypto.BadPaddingException: Given final block not properly padded
com.liferay.portal.kernel.exception.SystemException: com.liferay.petra.encryptor.EncryptorException: com.liferay.petra.encryptor.EncryptorException: javax.crypto.BadPaddingException: Given final block not properly padded
       at com.liferay.portal.service.impl.UserLocalServiceImpl.decryptUserId(UserLocalServiceImpl.java:1775)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:163)
       at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:54)
       at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:58)
       at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:137)
       at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
       at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:137)
       at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:169)
       at com.sun.proxy.$Proxy121.decryptUserId(Unknown Source)
       at com.liferay.portal.security.auto.login.remember.me.RememberMeAutoLogin.doLogin(RememberMeAutoLogin.java:98)
       at com.liferay.portal.kernel.security.auto.login.BaseAutoLogin.login(BaseAutoLogin.java:50)
       at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:195)
       at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
       at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
       at com.liferay.portal.monitoring.internal.servlet.filter.MonitoringFilter.processFilter(MonitoringFilter.java:181)
       at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:100)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:720)
       at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466)
       at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
       at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
       at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:372)
       at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
       at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
       at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
       at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
       at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
       at com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:65)
       at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
       at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:100)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
       at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
       at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
       at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
       at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
       at java.lang.Thread.run(Thread.java:748)
Caused by: com.liferay.petra.encryptor.EncryptorException: com.liferay.petra.encryptor.EncryptorException: javax.crypto.BadPaddingException: Given final block not properly padded
       at com.liferay.petra.encryptor.Encryptor.decryptUnencodedAsString(Encryptor.java:115)
       at com.liferay.petra.encryptor.Encryptor.decrypt(Encryptor.java:73)
       at com.liferay.portal.service.impl.UserLocalServiceImpl.decryptUserId(UserLocalServiceImpl.java:1772)
       ... 71 more
Caused by: com.liferay.petra.encryptor.EncryptorException: javax.crypto.BadPaddingException: Given final block not properly padded
       at com.liferay.petra.encryptor.Encryptor.decryptUnencodedAsBytes(Encryptor.java:100)
       at com.liferay.petra.encryptor.Encryptor.decryptUnencodedAsString(Encryptor.java:109)
       ... 73 more
Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
       at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:989)
       at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:845)
       at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446)
       at javax.crypto.Cipher.doFinal(Cipher.java:2165)
       at com.liferay.petra.encryptor.Encryptor.decryptUnencodedAsBytes(Encryptor.java:96)
       ... 74 more
2018-05-31 03:10:32.362 ERROR [http-nio-8443-exec-30][AutoLoginFilter:255] Current URL /search?q=plumbing generates exception: com.liferay.portal.kernel.exception.SystemException: com.liferay.petra.encryptor.EncryptorException: com.liferay.petra.encryptor.EncryptorException: javax.crypto.BadPaddingException: Given final block not properly padded

	

Resolution

To resolve this issue, set the property session.cookie.use.full.hostname=true in the portal-ext.properties file.

As a best practice, administrators should never modify the portal.properties file directly, but create a separate portal-ext.properties file instead.

Did this article resolve your issue ?

Legacy Knowledge Base