How to override an abstract method with a non-abstract method? :(

Hello,

So I’ve been trying to to complete the Search decorator tutorial which can be found here: Create a search decorator tutorial, and I’ve run into an issue of which I am unsure how I can correct. The error which can be found below basically says that I cannot use a non-abstract class to override an abstract class. This error is shown in the command prompt and the text is shown below.

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/dbianco/search-decorator2/src/main/java/com/example/plugins/tutorial/confluence/PromoteContentCreatorSearchDecorator.java:[42,24] com.atlassian.confluence.plugins.v2.search.tutorial.PromoteContentCreatorSearchDecorator.PromoteContentCreatorSearch is not abstract and does not override abstract method getLimit() in com.atlassian.confluence.search.v2.ISearch
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.469 s
[INFO] Finished at: 2020-07-21T13:00:42-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project search-decorator2: Compilation failure
[ERROR] /C:/Users/dbianco/search-decorator2/src/main/java/com/example/plugins/tutorial/confluence/PromoteContentCreatorSearchDecorator.java:[42,24] com.atlassian.confluence.plugins.v2.search.tutorial.PromoteContentCreatorSearchDecorator.PromoteContentCreatorSearch is not abstract and does not override abstract method getLimit() in com.atlassian.confluence.search.v2.ISearch
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Below you can also find a copy of my PomoteContentCreatorSearchDecorator.java

package com.atlassian.confluence.plugins.v2.search.tutorial;

import com.atlassian.confluence.search.v2.HightlightParams;
import com.atlassian.confluence.search.v2.ISearch;
import com.atlassian.confluence.search.v2.ResultFilter;
import com.atlassian.confluence.search.v2.SearchDecorator;
import com.atlassian.confluence.search.v2.SearchFilter;
import com.atlassian.confluence.search.v2.SearchQuery;
import com.atlassian.confluence.search.v2.SearchSort;
import com.atlassian.confluence.search.v2.query.BooleanQuery;
import com.atlassian.confluence.search.v2.query.ConstantScoreQuery;
import com.atlassian.confluence.search.v2.query.CreatorQuery;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.sal.api.user.UserKey;
import com.atlassian.sal.api.user.UserManager;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Optional;

import static java.util.Objects.requireNonNull;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PromoteContentCreatorSearchDecorator implements SearchDecorator {
    private final UserManager userManager;
 
    @Autowired
    public PromoteContentCreatorSearchDecorator(@ComponentImport UserManager userManager) {
        this.userManager = requireNonNull(userManager);
    }
 
    @Override
    public ISearch decorate(ISearch search) {
        UserKey loginUserKey = userManager.getRemoteUserKey();
        if (loginUserKey != null) {
            return new PromoteContentCreatorSearch(search, loginUserKey);
        }
        return search;
    }
	
	private static class PromoteContentCreatorSearch implements ISearch {
		private final ISearch delegate;
		private final UserKey creator;
 
		private PromoteContentCreatorSearch(ISearch delegate, UserKey creator) {
			this.delegate = delegate;
			this.creator = creator;
		}
 
		@Override
		public SearchQuery getQuery() {
			// a content matching should clause adds an overwhelming contribution to the overall score so it
			// is ranked before any unmatched content
			return BooleanQuery.builder()
					.addMust(delegate.getQuery())
					.addShould(new ConstantScoreQuery(new CreatorQuery(creator), 50.0f))
					.build();
		}
	}
}	

Anything would help thank you for reading :smiley:

Hi @DianaBianco,

Thanks for reaching out, its a java compilation issue where-in you have not overriden all the methods specified in ISearch interface. Please make sure you override rest of methods too as mentioned in following screenshot:
image

Also the example documentation you have followed gives the snippet, you are expected to fill out the java ceremonials and implement full API.
Please let us know if you questions.

Thanks,
GG

Hi @ggautam,

Thank you for your response however now I’m having a different problem. My plugin with the search decorator compiles but does not show up in my confluence test environment when I run the atlas-run command. Also when I upload it to my confluence production environment the plugin is disabled. When I try to enable it an error message shows that tells me to refer to the logs. When I look at my log I get an error that says my “Address already in use: bind.” I’ve included an excerpt of my log for clarity below:

2020-07-22 10:47:57,349 DEBUG [285:StdOutHandler [C:\Program Files\Java\jdk1.8.0_251\jre\bin\java.exe]] [plugins.synchrony.bootstrap.LoggingOutputHandler] processLine 2020-07-22 14:47:57,149 ERROR [main] [synchrony.logging] uncaught exception {:throwable #error {
2020-07-22 10:47:57,349 DEBUG [285:StdOutHandler [C:\Program Files\Java\jdk1.8.0_251\jre\bin\java.exe]] [plugins.synchrony.bootstrap.LoggingOutputHandler] processLine 	 :cause "Address already in use: bind"
2020-07-22 10:47:57,349 DEBUG [285:StdOutHandler [C:\Program Files\Java\jdk1.8.0_251\jre\bin\java.exe]] [plugins.synchrony.bootstrap.LoggingOutputHandler] processLine 	 :via
2020-07-22 10:47:57,349 DEBUG [285:StdOutHandler [C:\Program Files\Java\jdk1.8.0_251\jre\bin\java.exe]] [plugins.synchrony.bootstrap.LoggingOutputHandler] processLine 	 [{:type clojure.lang.ExceptionInfo
2020-07-22 10:47:57,349 DEBUG [285:StdOutHandler [C:\Program Files\Java\jdk1.8.0_251\jre\bin\java.exe]] [plugins.synchrony.bootstrap.LoggingOutputHandler] processLine 	   :message "error while starting state #'synchrony.server.http-server/http-server"
2020-07-22 10:47:57,350 DEBUG [285:StdOutHandler [C:\Program Files\Java\jdk1.8.0_251\jre\bin\java.exe]] [plugins.synchrony.bootstrap.LoggingOutputHandler] processLine 	   :data {:var #'synchrony.server.http-server/http-server}
2020-07-22 10:47:57,350 DEBUG [285:StdOutHandler [C:\Program Files\Java\jdk1.8.0_251\jre\bin\java.exe]] [plugins.synchrony.bootstrap.LoggingOutputHandler] processLine 	   :at [mount.lite$start$fn__24142 invoke "lite.clj" 153]}
2020-07-22 10:47:57,350 DEBUG [285:StdOutHandler [C:\Program Files\Java\jdk1.8.0_251\jre\bin\java.exe]] [plugins.synchrony.bootstrap.LoggingOutputHandler] processLine 	  {:type java.net.BindException
2020-07-22 10:47:57,350 DEBUG [285:StdOutHandler [C:\Program Files\Java\jdk1.8.0_251\jre\bin\java.exe]] [plugins.synchrony.bootstrap.LoggingOutputHandler] processLine 	   :message "Address already in use: bind"
2020-07-22 10:47:57,350 DEBUG [285:StdOutHandler [C:\Program Files\Java\jdk1.8.0_251\jre\bin\java.exe]] [plugins.synchrony.bootstrap.LoggingOutputHandler] processLine 	   :at [sun.nio.ch.Net bind0 "Net.java" -2]}]

I’ve tried restarting my computer and running just my production environment but it still doesn’t work. Also when I go into the “trouble shooting and support” section of confluence to look at the “log analyzer” it says, Confluence Unresponsive due to Blocked Threads when Comala Workflows Plugin 5.5.0, 5.5.1, 5.5.2, 5.7.2 or 5.7.3 Has Been Installed. I don’t know if it relates to the issue I’m having but it is also very confusing. Any advice would help.
Thank you,
Diana

You have another service/server installed using the same port…

  1. Change the port Synchrony uses
  2. Stop the other server
1 Like

Hi @amoerchen,

Thank you for your response so I’ve tried your suggestions and it didn’t work out too well now I’m running my program again on the old port with a different plugin that used to work fine and after redownloading the sdk and now I get this error.

2020-07-24 10:33:07,731 INFO [synchrony-interop-executor:thread-1] [plugins.synchrony.bootstrap.DefaultSynchronyProcessManager] isSynchronyProxyEnabled proxy port present: false
2020-07-24 10:33:07,733 INFO [synchrony-interop-executor:thread-1] [plugins.synchrony.bootstrap.DefaultSynchronyProcessManager] isSynchronyProxyEnabled app config synchrony.proxy.enabled: false
2020-07-24 10:33:09,097 INFO [synchrony-interop-executor:thread-1] [plugins.synchrony.bootstrap.DefaultSynchronyProcessManager] debugPrintEnvironment Synchrony working dir: C:\Users\dbianco\simplebp\target\confluence\home
2020-07-24 10:33:09,097 INFO [synchrony-interop-executor:thread-1] [plugins.synchrony.bootstrap.DefaultSynchronyProcessManager] debugPrintEnvironment C:\Program Files\Java\jdk1.8.0_251\jre\bin\java.exe -classpath C:\Users\dbianco\simplebp\target\container\tomcat9x\cargo-confluence-home\temp\2.1.0-master-9d112c9d.jar;C:\Users\dbianco\simplebp\target\container\tomcat9x\cargo-confluence-home\webapps\confluence\WEB-INF\lib\h2-1.4.196.jar -Xss2048k -Xmx1g synchrony.core sql
2020-07-24 10:33:11,549 INFO [ListenableFutureAdapter-thread-0] [plugins.synchrony.bootstrap.DefaultSynchronyProcessManager] isSynchronyProxyEnabled proxy port present: false
2020-07-24 10:33:11,549 INFO [ListenableFutureAdapter-thread-0] [plugins.synchrony.bootstrap.DefaultSynchronyProcessManager] isSynchronyProxyEnabled app config synchrony.proxy.enabled: false

How do I fix this?

Thank you,
Diana :smiley:

The log itself is just INFO, so shouldn’t be any problem?

Hm, else, if you don’t need Synchrony → just disable it

Or just find out what else is using the same port at your system… Maybe some other server. → networking - How do I find out which process is listening on a TCP or UDP port on Windows? - Stack Overflow

I don’t use the SDK to run my developer Confluence. I’m using WSL with a normal installation of Confluence.

A little easier is it to just user Docker Compose and Docker

Oh yeah I forgot to mention that when I log into confluence at the localhost it says it cannot connect to severer save any changes I’ve made to my page. And when I looked at my log that’s what it says that’s why I think my error is with synchrony. But thank you for your suggestions I will definitely try them.