Forums

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

MultipleCompilationErrorsException: startup failed: Compilation incomplete: expected to find class

Mouna Hammoudi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2022

Capture.PNG

I am using a REST endpoint in Jira and I am having three files in script editor that are reponsible for this REST endpoint. First,  I have a REST_Create_Multiple_Subtasks.groovy file which is responsible for the REST enmdpoint.  

 

Here is its code: 

import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate

import groovy.json.JsonBuilder

import groovy.transform.BaseScript

import com.atlassian.jira.issue.Issue;

import javax.ws.rs.core.MultivaluedMap

import javax.ws.rs.core.Response

import com.atlassian.jira.component.ComponentAccessor

import com.onresolve.scriptrunner.runner.ScriptRunnerImpl

import com.atlassian.sal.api.ApplicationProperties

import com.atlassian.sal.api.UrlMode

import org.apache.log4j.Logger

import com.atlassian.jira.project.Project

import com.atlassian.jira.bc.project.component.ProjectComponent

import com.atlassian.jira.project.ProjectManager

@BaseScript CustomEndpointDelegate delegate

callSubTaskCreator(httpMethod: "GET", groups: ["jira-users"]) {

  MultivaluedMap queryParams, String body ->

  def log = Logger.getLogger("atlassian-jira.log")

def subTaskCreatorHashMap= CreateMultipleSubtasks.Configuration_CreateMultipleSubtasks.getSubTaskCreatorHashMap()

String itracCreatemultiplesubtasksProjectCategoriesURL = subTaskCreatorHashMap["itracCreatemultiplesubtasksProjectCategoriesURL"];

log.warn("I AM HERE MOUNA ");

    def user = ComponentAccessor.jiraAuthenticationContext?.loggedInUser

  Issue issue = ComponentAccessor.getIssueManager().getIssueObject(queryParams.getFirst("issueId") as Long)

  long projectID = issue.getProject().get("id") as long

  def projectManager = ComponentAccessor.getProjectManager()

  Project project = projectManager.getProjectObj(projectID)

  int projectCategoryID = project.getProjectCategory().getId() as int

  def baseUrl = ScriptRunnerImpl.getOsgiService(ApplicationProperties).getBaseUrl(UrlMode.ABSOLUTE)

  int issueTypeID = issue.getIssueTypeId() as int

  def itracCreatemultiplesubtasksProjectCategoriesURL2 = itracCreatemultiplesubtasksProjectCategoriesURL.replaceAll(":1:", issue.getKey())

  def itracCreatemultiplesubtasksProjectCategoriesURL3 = itracCreatemultiplesubtasksProjectCategoriesURL2.replaceAll(":2:", user.getUsername())

    Response.temporaryRedirect(URI.create(itracCreatemultiplesubtasksProjectCategoriesURL3)).build()

 

}

I have a Fragment_Condition_CreateSubtasks.groovy which is responsible for specifying the conditions under which the REST endpoint should be executed 

Here is the code: 

import org.apache.log4j.Logger

import com.atlassian.jira.plugin.webfragment.model.JiraHelper

import CreateMultipleSubtasks.Configuration_CreateMultipleSubtasks

def log = Logger.getLogger("atlassian-jira.log")

Configuration_CreateMultipleSubtasks conf = new Configuration_CreateMultipleSubtasks()

def subTaskCreatorHashMap= conf.getSubTaskCreatorHashMap()

String projectKey = subTaskCreatorHashMap["projectKey"];

String issueTypeName = subTaskCreatorHashMap["issueTypeName"];

log.warn("MOUNA PROJECT KEY "+ projectKey+" issuetypename "+issueTypeName)

def val=jiraHelper.project?.key==projectKey  &&  issue.issueType.name==issueTypeName

return val

Finally, I have the file Configuation_CreareSubtasks.groovy which specifies some constant values for the REST endpoint to be read in the 2 previous files:. Here is the code: 


 public  class Configuration_CreateMultipleSubtasks {

 

    static def getSubTaskCreatorHashMap(){

        def map = [itracCreatemultiplesubtasksIssueTypesId:5,

        itracCreatemultiplesubtasksProjectCategoriesID: [10011, 10200, 10220, 10230, 10240, 10670, 10170, 11170, 11270, 11870, 11871, 11872, 11873, 11874, 11875, 12470],

        itracCreatemultiplesubtasksProjectCategoriesURL: "http://itrac-sustservice.eur.ad.sag:5555/web/subtaskmgr/Login.jsp?iTrac=:1:&reporter=:2:",

        projectKey: "PIE",

        issueTypeName: "Defect"]

        return map

    }

}

 

I receive the error: 

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Compilation incomplete: expected to find the class CreateMultipleSubtasks.Configuration_CreateMultipleSubtasks in file:/D:/itrac-shared-home/scripts/CreateMultipleSubtasks/Configuration_CreateMultipleSubtasks.groovy, but the file contains the classes: Configuration_CreateMultipleSubtasks 1 error
Anyone knows what is wrong?

2 answers

0 votes
Becky Yu
Contributor
August 26, 2024

If you define the class name as 'public', then the name of the file and the class will HAVE to be the same.

You have this class:

public  class Configuration_CreateMultipleSubtasks {}

so you should change the file name from Configuation_CreareSubtasks.groovy to Configuration_CreateMultipleSubtasks.groovy.

Suggest an answer

Log in or Sign up to answer