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
RE: OSGI dude, overriding JournalArticleSitemapURLProvider
Hi!,
What is the correct way to override the JournalArticleSitemapURLProvider service to create a custom sitemap in direct web content?.
If I simply create a SitemapURLProvider service for the JournalArticle classname(*) it works when deployed the first time, but when the server is restarted, the service is registered first and the one that is treated is Liferay (JournalArticleSitemapUrlProvider). Even if a "service.ranking: Integer = 100" is added.
Curiously, if I do the same with a negative ranking, it seems to work correctly, but so a priori it seems to me that I am not doing the right thing
(*)
Regards,
What is the correct way to override the JournalArticleSitemapURLProvider service to create a custom sitemap in direct web content?.
If I simply create a SitemapURLProvider service for the JournalArticle classname(*) it works when deployed the first time, but when the server is restarted, the service is registered first and the one that is treated is Liferay (JournalArticleSitemapUrlProvider). Even if a "service.ranking: Integer = 100" is added.
Curiously, if I do the same with a negative ranking, it seems to work correctly, but so a priori it seems to me that I am not doing the right thing

(*)
@Component (immediate = true, service = SitemapURLProvider.class)
public class CustomJournalArticleSitemapUrlProvider implements SitemapURLProvider {
@Override
public String getClassName () {
return JournalArticle.class.getName ();
}
Regards,
Keep your component as is. Just add the Liferay component to the blacklist to prevent it from starting and taking your component's place.
It works correctly, thank you very much David!
I would like to ask you another question: What about "com.liferay.portal.util.LayoutSitemapURLProvider"? In this case there is no @Component annotation, instead there is an @OSGiBeanProperties and it cannot be added to the blacklist (or I don't know how to). On the other hand, the unorthodox solution of the negative ranking seems to continue working, is there a more correct solution?. Thank you very much in advance.
Regards.
I would like to ask you another question: What about "com.liferay.portal.util.LayoutSitemapURLProvider"? In this case there is no @Component annotation, instead there is an @OSGiBeanProperties and it cannot be added to the blacklist (or I don't know how to). On the other hand, the unorthodox solution of the negative ranking seems to continue working, is there a more correct solution?. Thank you very much in advance.
Regards.
Javier Lamadrid:
What about "com.liferay.portal.util.LayoutSitemapURLProvider"?
It's injected via layout-spring.xml, so it ends up being part of the system bundle 0, which is probably not compatible with the way Liferay implemented component blacklists (from reading the code, it seems like it watches for non-system bundle start events, though I could be wrong).
As a workaround, you could add a custom layout-spring.xml to Liferay's WEB-INF/classes/META-INF that comments out the reference to the class so that no Spring bean gets created (and thus no OSGi component gets injected once the portal is initialized). In the future (7.3 and beyond), it should be possible to blacklist it because it's moved outside of system bundle 0 with LPS-97978.
I check it, thank you very much Minhchau!
Regards
Regards
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™