Fórum

portal-ext properties

Ashwini Sidhanti, modificado 6 Anos atrás.

portal-ext properties

New Member Postagens: 20 Data de Entrada: 15/12/16 Postagens Recentes
Hi Everyone,

I have a very typical requirement of calling Portal-ext.property file in my code. I used PropsUtil.get(Key) to call the property value in my code. But it throws null pointer exception. Now iam not sure Is it possible to call portal-ext property file in my code. If so what is the best way to do it.
Any help is appreciated.

Thanks
Ashwini Sidhanti
thumbnail
David H Nebinger, modificado 6 Anos atrás.

RE: portal-ext properties

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
PropsUtil like never fails. Especially by the NPE.

Can you share the version and the stack trace?









Come meet me at the 2017 LSNA!
Ashwini Sidhanti, modificado 6 Anos atrás.

RE: portal-ext properties

New Member Postagens: 20 Data de Entrada: 15/12/16 Postagens Recentes
Thanks David for the quick reply.
I am using Liferay DXP.
PropsUtil import is : import com.liferay.portal.kernel.util.PropsUtil;
Code : PropsUtil.get(key)
Stack trace is :
Exception in thread "main" java.lang.NullPointerException
at com.liferay.portal.kernel.util.PropsUtil.get(PropsUtil.java:32)

I observe that getProps() in PropsUtil line 32 is null.

Regards
Ashwini Sidhanti
thumbnail
David H Nebinger, modificado 6 Anos atrás.

RE: portal-ext properties

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
Ashwini Sidhanti:
I am using Liferay DXP.


What service pack? What fix pack? Details are important.

Stack trace is :
Exception in thread "main" java.lang.NullPointerException
at com.liferay.portal.kernel.util.PropsUtil.get(PropsUtil.java:32)


Is there more for the stack trace? Having the full path can help too









Come meet me at the 2017 LSNA!
Ashwini Sidhanti, modificado 6 Anos atrás.

RE: portal-ext properties

New Member Postagens: 3 Data de Entrada: 22/12/16 Postagens Recentes
Fix pack: de-20-7010
service pack: GA1

The stack trace is very limited and that is all I have to prob too.
But when I bedug I understood that PropsUtil itself is null.
Why and how to resolve it I have no clue.
just being sure:
Can I call the properties of portal-ext.properties in my code through PropsUtil?
If so Is there any special setup required?
Ashwini Sidhanti, modificado 6 Anos atrás.

RE: portal-ext properties

New Member Postagens: 3 Data de Entrada: 22/12/16 Postagens Recentes
Closing this Post Because found the solution. emoticon
I.e I need to call my class in a certain class where I would make Liferay available to the PropsUtil.
Thanks for all the time David.
thumbnail
Andrew Jardine, modificado 6 Anos atrás.

RE: portal-ext properties

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hi Ashwini,

Glad to hear you got it solved, but if you could take a few minutes to document some of the details of what the actual problem ended up being and how you solved it, then it might help someone who comes along in the future with the same issue. This statement --

...to call my class in a certain class where I would make Liferay available to the PropsUtil


is a little cryptic. emoticon
Ashwini Sidhanti, modificado 6 Anos atrás.

RE: portal-ext properties

New Member Postagens: 20 Data de Entrada: 15/12/16 Postagens Recentes
Agree with you, Andrew.
PropsUtil is always available in the Liferay environment.
So I made a simple hook with a single class which implements LifecycleAction.
Called my API in the class and could see my results on the web portal.
I am not sure if this is the best solution. But this worked.

Regards,
Ashwini Sidhanti