Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
How to override a Liferay JAVA class effectively?
Hello, I am trying to override the "OpenIdConnectServiceHandlerImpl .java" class in order to make changes.
When deploying my override jar, I have the following error:
So each time a dependency is missing and I face this error, I add the name of the .jar archive in the bnd.bnd file, then I redeploy the module. I no longer have the error, but another one appears ... The same error, but concerning another dependency, and so on ... I am at the 20th archive listed in the file bnd.bnd. And I don't know how many are needed, but it can last a long time if it's a hundred ...
It is really a heavy and long process. Isn't there another way to deal with this error? A simpler and less time consuming way?We are working on version 7.2.1 GA2
Thanks for your help
When deploying my override jar, I have the following error:
2020-02-12 16:50:32.588 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:259] Processing auth-sso-0.0.1.jar
2020-02-12 16:50:38.531 ERROR [fileinstall-/opt/liferay/osgi/modules][LogService:93] Error while starting bundle: file:/opt/liferay/osgi/modules/auth-sso-0.0.1.jar
org.osgi.framework.BundleException: Could not resolve module: com.agrial [1161]_ Unresolved requirement: Import-Package: net.jcip.annotations_ [Sanitized]
at org.eclipse.osgi.container.Module.start(Module.java:444)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1275)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1248)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316)
So each time a dependency is missing and I face this error, I add the name of the .jar archive in the bnd.bnd file, then I redeploy the module. I no longer have the error, but another one appears ... The same error, but concerning another dependency, and so on ... I am at the 20th archive listed in the file bnd.bnd. And I don't know how many are needed, but it can last a long time if it's a hundred ...
It is really a heavy and long process. Isn't there another way to deal with this error? A simpler and less time consuming way?We are working on version 7.2.1 GA2
Thanks for your help
Axel LEFEVRE:
HOW you do that depends on the dependencies that you introduce in your module and the final size that you'd like your module to have.
Hello, I am trying to override the "OpenIdConnectServiceHandlerImpl .java" class in order to make changes.
When deploying my override jar, I have the following error:
...
It is really a heavy and long process. Isn't there another way to deal with this error? A simpler and less time consuming way?We are working on version 7.2.1 GA2
Well, you can't deploy new code without either bringing along its dependencies, or deploying them to the system.
You can have a look at David's blog article on some gradle options. The free OSGi Basics lesson on Liferay University contains a chapter "Bringing along Dependencies" where I'm still fond of the illustrating animation, but wish that the video wasn't edited right with it

If the dependencies are all OSGi bundles, there's no need to rebuild your plugin. You can just drop them into Liferay's deploy folder until the dependencies are all met, then your plugin will start automagically. And later plugins will be able to use exactly the same libraries, as they're already there.
Maybe the "better" way would be to check if you really need those imports. If you do not need these directly in your custom classes you may want to try to exclude the imports in the bnd.bnd file.
Speaking of overwriting the OpenIdConnectServiceHandlerImpl class here is what my bnd.bnd file looked like in a similar project:
Speaking of overwriting the OpenIdConnectServiceHandlerImpl class here is what my bnd.bnd file looked like in a similar project:
Import-Package: \
!com.google.crypto.tink.subtle,\
!org.bouncycastle.asn1,\
!org.bouncycastle.asn1.pkcs,\
!org.bouncycastle.asn1.x509,\
!org.bouncycastle.cert,\
!org.bouncycastle.cert.jcajce,\
!org.bouncycastle.crypto,\
!org.bouncycastle.crypto.engines,\
!org.bouncycastle.crypto.modes,\
!org.bouncycastle.crypto.params,\
!org.bouncycastle.openssl,\
!org.bouncycastle.openssl.jcajce,\
!org.cryptomator.siv,\
!com.sun.mail.util,\
*
Maybe it helps.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™