Skip to content

Incompatible with agrest #19

Description

@timcu

Trying to use agrest with tapestry-resteasy produces an error in org.tynamo.resteasy.ResteasyRequestFilter

Application.getSingletons() returned unknown class type: io.agrest.runtime.AgRuntime

ResteasyRequestFilter doesn't support all the available types RESTEasy has to offer, so it throws the exception.
Only Resources and Providers are supported, but AgRuntime is a "Feature" type.

Example code using a simple data model from https://github.com/agrestio/agrest-bookstore-example . I can provide full source code if that helps.

  • add tapestry-resteasy to project
<dependency>
    <groupId>org.tynamo</groupId>
    <artifactId>tapestry-resteasy</artifactId>
    <version>0.7.0</version>
</dependency>
  • write a service to setup the AgRuntime
public class AgrestServiceImpl implements AgrestService {
  public AgrestServiceImpl() {
    ServerRuntime runtime = ServerRuntime.builder().addConfig("cayenne-project.xml").build();
    AgCayenneModule cayenneExt = AgCayenneBuilder.build(runtime);
    agRuntime = new AgBuilder().module(cayenneExt).build();
  }
  private AgRuntime agRuntime;
  public AgRuntime agRuntime() {
    return agRuntime;
  }
}
  • write a simple resource with a single @get method using Agrest
@Path("/category")
@Produces(MediaType.APPLICATION_JSON)
public class CategoryResource {
  @Context
  private Configuration config;
  @GET
  public DataResponse<Category> getAll(@Context UriInfo uriInfo) {
      return Ag.select(Category.class, config).uri(uriInfo).get();
  }
}
  • contribute the AgRuntime and resource like in my previous mail.
    @Contribute(javax.ws.rs.core.Application.class)
    public static void configureRestProviders(Configuration<Object> singletons, AgrestService svcAgrest) {
        singletons.add(svcAgrest.agRuntime());
        singletons.addInstance(CategoryResource.class);
    }
  • test it with your browser or curl

http://localhost:8080/tapestry-agrest/rest/category

java.lang.RuntimeException: Exception constructing service 'ResteasyRequestFilter': Error invoking constructor public
org.tynamo.resteasy.ResteasyRequestFilter(java.lang.String,org.slf4j.Logger,org.apache.tapestry5.http.services.ApplicationGlobals,javax.ws.rs.core.Application,org.apache.tapestry5.ioc.services.SymbolSource,boolean,org.apache.tapestry5.ioc.services.UpdateListenerHub,long,long,boolean) throws javax.servlet.ServletException: Application.getSingletons() returned unknown class type: io.agrest.runtime.AgRuntime

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