[INFO] 2019-01-18 08:31:40,648 ERROR [spring-startup] c.a.plugin.osgi.factory.OsgiPlugin Plugin 'com.izymes.workzone' never resolved service '&auditService' with filter '(objectClass=com.atlassian.bitbucket.audit.AuditService)'
com.atlassian.bitbucket.audit.AuditService is part of the bitbucket-api jar (along with all the other public components) and this dependency is included in the app’s pom.xml
Not including the package into DynamicImport-Package doesn’t help either …
Have you found a solution for AuditService yet? I’m having the same issue trying to use AuditService in a Bitbucket plugin:
ERROR [spring-startup] c.a.plugin.osgi.factory.OsgiPlugin Plugin 'packagename' never resolved service '&auditService' with filter '(&(objectClass=com.atlassian.bitbucket.audit
.AuditService)(objectClass=com.atlassian.bitbucket.audit.AuditService))'
The service is imported like this (shortened):
import com.atlassian.bitbucket.audit.AuditService;
@ExportAsService{MyService.class}
@Named("myService")
public class MyService {
@ComponentImport
private final AuditService auditService;
@Inject
public MyService(final AuditService auditService) {
this.auditService = auditService
}
}
Unfortunately this does not fit my needs, because I want to fetch the project creation dates from the audit log (as there is no other way in the api to access these, only by querying directly on the database).
It looks like this was broken in Bitbucket Server 4.5.0 (April 2016), and was just not noticed for ~2 1/2 years. I’ve created BSERV-11993 to track a fix. While the class for the interface is OSGi-exported, the actual service is not. So apps can classload the AuditService interface, but any component import for it will never resolve.
@izymesdev, I’m glad you were able to come up with a satisfactory workaround. Apologies for not noticing this question sooner!
@sezu, just FYI, I don’t think querying the audit logs for project creation dates will be reliable, long term. If your app needs to track project creation, you’d be better off listening for ProjectCreatedEvent and implementing your own recording for the date. That won’t help with existing projects, unfortunately, but the audit log would be at best a partial solution anyway.