Hi all In case you want to follow the topic I posted some comments on the issue that Tim reported on GitHub. https://github.com/tynamo/tapestry-resteasy/issues/19
Cheers! Alejandro. On Sat, Aug 7, 2021 at 2:57 AM D Tim Cummings <t...@triptera.com.au.invalid> wrote: > > Thanks for your help Ben. I guess I don't need to use agrest. I can use > tapestry-resteasy with cayenne persistence. > > Cheers > > Tim > > On 6/8/21 23:03, Ben Weidig wrote: > > Hi Tim, > > > > your code looks fine to me, but it seems like this is a limitation of > > tapestry-resteasy. > > > > The project wraps the configuration of RESTEasy to make it easier to use > > with Tapestry. > > The method > > https://github.com/tynamo/tapestry-resteasy/blob/0111a37e842a67e49b47752de85d738676c179e9/src/main/java/org/tynamo/resteasy/ResteasyRequestFilter.java#L138 > > goes over the contributed instances and classes, but it doesn't support all > > the available types RESTEasy has to offer, so it throws the exception > > you're getting. > > Only Resources and Providers are supported, but AgRuntime is a "Feature" > > type. > > > > The only option I see (without tapestry-resteasy adding it) is overriding > > the ResteasyRequestFilter and extending the conditions for provider > > detection to allow instances of Feature, too. > > Features are internally registered like providers if I saw it correctly in > > the RESTEasy code. > > > > I've only read the tapestry-resteasy/RESTEasy source code and not tested it > > with a running project, so it might not be that easy. > > > > > > On Fri, Aug 6, 2021 at 1:52 PM D Tim Cummings <t...@triptera.com.au.invalid> > > wrote: > > > >> Hi Ben > >> > >> I followed your suggestions and was able to get rest working with > >> tapestry-resteasy without using persistence. However when I added agrest > >> tapestry resteasy threw an exception unknown class type: > >> io.agrest.runtime.AgRuntime. My code is as follows. I am using a simple > >> data model from https://github.com/agrestio/agrest-bookstore-example . > >> Could you please check I have implemented your suggestions correctly. > >> > >> - add tapestry-resteasy to your 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:8089/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 > >> > >> > >> On 3/8/21 22:06, Ben Weidig wrote: > >>> tapestry-resteasy is just bringing RESTEasy to Tapestry. > >>> There's no dependency to JPA/Hibernate. > >>> Do you mean the PersistenceService in the example on the page under "Code > >>> your singleton resource"? > >>> That's not a necessity, just an example for a Rest resource. > >>> In your case, you would use Agrest instead. > >>> > >>> You don't need to edit web.xml because tapestry-resteasy uses a Tapestry > >>> HttpServletRequestFilter to piggyback Tapstry itself, instead of going > >>> through the a custom servlet defined in the web.xml. > >>> Everything that would be done in the web.xml is done with code instead. > >>> This way, you don't need an extra Bridge to handle service injection. > >>> > >>> > >> https://github.com/tynamo/tapestry-resteasy/blob/master/src/main/java/org/tynamo/resteasy/ResteasyRequestFilter.java > >>> The next steps for simple proof-of-concept would be something like this: > >>> > >>> - add tapestry-resteasy to your project > >>> - write a service to setup the AgRuntime > >>> - write a simple resource with a single @GET method using Agrest > >>> - contribute the AgRuntime and resource like in my previous mail. > >>> - test it with your browser or curl > >>> > >>> Hope this helps! > >>> > >>> On Tue, Aug 3, 2021 at 1:12 PM D Tim Cummings > >> <t...@triptera.com.au.invalid> > >>> wrote: > >>> > >>>> Thanks for this very detailed reply. I will work through what you have > >>>> suggested and see how I go. > >>>> > >>>> I had a look at tapestry-resteasy but it seems to rely on hibernate or > >>>> jpa and I am using cayenne. I am not sure what is required for > >>>> org.tynamo.services.PersistenceService. Also tapestry-resteasy says I > >>>> don't need to edit web.xml. > >>>> > >>>> Another example I am following says I do need to edit web.xml. > >>>> https://github.com/andrus/wowodc13 is an example for tapestry and > >>>> cayenne and jersey 1.x rest. It seems to rely on a JerseyTapestryBridge > >>>> [1] but the code looks specific to jersey 1.x and wouldn't work with > >>>> jersey 2.x > >>>> > >>>> Cheers > >>>> > >>>> Tim > >>>> > >>>> [1] > >>>> > >>>> > >> https://github.com/andrus/wowodc13/blob/master/site/src/main/java/demo/rest/jersey/JerseyTapestryBridge.java > >>>> On 3/8/21 17:15, Ben Weidig wrote: > >>>>> Hi Tim, > >>>>> > >>>>> full disclosure: I haven't used Cayenne or Agrest, but I checked out > >>>> their > >>>>> documentation. > >>>>> > >>>>> I don't think there's anything Tapestry-specific needed to get it up > >> and > >>>>> running except setting up Rest. > >>>>> They say in their docs that you still have to write your JAX-RS > >> endpoints > >>>>> and do security yourself. > >>>>> > >>>>> For JAX-RS, there's tapestry-resteasy > >>>>> https://www.tynamo.org/tapestry-resteasy+guide/ > >>>>> There are examples how to add Rest to Tapestry and register your > >>>> resources. > >>>>> The AgRuntime should be contributable just like a Rest resource. > >> RestEasy > >>>>> treats many of its classes are contributable (Resources, Provider, > >> etc.). > >>>>> You could create a service to build it. > >>>>> > >>>>> @Contribute(javax.ws.rs.core.Application.class) > >>>>> public static void configureRestProviders(Configuration<Object> > >>>> singletons, > >>>>> YourAgRuntimeBuilder builder) { > >>>>> singletons.add(builder.build()); > >>>>> singletons.addInstance(YourCredentialsInterceptor.class); > >>>>> singletons.addInstance(YourResource.class); > >>>>> } > >>>>> > >>>>> For security, we use custom headers containing an API key/secret that > >> are > >>>>> validated by a javax.ws.rs.container.ContainerRequestFilter with > >>>>> @Priority(Priorities.AUTHENTICATION) and > >>>>> @Priority(Priorities.AUTHORIZATION) and plug in your security code. > >>>>> > >>>>> But as said before, I haven't tested it, and it just looks this way to > >> me > >>>>> at first glance. > >>>>> > >>>>> Cheers, > >>>>> Ben > >>>>> > >>>>> On Tue, Aug 3, 2021 at 5:28 AM D Tim Cummings > >>>> <t...@triptera.com.au.invalid> > >>>>> wrote: > >>>>> > >>>>>> Does anyone have experience integrating Agrest (https://agrest.io/) > >>>> into > >>>>>> a Tapestry app? My Tapestry app uses Cayenne ORM and it looks like > >>>>>> Agrest works well with Cayenne to produce REST functionality. It would > >>>>>> be helpful to see some sample code. > >>>>>> > >>>>>> Thanks in advance > >>>>>> > >>>>>> Tim > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > >> For additional commands, e-mail: users-h...@tapestry.apache.org > >> > >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org