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
How to use AopService in my FooLocalServiceImpl or FooServiceImpl classes
Hi guys
I wanna use AopService in my LocalServiceImpl and ServiceImpl classes in a service-builder module in Liferay 7.2.1 GA2
So i added bellow @Component to my FooLocalServiceImp class.
Next when i ran delpoy task i faced bellow error in my console:
error : Class com.liferay.sample.service.impl.FooLocalServiceImpl is not assignable to specified service com.liferay.portal.aop.AopService
Then i googled about this and drill to Liferay source So understand i should implement AopService in the FooLocalServiceBaseImpl abstract class and override two functions as bellow :
But FooLocalServiceBaseImpl regenerated on every build-service!
is there any way to prevent this?
I wanna use AopService in my LocalServiceImpl and ServiceImpl classes in a service-builder module in Liferay 7.2.1 GA2
So i added bellow @Component to my FooLocalServiceImp class.
@Component(
property = "model.class.name=com.liferay.sample.model.Foo",
service = AopService.class
)
Then i just run buildService gradle task Next when i ran delpoy task i faced bellow error in my console:
error : Class com.liferay.sample.service.impl.FooLocalServiceImpl is not assignable to specified service com.liferay.portal.aop.AopService
Then i googled about this and drill to Liferay source So understand i should implement AopService in the FooLocalServiceBaseImpl abstract class and override two functions as bellow :
@Override
public Class<!--?-->[] getAopInterfaces() {
return new Class<!--?-->[] {
FooLocalService.class, IdentifiableOSGiService.class,
PersistedModelLocalService.class
};
}
@Override
public void setAopProxy(Object aopProxy) {
fooLocalService = (FooLocalService)aopProxy;
}
But FooLocalServiceBaseImpl regenerated on every build-service!
is there any way to prevent this?
There is just so much wrong here, but let's start with the major issue...
You should not modify generated sources. Period. And FooLocalServiceBaseImpl is generated and therefore not to be monkeyed with. All of your code goes to FooLocalServiceImpl, period.
Outside of that, you shouldn't force a class to become another type of service. FooLocalServiceBaseImpl already implements what it should, including AopService. Why you are trying to have it re-implement it again is unclear.
So I don't know where you got your marching orders on what to do or why, but they are mostly just plain wrong.
You should not modify generated sources. Period. And FooLocalServiceBaseImpl is generated and therefore not to be monkeyed with. All of your code goes to FooLocalServiceImpl, period.
Outside of that, you shouldn't force a class to become another type of service. FooLocalServiceBaseImpl already implements what it should, including AopService. Why you are trying to have it re-implement it again is unclear.
So I don't know where you got your marching orders on what to do or why, but they are mostly just plain wrong.
Hi David
I just want to implement a simple tetsIntegration module that explained here :
https://liferay.dev/forums/-/message_boards/message/119429731
But there aren't any Document for that.
I saw some example in the GitHub and i think it's necessary if i want to use LocalService/Service in my Test classes , it should have :
Here is my project in GitHub :
https://github.com/naderjafari/liferay-todo-list/tree/Liferay-7.2.1-fix-test
My test class :
https://github.com/naderjafari/liferay-todo-list/blob/Liferay-7.2.1-fix-test/liferay-todo-list-test/src/testIntegration/java/com/chberndt/liferay/todo/list/service/persistence/test/TaskLocalServiceTest.java
May service class:
https://github.com/naderjafari/liferay-todo-list/blob/Liferay-7.2.1-fix-test/liferay-todo-list-service/src/main/java/com/chberndt/liferay/todo/list/service/impl/TaskLocalServiceImpl.java
I just want to implement a simple tetsIntegration module that explained here :
https://liferay.dev/forums/-/message_boards/message/119429731
But there aren't any Document for that.
I saw some example in the GitHub and i think it's necessary if i want to use LocalService/Service in my Test classes , it should have :
@Component(
property = "model.class.name=com.liferay.sample.model.Foo",
service = AopService.class
)
Here is my project in GitHub :
https://github.com/naderjafari/liferay-todo-list/tree/Liferay-7.2.1-fix-test
My test class :
https://github.com/naderjafari/liferay-todo-list/blob/Liferay-7.2.1-fix-test/liferay-todo-list-test/src/testIntegration/java/com/chberndt/liferay/todo/list/service/persistence/test/TaskLocalServiceTest.java
May service class:
https://github.com/naderjafari/liferay-todo-list/blob/Liferay-7.2.1-fix-test/liferay-todo-list-service/src/main/java/com/chberndt/liferay/todo/list/service/impl/TaskLocalServiceImpl.java
I resolved this issue with updating my workspace :
in setting.gradle.
Now everything is OK after executing buildService task.
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "2.2.11"
in setting.gradle.
Now everything is OK after executing buildService task.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™