Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ServiceDeskPermissionService class not found

Carsten M
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 27, 2020

I try to access the ServiceDeskPermissionService in a Plugin but is always returns the Exception java.lang.ClassNotFoundExceptioncom.atlassian.servicedesk.api.permission.ServiceDeskPermissionService

This is my POM:

 <dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
<!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
<dependency>
<groupId>com.atlassian.servicedesk</groupId>
<artifactId>jira-servicedesk-api</artifactId>
<version>4.7.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.6.01</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>

<!-- WIRED TEST RUNNER DEPENDENCIES -->

<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>2.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.12</version>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.2.1.jre8</version>
<scope>provided</scope>
</dependency>


<!-- Added for Authenticator -->
<dependency>
<groupId>com.atlassian.crowd</groupId>
<artifactId>embedded-crowd-api</artifactId>
<version>2.10.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.seraph</groupId>
<artifactId>atlassian-seraph</artifactId>
<version>2.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>jira-maven-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<applications>
<application>
<applicationKey>jira-servicedesk</applicationKey>
<version>${servicedesk.version}</version>
</application>
</applications>
<allowGoogleTracking>false</allowGoogleTracking>
<extractDependencies>true</extractDependencies>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<jira.version>8.7.1</jira.version>
<amps.version>8.1.0</amps.version>
<servicedesk.version>4.7.1</servicedesk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

And this is how I try to access the ServiceDeskPermissionService

ServiceDeskPermissionService serviceDeskPermissionService = ComponentAccessor.getOSGiComponentInstanceOfType(ServiceDeskPermissionService.class); 

The same happens when i try to access the CustomerService.

I also tried to access the ServiceDesk api by spring scanner

@ComponentImport
private final ApplicationProperties applicationProperties;
@ComponentImport
private final UserService userService;
@ComponentImport
private final CustomerService customerService;
@ComponentImport
private final UserManager userManager;
@ComponentImport
private final ServiceDeskManager serviceDeskManager;

@Inject
public HSETUAuthenticatorComponentImpl(final ApplicationProperties applicationProperties, final UserService userService, final CustomerService customerService, final UserManager userManager, final ServiceDeskManager serviceDeskManager)
{
this.applicationProperties = applicationProperties;
this.userService = userService;
this.customerService = customerService;
this.userManager = userManager;
this.serviceDeskManager = serviceDeskManager;
}

CustomerService will not be injected, and returns a classdefnotfoundexpection

POM excerpt:

<dependency>
<groupId>com.atlassian.servicedesk</groupId>
<artifactId>jira-servicedesk-api</artifactId>
<version>4.7.1</version>
<scope>provided</scope>
</dependency>

I use the jiraservicedesk from here https://www.atlassian.com/de/software/jira/service-desk/download, Version 4.7.1

I hope this information is sufficient to solve the problem. If further information is necessary I will gladly provide it.

1 answer

0 votes
moofoo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 30, 2020

Hi Carsten,

Thanks so much for your question.

These issues are really hard to debug and usually are easy to resolve. Let's try a few diagnostics first.

Check the compiled OSGi descriptors in the target/classes/META-INF/plugin-components/ directory.

Namely, the target/classes/META-INF/plugin-components/imports file - it should contain an entry for com.atlassian.servicedesk.api.permission.ServiceDeskPermissionService.

Same for CustomerService, the target/classes/META-INF/plugin-components/imports file should have an entry for it: com.atlassian.servicedesk.api.customer.CustomerService.

Next, check that the target/classes/META-INF/MANIFEST.MF file contains both of those with the correct version in the Import-Package section. You should have something like this:

com.atlassian.servicedesk.api.customer.CustomerService;version="[4.7,1)"

In order to import the ServiceDeskPermissionService, you might want to add the following @ComponentImport annotation to your class' member:

@ComponentImport
com.atlassian.servicedesk.api.permission.ServiceDeskPermissionService serviceDeskPermissionService;

Also, make sure you have the correct <Import-Package> section in the jira-maven-plugin plugin configuration in your pom.xml file:

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>jira-maven-plugin</artifactId>
        <version>${amps.version}</version>

        <extensions>true</extensions>

        <configuration>
          <instructions>
            <Spring-Context>*</Spring-Context>

            <Import-Package>
              <!-- make sure you do not ignore the corresponding packages -->
              *
            </Import-Package>
          </instructions>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

The other mistake we often see is that the imported Maven dependency is wrong (which is not your case, but just to make things clear) - you should have a provided-scope dependency with the interfaces you are trying to autowire, e.g.:

<dependency>
  <groupId>com.atlassian.servicedesk</groupId>
  <artifactId>jira-servicedesk-api</artifactId>
  <version>${servicedesk.version}</version>
  <scope>provided</scope>
</dependency>

Also make sure that the version of the packages that you import are aligned (e.g. you do not import jira-servicedesk-api version 4.7.1 and in your OSGi descriptors you have classes requiring version 4.8.0 or alike).

On a sidenote, make sure the version of atlassian-spring-scanner-maven-plugin is of version 2.x (we are currently on 2.1.9), since there are some significant differences between v 1.x and v 2.x.

If it is correct, ensure the Spring configuration in META-INF/spring/spring.xml is up to date:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:atlassian-scanner="http://www.atlassian.com/schema/atlassian-scanner/2"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.atlassian.com/schema/atlassian-scanner/2
           http://www.atlassian.com/schema/atlassian-scanner/2/atlassian-scanner.xsd">
 <atlassian-scanner:scan-indexes/>
</beans>

Hope this gives you few starting points to resolve your issue. Please respond if I can help further.

Thank you,

Artem
Jira Service Desk team

John Funk
Community Champion
June 10, 2020

Hi @Carsten M  - Was this able to solve your problem? 

Carsten M
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 18, 2020

Sorry for the late reply. In the meantime I was involved in several other projects. In the meantime I have rejected this approach. Nevertheless, I would like to know what the cause of my problems is.
That's why I looked at @moofoo's suggestions today.

The target/classes/META-INF/plugin-components/imports file contains all imports.

The target/classes/META-INF/MANIFEST.MF file in the < Import Package> section does not contain any of these entries.
What reasons can there be for the absence of these entries?

I have set the dependency jira-servicedesk-api to version 4.7.1.
I have set the dependency atlassian-spring-scanner-maven-plugin to version 2.1.9.

The file META-INF/spring/spring.xml is missing.
What could be the reason for that?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events