Instead put the method into VirtualPathLocalServiceImpl and you can access it from VirtualPathLocalServiceUtil after you build services.

In general you should never put business logic into the entity implementations. Most of these types of methods would not be available in the generated VirtualPath interface and trying to call the method will result in an UnsupportedOperationException every time.

Instead put the method into VirtualPathLocalServiceImpl and you can access it from VirtualPathLocalServiceUtil after you build services.

I already tried that and it didn't work. I tried again this morning, this time putting the method non-static, and in it generated the method correctly!

David H Nebinger:

In general you should never put business logic into the entity implementations. Most of these types of methods would not be available in the generated VirtualPath interface and trying to call the method will result in an UnsupportedOperationException every time.

With into entity implementations what do you mean? That I should not put method in VirtualPathImpl and it's more recommended to write them into VirtualPathLocalServiceImpl? But what if a method is needed both in local and remote interface? Should I implement the method twice?

With into entity implementations what do you mean? That I should not put method in VirtualPathImpl and it's more recommended to write them into VirtualPathLocalServiceImpl? But what if a method is needed both in local and remote interface? Should I implement the method twice?

VirtualPathImpl, VirtualPathLocalServiceImpl and VirtualPathServiceImpl are all different.

VirtualPathImpl - As david said, there should not be any bussiness logic in that class. It was the extended model implementation for the Virtual path service. Represents a row in the virtualpath service database table, with each column mapped to a property of this class.

VirtualPAthLocalServiceImpl - For local Service, In this class where you have to write your business logic & methods and re-run the service and access it using VirtualPathLocalServiceUtil.

VirtualPathServiceImpl - For remote Service, In this class where you have to write your business logic & methods and re-run the service and access it using VirtualPathServiceUtil.

But what if a method is needed both in local and remote interface? Should I implement the method twice?

With into entity implementations what do you mean? That I should not put method in VirtualPathImpl and it's more recommended to write them into VirtualPathLocalServiceImpl? But what if a method is needed both in local and remote interface? Should I implement the method twice?

Nope, take a queue from how Liferay structures their remote service implementations. Most of them, you'll see, invoke the permission checker stuff and then pass through to the local service implementation.

This way you're only implementing once but reusing for both local and remote.