Using Apache Felix Web-console

Find all the packages that are exported by the Liferay portal

I'm recently faced with a challenge of understanding all the packages that are exported by the Liferay portal. Liferay  comes with a lot of inbuilt OSGI modules and it is quite difficult to find all the packages exported by all of the modules. 

Here's a little background about my challenge: 

I never knew that the package "com.fasterxml.jackson.core" is being exported by default by the Liferay portal. So I included and resolved them in my project using the available resources and blogs:

https://liferay.dev/blogs/-/blogs/osgi-module-dependencies

https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/adding-third-party-libraries-to-a-module

https://portal.liferay.dev/docs/7-0/reference/-/knowledge_base/r/third-party-packages-portal-exports

But chances are very likely that it would be nice to know all the packages exported by the Liferay portal. I don't want to include `Jackson-core` and `Jackson-annotations` to the classpath of my module, when they were already being exported by Liferay. 

Right now, there is no solid way of knowing all the packages that are being exported by Liferay. Here's my workaround. Hope it helps out you too. 

Workaround: 

1) Install org.apache.felix.webconsole-4.3.4.jar to the OSGI container. You can download it here:

https://repo1.maven.org/maven2/org/apache/felix/org.apache.felix.webconsole/4.3.4/org.apache.felix.webconsole-4.3.4.jar

(Copy this jar into the LIFERAY_HOME/deploy directory)

2) Go to localhost:8080/o/system/console (username and password being `admin`, `admin`). Click the tab `bundles`. 

3) Go to developer tools (I used Google-chrome). Open console, paste the following snippet and hit enter (jQuery is being loaded automatically, you can always double check it in the network tab):

$('.ui-icon-triangle-1-e').click()

4) Press `End` button of your keyboard. It should take you to the bottom of the screen. Scroll up and down for a couple of times, so that  jQuery has worked on clicking all the elements in the table. It should take a while (It's a 1000+ rows). Copy and paste the contents of your browser in a text-pad of your choice. (I'm using visual-studio code, with language-mode `log`). Moving forward, you can use this as a reference, if you have a question about including a package from third-party library on your modules classpath (Make sure that the package you are including is not in the Export-Package of any of the modules in the text-file you copied). I'll post my version of text file here in a while. 

 

Blogs

Actually the Target Platform does offer a way to identify what Liferay provides vs what it doesn't.

 

 

 

If you leave version off of your dependencies, a build will succeed when Liferay has the dependency as an export, but you'll get an error for those that are not provided.

 

 

 

In this way you can kind of tell if something was exposed or not without having to track them down in the portal manually.

 

 

 

I do like the idea of using the web console in Liferay. Gogo is fine once you learn the commands, but sometimes having a nice GUI to help navigate all of the various OSGi information can be tough.

I'm migrating portlets from 6.x to 7.x. IMO it'll be a tough one to do without knowing what all packages Liferay is exporting out of box. 

Especially, I need to convert my service builders to OSGI, and they use a lot of third-party libraries.