Hi team, I'm trying to add a template extension an...
# help
a
Hi team, I'm trying to add a template extension and created a jar out of it. The jar is added to the classpath of standalone jar and started the mock server. When I trigger that template helper, I'm seeing this error
Copy code
<title>Error 500 java.lang.AbstractMethodError: Receiver class com.example.template.SliceHandlebarHelper does not define or inherit an implementation of the resolved method &apos;abstract java.lang.Object apply(java.lang.Object, wiremock.com.github.jknack.handlebars.Options)&apos; of interface wiremock.com.github.jknack.handlebars.Helper.</title>
Is there anything that I need to do? The SliceHandlebarHelper already implements Helper. TIA
Copy code
public class SliceHandlebarHelper  extends HandlebarsHelper<Object> {

    @Override
    public Object apply(Object o, Options options) throws IOException {...
Attached pom.xml
l
It is a little tricky to help without seeing all the code of your helper. Are you importing the correct
Options
class for example.
a
Yes, I am able to compile as well. After starting the wiremock, when using the helper I'm getting this issue
ExtensionFactory
Copy code
public class TemplateExtensionFactory implements ExtensionFactory {

    @Override
    public List<Extension> create(WireMockServices services) {
        return List.of(new ListTemplateHelperProviderExtension());
    }
}
TemplateHelperProviderExtension
Copy code
public class ListTemplateHelperProviderExtension implements TemplateHelperProviderExtension {

    private final Map<String, Helper<?>> listTemplateHelpers = new HashMap<>();

    public ListTemplateHelperProviderExtension() {
        listTemplateHelpers.put("slice", new SliceHandlebarHelper());
    }

    @Override
    public Map<String, Helper<?>> provideTemplateHelpers() {
        return listTemplateHelpers;
    }

    @Override
    public String getName() {
        return "list";
    }
}
SliceHandlebarHelper
Copy code
import com.github.jknack.handlebars.Options;
import com.github.tomakehurst.wiremock.extension.responsetemplating.helpers.HandlebarsHelper;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import static java.util.Collections.emptyList;

public class SliceHandlebarHelper  extends HandlebarsHelper<Object> {

    @Override
    public Object apply(Object o, Options options) throws IOException {
       ...
    }
}
l
Not really sure what the issue is. Does the jar you generate contain the WireMock and handlebars helpers dependencies?
a
I think I might have found the issue, in the error
implementation of the resolved method &apos;abstract java.lang.Object apply(java.lang.Object, <http://wiremock.com|wiremock.com>.github.jknack.handlebars.Options)
it is expecting wiremock.com.github.jknack.handlebars.Options instead of com.github.jknack.handlebars.Options . Gradle has relocate option
Copy code
shadowJar {
    relocate "com.github.jknack", 'wiremock.com.github.jknack'
}
looking for maven alternative.
🙌 1