0

I am trying to extend ProfileImages servlet from /libs/foundation/src/impl/src/main/java/com/day/cq/wcm/foundation/pro file/impl/ProfileImages.java

and bundling as an OSGI service.

I have the following annotations

@Component(immediate=true)
@SlingServlet(
    resourceTypes = {"nt:file"},
    methods = {"GET"},
    selectors = {"adjust","adjust.small"},
    extensions = {"res", "jpg", "png", "gif"}
)

I see my service in bundles and Services in OSGI console. However it is not doing as ProfileImages servlet used to do

ProfileImages create the thumbnail if we invoke the following URL

http://mydomain.com:4502/content/dam/geometrixx/portraits/scott_reynolds.jpg.prof.thumbnail.100.100.jpg

If my servlet is invoke, I should get the same response

http://mydomain.com:4502/content/dam/geometrixx/portraits/scott_reynolds.jpg.adjust.small.100.100.jpg

However I am getting is 404 which is from the DefaultGetServlet

It seems that Sling servet is not able to resolve my servlet

One thing I need to know is how to get my service updated in

Apache Sling Servlet Resolverorg.apache.sling.servlets.resolver

My servlet is doing the same thing as the following service in sling servlet resolver

Service ID 843 Types: org.apache.sling.api.resource.ResourceProvider

Description: ServletResourceProvider for Servlets at [/libs/foundation/components/primary/nt/file/prof/thumbnail.gif.servl et, /libs/foundation/components/primary/nt/file/prof.gif.servlet, /libs/foundation/components/primary/nt/file/prof/thumbnail.res.servle t, /libs/foundation/components/primary/nt/file/prof.jpg.servlet, /libs/foundation/components/primary/nt/file/prof.png.servlet, /libs/foundation/components/primary/nt/file/prof/thumbnail.png.servle t, /libs/foundation/components/primary/nt/file/prof/thumbnail.jpg.servle t, /libs/foundation/components/primary/nt/file/prof.res.servlet]

My service should be listed in sling resolver with id and something like

...../adjust.small.jpg.servlet, ..../adjust.res.servlet I am using CRXDE web version for development Is there any configurations I have to do to get my service in over resource resolver?

David Gorsline
  • 4,933
  • 12
  • 31
  • 36
user1130906
  • 101
  • 4
  • 16

1 Answers1

0

Your servlet can not be resolved because it is not registered with the Declarative Services Runtime. The @Component and @SlingServlet annotations are not evaluated at runtime, they are part of the Apache Felix SCR Plugin Project which provides a maven plugin and ant task to create "OSGi Declarative Services" descriptors. http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin.html

For registering your Servlet as an OSGi Service an OSGI-INF/serviceComponents.xml file is required.

So I'm afraid you won't get around using a build lifecycle tool to build your OSGi bundle before uploading to CQ5, if you are planning to use the scr annotations. Else you have to create your service component file manually.

Thomas
  • 1,302
  • 9
  • 16