Add sample project that demonstrates AEM integration for Caravan JAX-RS


Currently, I see no usage instructions nor sample project that fully demonstrates usage of Caravan JAX-RS inside AEM (6.3). In trying to set it up, I have encountered numerous pitfalls (missing bundles, package conflicts, etc) that seem like they would warrant entries into the documentation.


Paul Bjorkstrand
January 9, 2018, 3:32 PM

The use case is publishing REST services from AEM. Basically, I am trying to get the following to work:

The Caravan-JaxRs-ApplicationPath bundle instruction is set to

What I am currently battling is that in AEM 6.3 SP1, the ServletContainerBridge's service(..) method is not even being called when I hit localhost:4502/services/test (confirmed to be the problem by debugging). I have verified that the service & servlet are registered (both via the services listing and the Http Whiteboard).

Paul Bjorkstrand
January 9, 2018, 6:52 PM

More notes:

I have tried to pull apart the caravan functionality, and move only a barebones set of modified classes from caravan into my bundle It is almost working, but I get an exception on the call of ServletContainerBridge.init(ServletConfig). I would be interested in knowing what the caravan does to not encounter this issue (if it does anything)

Obfuscated stack trace (removed client identifying text)

Stefan Seifert
January 9, 2018, 9:32 PM

i've added a simple example application here:

from the stacktrace - maybe you've missed to deploy the hibernate-validator bundle to you instances? see list of deployed dependencies in my example.

Paul Bjorkstrand
January 9, 2018, 9:32 PM

I dug down, and think I found the issue, but have no proposal for a resolution, yet. I'll try to explain the issue as best as I can.

In the bundle jersey-bean-validation-2.20.jar there is a java service listed in META-INF/services. The service interface is org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable, which exposes the org.glassfish.jersey.server.validation.internal.ValidationAutoDiscoverable service implementation.

This service locator is preventing glassfish from finding/creating a Validator implementation, which causes the thrown exception when calling ServletContainer.init(ServletConfig) (that is largely a guess, I don't know Glassfish/javax.validation that well).

When you remove that service locator from that jar, then rewrap it all together, it starts working just fine. After some heavy debugging, I found that the exact spot it was throwing, and made an educated guess as to the cause. To help guide my testing, I compared what was in the service registry in to what was in the nested jars in .

This was the first difference between the two, with respect to service locator. This explains why the JAX-RS OSGi Connector works, when using its dependencies, while Caravan does not, when using the listed dependencies (aka, the two different Jersey combined jars).

Paul Bjorkstrand
January 9, 2018, 10:01 PM

Heh, we both posted within a minute of each other

I tried to add the dependencies, and it was still not working, but maybe I missed something. I'll take a look at your sample and try it out. I would much prefer to use the already available bundles, rather than having to generate & house one in the project.

Cannot Reproduce




Paul Bjorkstrand