0

I'm trying to implement permissions (resources & models ones) on Liferay 7.1. I've noted that BaseModelPermissionChecker is now deprecated (so I should not make my permission classes extending it). So I tried to do as indicated in Liferay official tutorial
However, when deploying my osgi services, OSGI container indicates the following error (for model and resource permission):

ERROR [Refresh Thread: Equinox Container: 80bbc977-c7cb-0018-1000-82f21869d6ec][com_liferay_training_space_gradebook_service:97] [com.a.b.c.service.permission.MyEntityPermission(3887)] Field _portletResourcePermission in component class com.a.b.c.service.permission.MyEntityPermission must not be static.

Have you got that error ? Did I skip something ?

EDIT

Component created:

@Component(immediate = true, service = {})
public class BookResourcePermission {

public static final String ADD_BOOK = "ADD_BOOK";

@Reference(target = "(resource.name=com.x.y.mybook.model)", unbind = "-")
protected static void setPortletResourcePermission(PortletResourcePermission portletResourcePermission) {
    _portletResourcePermission = portletResourcePermission;
}

public static boolean contains(PermissionChecker permissionChecker, long groupId, String actionId) {
    return _portletResourcePermission.contains(permissionChecker, groupId, actionId);
}

private static PortletResourcePermission _portletResourcePermission;
}

Thanks !

javaxiss
  • 680
  • 3
  • 13
  • 34
  • it says your Field _portletResourcePermission is static ... and equinox doesn't likes that .. have you an @REFERENCE above an static field ? – André Oct 11 '18 at 18:56
  • yes I have an @Reference over there. – javaxiss Oct 11 '18 at 19:40
  • 1
    the mentioned tutorial uses Method injection instead of property injection,. this hides the static field for equinox – André Oct 12 '18 at 10:58
  • Yeah at the beginning I did it like that. However, I got an exception on the build: In component , method , cannot recognize the signature of the descriptor: ()V, No interface specified on ]. It is the same as this one https://community.liferay.com/fr/forums/-/message_boards/message/84345299/exclusive?_com_liferay_message_boards_web_portlet_MBPortlet_showBreadcrumb=false – javaxiss Oct 12 '18 at 16:58
  • may be you should provide the component you have created ... – André Oct 18 '18 at 18:50
  • I've edited my post with the component created that throws the error.. That error is thrown at build time by AnnotationReader of bndlib. – javaxiss Oct 18 '18 at 21:18
  • Well, that's my mistake...It is a typo..It is due to the static modifier on the setter :-( It works fine now. – javaxiss Oct 19 '18 at 12:46
  • 1
    every osgi Service needs an Interfaces... the annotation has to be validly used... you can set Object as Class, and the service compotent registry (the SCR bundle of your runtime) needs to be used via method/ propery injection ,,, but both from object instances und not these static ones ... welcome in the osgi world, where everything is a component – André Oct 22 '18 at 09:55

0 Answers0