Skip to content

ServiceProviderConfig request throws MessageBodyWriter not found for media type exception #140

@dhubbard-ag

Description

@dhubbard-ag

Describe the bug
A request to service for /ServiceProviderConfig returns a 500 error, throws a JavaException

Severe:   MessageBodyWriter not found for media type=application/scim+json, type=class com.unboundid.scim2.common.GenericScimResource, genericType=class com.unboundid.scim2.common.GenericScimResource.

I found a similar problem #131 - and followed the resolution there and added jackson media dependency

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>2.30</version>
        </dependency>    

With this the exception changes to:

Severe:   MessageBodyWriter not found for media type=application/json, type=class com.unboundid.scim2.common.GenericScimResource, genericType=class com.unboundid.scim2.common.GenericScimResource.

To Reproduce

  1. Created a new Web Application Maven project (in NetBeans 8.2)

  2. Added ServiceProviderConfigEndpoint (based on TestServiceProviderConfigEndpoint.java in Server project.

package com.mycompany.scim;

import com.unboundid.scim2.common.types.AuthenticationScheme;
import com.unboundid.scim2.common.types.BulkConfig;
import com.unboundid.scim2.common.types.ChangePasswordConfig;
import com.unboundid.scim2.common.types.ETagConfig;
import com.unboundid.scim2.common.types.FilterConfig;
import com.unboundid.scim2.common.types.PatchConfig;
import com.unboundid.scim2.common.types.ServiceProviderConfigResource;
import com.unboundid.scim2.common.exceptions.ScimException;
import com.unboundid.scim2.common.types.SortConfig;
import static com.unboundid.scim2.common.utils.ApiConstants.MEDIA_TYPE_SCIM;
import com.unboundid.scim2.server.annotations.ResourceType;
import com.unboundid.scim2.server.resources.
    AbstractServiceProviderConfigEndpoint;

import java.util.Collections;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
 * A test Service Provider Config endpoint implementation that just serves up
 * a canned config.
 */
@ResourceType(
    description = "SCIM 2.0 Service Provider Config",
    name = "ServiceProviderConfig",
    schema = ServiceProviderConfigResource.class,
    discoverable = false)
@Path("/ServiceProviderConfig")
public class ServiceProviderConfigEndpoint
    extends AbstractServiceProviderConfigEndpoint
{
  /**
   * {@inheritDoc}
   */
    @Override
    @Produces({MEDIA_TYPE_SCIM, MediaType.APPLICATION_JSON})
    public ServiceProviderConfigResource getServiceProviderConfig()
      throws ScimException
    {
        System.out.println("Received Get for /ServiceProviderConfig");
        return create();
    }

    /**
     * Create a test config resource.
     *
     * @return The created resource.
     */
    public static ServiceProviderConfigResource create()
    {
        return new ServiceProviderConfigResource("https://doc",
          new PatchConfig(true),
          new BulkConfig(true, 100, 1000),
          new FilterConfig(true, 200),
          new ChangePasswordConfig(true),
          new SortConfig(true),
          new ETagConfig(false),
          Collections.singletonList(
              new AuthenticationScheme(
                  "Basic", "HTTP BASIC", null, null, "httpbasic", true)));
    }
}
  1. Deploy to Glassfish

  2. Call http://localhost:8880/SCIMProvider/rest/ServiceProviderConfig

Expected behavior
Should return the generated json data (this from log message before exception) with a 200 response

{
  "schemas" : [ "urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig" ],
  "documentationUri" : "https://doc",
  "patch" : {
    "supported" : true
  },
  "bulk" : {
    "supported" : true,
    "maxOperations" : 100,
    "maxPayloadSize" : 1000
  },
  "filter" : {
    "supported" : true,
    "maxResults" : 200
  },
  "changePassword" : {
    "supported" : true
  },
  "sort" : {
    "supported" : true
  },
  "etag" : {
    "supported" : false
  },
  "authenticationSchemes" : [ {
    "name" : "Basic",
    "description" : "HTTP BASIC",
    "type" : "httpbasic",
    "primary" : true
  } ],
  "meta" : {
    "resourceType" : "ServiceProviderConfig",
    "location" : "http://localhost:8880/SCIMProvider/rest/ServiceProviderConfig"
  }

Additional context

  • Java version: Java 8
  • Server: Glassfish 4.1
  • SCIM 2 SDK version: 2.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions