Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Liferay 7.2 - UserLocalServiceWrapper not working?
I have been using UserServiceWrapper to add information to my database when I add a new user. Overriding the "addUser" method it has been working until now. But if I understand correctly I should be using UserLocalServiceWrapper. The thing is that changing my class to extends UserLocalServiceWrapper the "addUser" method don't work anymore. I have changed the "serviceSetter" method to set an UserLocalServiceWrapper and I have also changed the addUser method to the same method present in UserLocalServiceWrapper (same parameters). What is the main difference between UserServiceWrapper and UserLocalServiceWrapper? Why is one working and the other not?
[quote=]
https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/customizing-liferay-services-service-wrappers
[quote=]
What is the main difference between UserServiceWrapper and UserLocalServiceWrapper?UserServieWrapper is class which Wrap the UserService and UserLocalServiceWrapper is class which wraps the UserLocalService. so if you want to wrap localservice then you use localServiceWrapper and for remote or webservice you use servicewrapper . You can refer below url also
https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/customizing-liferay-services-service-wrappers
[quote=]
Why is one working and the other not?May be its not deployed correctly .You can try deleting your wrapper module and deploy once more
What is the main difference between UserServiceWrapper and UserLocalServiceWrapper?To add a little more to what Mohammed added, the UserService (no local) is normally the entry point for an external call in. So for example, the JSON Web services. The normal development flow then in the XXXServiceImpl classes is to check the user and their permissions and if they are "allowed" you then invoke the XXXLocalService methods. If you are working with a component in your application (as in not coming in from outside) then you normally use the XXXLocalService set of services because your initial "Access" vetting has already been provided (because your user has logged into the portal already).
So in short XXXService normally provides additional or tighter security measures than XXXLocalService. Everything else, Mohammed answered already.
Ok, I understood the differences between the Local and Not Local, but I can't seem to make it work yet. There are two methods "addUser" on the UserLocalServiceWrapper class, I have Overrided them both to print a System.out.println("something") before the super.addUser(). Then I go to my instance control panel and add a new user, just like I did with the UserServiceWrapper, but this time my Overrided methods are never called. If i go to the Gogo shell and type "lb" I can see my module active, so I presume that it is correctly deployed.
Your module might be active, but one or more components inside might not be. Can you try running the scr:info command on the canonical name of your wrapper class in the gogo shell? it will output a bunch of information about the component. Copy and paste the output here for us.
I think when you add user from control panel super.addUserwithWorkflow(..) is called so you can try adding SoP in that and see
Excellent point. I think there was a whole conversation around this in the slack channel the other day -- and David was actually saying that when you want to add a user using the API that you should just call the addUserWithWorkflow method. That method is in fact called from the addUser method, but if the action command that the control panel uses calls it directly, then the wrapper would of course not be invoked for the test.You could also try using the script tab in the Server Administrator section to write a quick groovy script to call the addUser method too.
How strange... I did a breakpoint at the super.addUserWithWorkflow on the UserLocalServiceWrapper class and it did pause there after adding an User. However Overriding this same method on my UserLocalServiceWrapperOverride class, this method was ignored. Also I noticed that when I start the server I get this Log:
2019-08-20 15:34:43.242 INFO [main][SystemCheckOSGiCommands:111] Running "Declarative Service Unsatisfied Component Checker". You can run this by itself with command "ds:unsatisfied" in gogo shell.
2019-08-20 15:34:51.948 WARN [main][SystemCheckOSGiCommands:134] Declarative Service Unsatisfied Component Checker check result: _Bundle {id: 1075, name: pt.globaleda.portalgra, version: 1.0.0}_ Declarative Service {id: 6, name: pt.globaleda.portalgra.wrappers.UserWrapper, unsatisfied references: _ {name: serviceSetter, target: null}
How silly I am... This was not working because I was setting my service wrong. On my serviceSetter method I was passing a UserLocalServiceWrapper instead of an UserLocalService. Don't know how this happened (probably a wrong copy/paste) but this was the problem. After solving this the service works as expected! Thank you both for the help!
PS: Next time I should paste here my entire class... Maybe you are not as sleepy as I am
PS: Next time I should paste here my entire class... Maybe you are not as sleepy as I am

LOL -- I don't know about sleepy. I think we all suffer from the same "I've starred at this for so long now I see something I want to see, not what it actually is" syndrome from time to time. What you need is a rubber duck! https://en.wikipedia.org/wiki/Rubber_duck_debugging
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™