Forums de discussion

BundleException: … Unresolved requirement: Import-Package: com.test.demo

thumbnail
Ronny M.J. Diels, modifié il y a 7 années.

BundleException: … Unresolved requirement: Import-Package: com.test.demo

New Member Publications: 13 Date d'inscription: 20/01/17 Publications récentes
org.osgi.framework.BundleException: Could not resolve module … Unresolved requirement: Import-Package: com.test.demo
We are planning to migrate from Liferay 6 to Liferay 7.
The first job will (probably) be to move our portlets (which all extend LiferayPortlet within a WAR) to OSGi modules.
However our current portlets have dependencies to a large amount of JAR files (stored in the WAR's WEB-INF\lib) and it seems that we need to define all the required packages before we can deploy our first module. Otherwise we run into the “Unresolved requirement: Import-Package” problem at deploy time.

What is the best way to handle this?
Should we create a “library module” where we add each jar to the “Bundle-ClassPath” and then “Export-Package: *” (in the bundle bnd.bnd) to make all the packages visible for other modules in the Liferay workspace?
Is there an easier way to do this?
thumbnail
David H Nebinger, modifié il y a 7 années.

RE: BundleException: … Unresolved requirement: Import-Package: com.test.dem

Liferay Legend Publications: 14915 Date d'inscription: 02/09/06 Publications récentes
Eeek. Just don't do it.

Keep your portlet wars as-is. Deploy them using the Liferay deploy folder and it will convert into WABs for you.

All you have to do is migrate your JSP hooks, themes, etc for Liferay 7.
thumbnail
Ronny M.J. Diels, modifié il y a 7 années.

RE: BundleException: … Unresolved requirement: Import-Package: com.test.dem

New Member Publications: 13 Date d'inscription: 20/01/17 Publications récentes
Thanks!
We will give it a try. To be continued...
thumbnail
Ronny M.J. Diels, modifié il y a 7 années.

RE: BundleException: … Unresolved requirement: Import-Package: com.test.dem

New Member Publications: 13 Date d'inscription: 20/01/17 Publications récentes
I gave it a try.
At first sight all our legacy v6 portlets were deployed correctly (no errors - see log snippet below ).

However, I cannot find the deployed portlet categories in the "Add => Applications" section.
So I can't drag a portlet on the page to continue testing.
Any idea what could be the problem?

... startup
... hot deploy (verzekeringen-portlet-6.0.6.1.war => c:\_Ronny\dev\servers\liferay-ce-portal-7.0-ga3\deploy)
...
07:44:22,250 WARN [http-nio-8080-exec-2][code_jsp:181] {code="404", msg="/favicon.ico", uri=/favicon.ico}
07:47:46,388 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:252] Processing verzekeringen-portlet-6.0.6.1.war
07:48:01,875 INFO [fileinstall-C:/_Ronny/dev/servers/liferay-ce-portal-7.0-ga3/osgi/war][BaseAutoDeployListener:42] Copying portlets for c:\_Ronny\dev\servers\liferay-ce-portal-7.0-ga3\tomcat-8.0.32\temp\20170225074800927KIUXOREN\verzekeringen-portlet-6.0.6.1.war
07:48:02,150 INFO [fileinstall-C:/_Ronny/dev/servers/liferay-ce-portal-7.0-ga3/osgi/war][BaseDeployer:873] Deploying verzekeringen-portlet-6.0.6.1.war
07:49:14,290 INFO [fileinstall-C:/_Ronny/dev/servers/liferay-ce-portal-7.0-ga3/osgi/war][BaseAutoDeployListener:50] Portlets for c:\_Ronny\dev\servers\liferay-ce-portal-7.0-ga3\tomcat-8.0.32\temp\20170225074800927KIUXOREN\verzekeringen-portlet-6.0.6.1.war copied successfully
...
... shutdown
... startup
...
08:07:16,546 INFO [fileinstall-C:/_Ronny/dev/servers/liferay-ce-portal-7.0-ga3/osgi/war][BaseAutoDeployListener:42] Copying portlets for c:\_Ronny\dev\servers\liferay-ce-portal-7.0-ga3\tomcat-8.0.32\temp\20170225080713401DDWHUFKR\verzekeringen-portlet-6.0.6.1.war
08:07:17,336 INFO [fileinstall-C:/_Ronny/dev/servers/liferay-ce-portal-7.0-ga3/osgi/war][BaseDeployer:873] Deploying verzekeringen-portlet-6.0.6.1.war
08:07:29,298 DEBUG [elasticsearch[Frankie Raye][bulk][T#1]][index:156] took[3.5s], took_millis[3540], type[LiferayDocumentType], id[com_liferay_configuration_admin_web_portlet_SystemSettingsPortlet_PORTLET_com.liferay.portal.osgi.web.wab.extender.internal.configuration.WabExtenderConfiguration], routing[] , source[{"uid":"com_liferay_configuration_admin_web_portlet_SystemSettingsPortlet_PORTLET_com.liferay.portal.osgi.web.wab.extender.internal.configuration.WabExtenderConfiguration","companyId":"0","configurationModelId":"com.liferay.portal.osgi.web.wab.extender.internal.configuration.WabExtenderConfiguration","entryClassName":"com.liferay.configuration.admin.web.internal.model.ConfigurationModel","configurationModelFactoryPid":"com.liferay.portal.osgi.web.wab.extender.internal.configuration.WabExtenderConfiguration","title_zh_CN":"WABµë¬s¦òsÖ¿","title_es_ES":"Extensor WAB","title_ja_JP":"WAB Extender","title_iw_IL":"WAB Extender","title_nl_NL":"WAB-verlenger","title_fi_FI":"WAB Extender -laite","title_ca_ES":"Estensor WAB","title_hu_HU":"WAB b+æv+¡t+æ","title_fr_FR":"Extendeur WAB","title":"WAB Extender","title_en_US":"WAB Extender","title_pt_BR":"Extensor WAB","title_de_DE":"WAB Extender","configurationModelAttributeName":"Stop timeout"}]
08:08:50,048 INFO [fileinstall-C:/_Ronny/dev/servers/liferay-ce-portal-7.0-ga3/osgi/war][BaseAutoDeployListener:50] Portlets for c:\_Ronny\dev\servers\liferay-ce-portal-7.0-ga3\tomcat-8.0.32\temp\20170225080713401DDWHUFKR\verzekeringen-portlet-6.0.6.1.war copied successfully
...
thumbnail
David H Nebinger, modifié il y a 7 années.

RE: BundleException: … Unresolved requirement: Import-Package: com.test.dem

Liferay Legend Publications: 14915 Date d'inscription: 02/09/06 Publications récentes
You can't deploy 6.0.6 wars to Liferay 7.

You can, however, deploy Liferay 7 wars to Liferay 7. So you have to go through the portlet code and update it for Liferay 7 APIs. They would need to be in a Liferay 7 SDK and compiled w/ java 8 against the Liferay 7 libraries. If you're on 6.1 or 6.2, this tends to be a straight forward process to upgrade the SDK and then compile.

I didn't know you were so far behind the curve; it may actually be better to change the 6.0.6 portlet wars into Liferay 7 OSGi bundles instead because regardless which way you go, you're looking at a lot of work to get there.

Your original post about unresolved requirement, those are due to the bundle indicating it needs to import the com.test.demo package but no other deployed bundle is exporting the package. Therefore it is unresolved and the bundle will not be able to start. Getting all of your dependencies right can be a challenge coming into OSGi, but it gets easier as time goes on.
thumbnail
Ronny M.J. Diels, modifié il y a 7 années.

RE: BundleException: … Unresolved requirement: Import-Package: com.test.dem

New Member Publications: 13 Date d'inscription: 20/01/17 Publications récentes
It is indeed an upgrade from Liferay 6.0 to 7.0, since the previous team has never done the effort to upgrade to 6.1 or 6.2.
Now I'm facing a huge challenge. Moreover since I've started only a month ago on this project as a Liferay newbie.
So thanks for your help. Now I can share your feedback at our next status meeting here...
thumbnail
David H Nebinger, modifié il y a 7 années.

RE: BundleException: … Unresolved requirement: Import-Package: com.test.dem

Liferay Legend Publications: 14915 Date d'inscription: 02/09/06 Publications récentes
It's going to be a big upgrade task, but you don't have to face it alone.

Liferay offers consulting services and there are lots of Liferay partners with experience that can help you complete the upgrade.

Even if you did a rather narrow contract to let them handle some of the development, it could propel you closer to your final goal.
thumbnail
Ronny M.J. Diels, modifié il y a 7 années.

RE: BundleException: … Unresolved requirement: Import-Package: com.test.dem

New Member Publications: 13 Date d'inscription: 20/01/17 Publications récentes
Then I come back to my initial post ;-)
In was trying to build a proof-of-concept, but bumped into the problem that I have to define an enormous amount of dependencies in our first OSGi module.
To be able to proceed without having to do this, I tried to copy the required jar files for our portlets to liferay-ce-portal-7.0-ga3\tomcat-8.0.32\lib\ext\.
However, it seems that these jars are not in the classpath because I got the same exception (org.osgi.framework.BundleException: Could not resolve module … Unresolved requirement: Import-Package: com.test.demo).
Is OSGi so strict that it does not have the tomcat libs in its classpath?
thumbnail
David H Nebinger, modifié il y a 7 années.

RE: BundleException: … Unresolved requirement: Import-Package: com.test.dem

Liferay Legend Publications: 14915 Date d'inscription: 02/09/06 Publications récentes
Correct, the OSGi container is managed outside of the application container's class loader to prevent pollution from the app container's class loader.

Dependency management is tough to get right in OSGi for the new developer. Best recommendation I can make is to check out my 6-part blog on creating a DS service for Liferay. The key part in this is to create a "clean" interface/API module that has no dependencies and a separate implementation jar that has every dependency that is necessary for the code to work.

Other service consumers can go through the clean API and they do not inherit all of the transitive dependencies of the implementation module.

If you're not careful with your dependency management, you can quickly find that all of your modules start having a huge list of dependencies and transitive dependencies that need to be satisfied just for the bundle to resolve, and this kind of active management/development will quickly become the bane of your existence.

Isolating and encapsulating dependencies to single modules will make your life much easier and it will also force you into a "design by interface" pattern that works best in the OSGi environment.
thumbnail
Ronny M.J. Diels, modifié il y a 7 années.

RE: BundleException: … Unresolved requirement: Import-Package: com.test.dem

New Member Publications: 13 Date d'inscription: 20/01/17 Publications récentes
We would like to migrate our liferay 6.0 war projects to 7.0 war projects.
If we succeed, this would allow us to re-use much more of the current code, JSPs and configurations than in a pure OSGi scenario.
My ex-colleagues spent 8 years to build what we have now, so we should at least try this migration path first.
Now I am searching for documentation on how to do this within the Liferay IDE / workspace and a way to keep our webapp jars in WEB-INF\lib and to keep our database/mail/webservice configuration in the context.xml and server.xml files.
Could you help me with this?