Can services exist in libs?

Enonic version: 6.8
OS: Linux

So I made a service which sorta belongs to a content-type. Since the content-type is in a lib, I felt like putting the service in the lib aswell. But that does not work. If I copy the service into the app, it works just fine.

Should it be possible for services to exist in libs?

No, it’s not possible to have services in libs yet. It’s planned, but we cannot do that currently.

Sorry, I just answered about Java services. When it comes to services in JavasScript it will work from a lib too.

1 Like

Where’s your services located? Under /site or just on the root?

Hmm… services/ should work fine in libs shouln’t they? @srs are you talking about Java service maybe?

Not in site, but in src/main/resources/services/serviceName/serviceName.js

Should work, but let me just verify it. It’s designed to work, but maybe it’s a bug somewhere.

Can you try to move it under a site and try it again to see if it works?

When I move it to site, it works.

Ok, then I will report this as a bug. It will be fixed in 6.9.

Don’t know whether it’s relevant, but the service is in a lib inside another lib :slight_smile:

Oh, so you bundle a lib inside another lib? Why? Or is it just dependencies?

Because library L uses stuff from library M.
Library M has very few dependencies.
Library L has many dependancies.

App A uses library M (and thus L).
App B only uses library L.

So it’s just dependencies, right? It’s not that LibL includes LibM (like inside the jar file)?

libL “includes” libM via build.gradle dependencies runtime files(’…/libFolder/build/libs/libName.jar’)

Application A does not include lib L as it gets it via lib M.