Seraph-Can't get SAL for remote Service Call Edited

I've been trying to make my own custom authentication plugin for SSO with my company using Seraph in Confluence (And will late do so in Jira) but I can't seem to make remote Service calls because I can't find the RequestFactory SAL.

Here are the rough steps I've taken so far

  1. Download/Setup SDK
  2. Create Confluence Plugin
  3. Extended the ConfluenceAuthenticator class and implemented my own logic

Now I'm trying to get a reference to the RequestFactory SAL and have tried,

  1. Dependency injection with annotations
  2. Dependency injection with contructor
  3. ComponentLocator
  4. component-import xml tag (docs are out of date and doesn't work)


So, my question is, how would I get access to the RequestFactory for making remote calls in Seraph?

When using the below code, if using ComponentLocator approach it returns null, and when using Dependency Injection it tells me the class couldn't be instantiated

Caused by: com.atlassian.seraph.config.ConfigurationException: Unable to instantiate class 'com.example.confluence.GluuAuthenticator' : java.lang.InstantiationException: com.example.confluence.MyCustomAuthenticator
        at com.atlassian.seraph.config.SecurityConfigImpl.configureClass(
        at com.atlassian.seraph.config.SecurityConfigImpl.configureAuthenticator(
        at com.atlassian.seraph.config.SecurityConfigImpl.<init>(
        at com.atlassian.seraph.config.SecurityConfigFactory.loadInstance(
        ... 131 more
Caused by: java.lang.InstantiationException: com.example.confluence.MyCustomAuthenticator
        at java.lang.Class.newInstance(
        at com.atlassian.seraph.config.SecurityConfigImpl.configureClass(
        ... 134 more
Caused by: java.lang.NoSuchMethodException: com.example.confluence.MyCustomAuthenticator.<init>()
        at java.lang.Class.getConstructor0(
        at java.lang.Class.newInstance(
        ... 135 more


Here's the code so far

Targeting Confluence 6.4

import com.atlassian.confluence.user.ConfluenceAuthenticator;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyCustomAuthenticator extends ConfluenceAuthenticator {
    private static final Logger log = LoggerFactory.getLogger(ConfluenceAuthenticator.class);
    private static final String CODE_PARAM_NAME = "code";

    private final RequestFactory<?> requestFactory;

    public MyCustomAuthenticator(@ComponentImport RequestFactory<?> requestFactory) {
        this.requestFactory = requestFactory;

    public Principal getUser(HttpServletRequest request, HttpServletResponse response) {
        log.debug("MyCustomAuthenticator::getUser(HttpServletRequest request, HttpServletResponse response)");
        Principal user = super.getUser(request, response);
        String code = request.getParameter(CODE_PARAM_NAME);

        if (user != null) {
            log.debug("User is already logged in: " +
                    ((user.getName() != null) ? user.getName() : "<None>") );
            return (Principal) user;

        if (code == null) {
            log.debug("User is not logged in, and there is no code found in query params, will redirect to SSO");
            return (Principal) user;
"User is not logged in, but code is found in the query params. Will start the flow to create the user, " +
                "starting with verifying the code: " + code);

        try {
            String s = requestFactory
                    .createRequest(Request.MethodType.GET, "")
  "results: " + s);
        } catch (ResponseException e) {

        return (Principal)user;


ComponentLocator approach is simply


but like, i said, always returns null 😔 also tried PluginSettingsFactory.class and it also returns null


4 answers

Re-reading the Seraph article, I realized that dependency injection is not available to Seraph and there are a few caveats when looking for other Components (like RequestFactory).


Which leads to

RequestFactory requestFactory = (RequestFactory)ContainerManager

However, now the error has changed to

com.atlassian.spring.container.ComponentNotFoundException: Failed to find component: No bean named 'requestFactory' is defined


Also tried

RequestFactory requestFactory = (RequestFactory)ContainerManager

with no luck either, says it can't be found


I CAN get other components though, for example using the example found here, works fine

SpaceManager spaceManager = (SpaceManager) ContainerManager.getComponent("spaceManager");


I'm also unable to use RequestFactory with Atlassian Spring Scanner 2.x using multiple approaches. Injecting TrustedRequestFactory works just fine. It seems this is currently broken, which is a pitty.

Same problem. Been trying to use RequestFactory with multiple approaches for 3 days now.

I managed to find an alternate solution to communicating with an external service


So, a few things for those looking at this:

  1. Seraph requires any java jar, not specifically a atlassian-plugin
  2. You can use any method you wish to communicate with the outside world

I managed to communicate using the built in Java HttpUrlConnection. Its super gross to use but works perfectly. I'd abandon the idea of using SAL inside of seraph if someone finds this thread


Here's an example to get started:


      // create the HttpURLConnection
      url = new URL(desiredUrl);
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      // just want to do an HTTP GET here
      // uncomment this if you want to write output to this url
      // give it 15 seconds to respond

      // read the output from the server
      reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
      stringBuilder = new StringBuilder();

      String line = null;
      while ((line = reader.readLine()) != null)
        stringBuilder.append(line + "\n");
      return stringBuilder.toString();
    catch (Exception e)
      throw e;


Copy/pasta from


But you can find many examples online on how to use this

Posted as well to Stackoverflow so more can see this

@Miguel Mendez Thank you so much for your post. 

I spent 2 days trying to figure out how to make this RequestFactory working and I had the exact same issue.

I ended up applying the same workaround you provided.

Premium Support should provide an explanation for this issue/bug...

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Tuesday in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

206 views 2 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you