java.lang.NoClassDefFoundError: com/atlassian/util/profiling/UtilTimerStack

Getting the below error
Uncaught exception 4ff4fb46-f3a4-412a-8ba8-898548c97e76 thrown by REST service: com/atlassian/util/profiling/UtilTimerStack
java.lang.NoClassDefFoundError: com/atlassian/util/profiling/UtilTimerStack
at com.thed.zephyr.je.zql.core.LuceneSearchProviderImpl.search(LuceneSearchProviderImpl.java:130)
at com.thed.zephyr.je.zql.core.LuceneSearchProviderImpl.search(LuceneSearchProviderImpl.java:90)
at com.thed.zephyr.je.zql.core.ZSearchServiceImpl.search(ZSearchServiceImpl.java:74)
at com.thed.zephyr.je.helper.ScheduleSearchResourceHelper.performZQLSearch(ScheduleSearchResourceHelper.java:1971)
at com.thed.zephyr.je.rest.ScheduleSearchResource.executeSearch(ScheduleSearchResource.java:178)

Below is the code snippet

public SearchResult search(final Query query, final ApplicationUser searcher,final org.apache.lucene.search.Query andQuery,
    		final boolean overrideSecurity,final Integer startIndex,boolean maxAllowedResult,Integer maxRecords) throws Exception {
        final ZFJManagedIndexSearcher scheduleSearcher = getScheduleSearcher();
        UtilTimerStack.push("Lucene Query");
    	Integer maxResultHit = Integer.valueOf(JiraUtil.getSimpleDBProperty(ConfigurationConstants.ZEPHYR_ZQL_RESULT_MAX_ON_PAGE, "20").toString());
        String defaultMax = "10000";

I guess UtilTimerStack is deprecated now, can any onplease help me with alternate of this.
It will be of great help.
Thank you!

1 Like

Can anyone please help me with this. It will be really of great help

1 Like

Hello RaghunandanTata,
i did some digging and it looks like UtilTimerStack is indeed deprecated, which is causing the NoClassDefFoundError. You can replace it with the standard Java Timer class to achieve similar functionality. Here’s an example of how you can do this:

import java.util.Timer;
import java.util.TimerTask;

public class ScheduleSearchResourceHelper {
    private Timer timer = new Timer();

    public void performZQLSearch() {
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                // Your code here
                System.out.println("Lucene Query Timer Task executed");
            }
        };
        timer.schedule(task, 0, 1000); // Schedule the task to run every second
    }
}

This code creates a Timer and schedules a TimerTask to run periodically. You can adjust the timing parameters as needed.

Hopefully it helps :slight_smile:

Best regards,
Daniel