Foren

Liferay 7 CE ga2 OSGI read portlet .properties file

thumbnail
Mohammad Azharuddin, geändert vor 7 Jahren.

Liferay 7 CE ga2 OSGI read portlet .properties file

Expert Beiträge: 492 Beitrittsdatum: 17.09.12 Neueste Beiträge
HI All
I am using Liferay 7 CE ga2
I am trying to read portlet.properties file in my custom OSGI module. I have added below dependency in my build.gradle file

build.gradle file
dependencies {
compile group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
compile group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
compile group: "javax.portlet", name: "portlet-api", version: "2.0"
compile group: "javax.servlet", name: "servlet-api", version: "2.5"
compile group: "org.osgi", name: "org.osgi.compendium", version: "5.0.0"
compile group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "3.1.0"
compile group: "com.liferay.portal", name: "com.liferay.util.java", version: "2.0.0"

}


and bnd.bnd file as shown


Bundle-SymbolicName: webform
Bundle-Version: 1.0.0
-metatype: *
-check: all


I am trying to read property using below code
String value = com.liferay.util.portlet.PortletProps.get("key");

It resolves during compile time but But during run time i am getting below error

org.osgi.framework.BundleException: Could not resolve module: webform [514]_ Unresolved requirement: Import-Package: com.liferay.util.portlet; version="[7.0.0,8.0.0)"_ [Sanitized]
at org.eclipse.osgi.container.Module.start(Module.java:429)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1498)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)



Please help
thumbnail
David H Nebinger, geändert vor 7 Jahren.

RE: Liferay 7 CE ga2 OSGI read portlet .properties file

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
You list the util-java.jar as a dependency but it is not available in the OSGi container.

You'll need to include it as a runtime dependency: https://web.liferay.com/web/user.26526/blog/-/blogs/osgi-module-dependencies





Come meet me at the LSNA!
thumbnail
Liferay Dev, geändert vor 6 Jahren.

RE: Liferay 7 CE ga2 OSGI read portlet .properties file

Junior Member Beiträge: 81 Beitrittsdatum: 17.05.15 Neueste Beiträge
Use this piece of code to read portlet.properties
Configuration configuration = ConfigurationFactoryUtil.getConfiguration(PortalClassLoaderUtil.getClassLoader(), "portlet");
thumbnail
Liferay Dev, geändert vor 6 Jahren.

RE: Liferay 7 CE ga2 OSGI read portlet .properties file

Junior Member Beiträge: 81 Beitrittsdatum: 17.05.15 Neueste Beiträge
Use this piece of code to read portlet.properties
Configuration configuration = ConfigurationFactoryUtil.getConfiguration( get Portlet level class loader , "portlet");