Expand my Community achievements bar.

SOLVED

osgi service calling another service fails to load at runtime.

Avatar

Level 9

we have a servlet which calls our service, which calls another service, which calls the original service. This compiles, but when we deploy locally, we get 404 for the servlet page. If we comment out the service, the servlet gets called.  Does this mean we cannot have services calling each other?  Not sure how to structure the code without this.

 

GetSomething.java

 

@Slf4j
@Component(service = { Servlet.class })
@SlingServletPaths(value="/bin/myservlet")
public class GetSomething {

	@Reference
	private AService aService;

 

 

AService.java

 

@component(service = AService.class)
public class AServiceImpl implements AService {

	@Reference
	private BService bService;

 

BService.java

@component(service = BService.class)
public class BServiceImpl implements BService {

	@Reference
	private AService aService;

 The above code wont work, even if no methods are called in any of the services - the servlet doesnt exist after deployment.  If we comment out the reference to AService in BService, then the servlet exists on the server.

 

Any suggestions?

1 Accepted Solution

Avatar

Correct answer by
Level 9
1 Reply

Avatar

Correct answer by
Level 9