Re: Integrating Agrest in Tapestry app
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 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 > > 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 > >> > >> > >> org.tynamo > >> tapestry-resteasy > >> 0.7.0 > >> > >> > >> - 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 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 > >> 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. > >>> > >>> > >>
Re: [RELEASE] Apache Tapestry 5.7.3 released
On 16.8.21 14:45, Thiago H. de Paula Figueiredo wrote: - Upgrading Hibernate's version from 5.1.1.Final to 5.4.32.Final. This required some changes in tapestry-hibernate due to some non-backward-compatible changes between these 2 Hibernate versions. I'm experiencing some issue where session.createQuery always returns a null in the constructor of a SessionState object, after moving to 5.7.3. Otherwise everything works and is a welcome upgrade. Are there any differences in how and when Tapestry creates the hibernate session and how this behaves after this upgrade? More details: I have a @SessionState UserInfo in each page where the authenticated user details are needed. The UserInfo class constructor calls a PersonManager service to find the logged-in user details. Authentication is external so it is not part of the problem. Apereo CAS, over all paths of the server, so that request.remoteUser contains the loggedin user name. In this personManager i have @Inject Session session and i have session.createQuery. Now the strange change in behaviour is that after upgrade to 5.7.3, all calls to session.CreateQuery always return null when personManager is called in the UserInfo constructor. Whatever query I use, it returns a null. As if the session is not working. But the session is not null, the session object status is OK and session object connection status is ok. If I call the personManager directly from a page (setupRender or property getter) everything works fine. Probably something is not written as it supposed to be and I need to refactor. Maybe we are not supposed to fill-in the UserInfo session state object details during its construction, but later. But this piece of code is more than 10 years old and has survived over all the Tapestry 5.x.x upgrades in the meanwhile and worked fine until now. UserInfo example: https://github.com/ajanovski/eprms/blob/main/eprms-tap/src/main/java/info/ajanovski/eprms/tap/util/UserInfo.java PersonImpl example (nothing special here): public class PersonDaoImpl implements PersonDao { @Inject private Logger logger; @Inject private Session session; @Override public List getAllPersons() { try { return session.createQuery("from Person order by lastName").list(); } catch (Exception e) { return null; } } @Override public Person getPersonByUsername(String username) { try { return (Person) (session .createQuery("from Person where userName=:param") .setParameter("param", username).setReadOnly(true) .setCacheable(true).uniqueResult()); } catch (Exception e) { return null; } } In case it matters, there is a ComponentRequestFilter to protect access to pages depending on the user role, implemented like this: https://github.com/ajanovski/eprms/blob/main/eprms-tap/src/main/java/info/ajanovski/eprms/tap/services/AccessController.java - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: [RELEASE] Apache Tapestry 5.7.3 released
Thanks Thiago! Great job! On Mon, Aug 16, 2021 at 2:45 PM Thiago H. de Paula Figueiredo < thiag...@gmail.com> wrote: > Hello, community! > > Tapestry 5.7.3 has just been released. It's a new release focused on some > improvements and new features. Main ones are: > > >- Upgrading Hibernate's version from 5.1.1.Final to 5.4.32.Final. This >required some changes in tapestry-hibernate due to some >non-backward-compatible changes between these 2 Hibernate versions. If > your >project doesn't work with this new Hibernate version, you should be > able to >use version 5.7.2 of tapestry-hibernate and tapestry-hibernate with > 5.7.3 >of everything else without issues. >- Introducing tapestry-spock, an integration of Tapestry with the Spock >testing framework, which used to be part of the Spock project. > > Unfortunately, the Tapestry site isn't updating at the moment due to an > internal process being broken. > > Your feedback is always welcome! > > Cheers! > > -- > Thiago > -- Massimo Lusetti
Re: [RELEASE] Apache Tapestry 5.7.3 released
I forgot to mention you can see the 5.7.3 release notes at https://cwiki.apache.org/confluence/display/TAPESTRY/Release+Notes+5.7.3 until the main site is updated. On Mon, Aug 16, 2021 at 9:45 AM Thiago H. de Paula Figueiredo < thiag...@gmail.com> wrote: > Hello, community! > > Tapestry 5.7.3 has just been released. It's a new release focused on some > improvements and new features. Main ones are: > > >- Upgrading Hibernate's version from 5.1.1.Final to 5.4.32.Final. This >required some changes in tapestry-hibernate due to some >non-backward-compatible changes between these 2 Hibernate versions. If your >project doesn't work with this new Hibernate version, you should be able to >use version 5.7.2 of tapestry-hibernate and tapestry-hibernate with 5.7.3 >of everything else without issues. >- Introducing tapestry-spock, an integration of Tapestry with the >Spock testing framework, which used to be part of the Spock project. > > Unfortunately, the Tapestry site isn't updating at the moment due to an > internal process being broken. > > Your feedback is always welcome! > > Cheers! > > -- > Thiago > -- Thiago
[RELEASE] Apache Tapestry 5.7.3 released
Hello, community! Tapestry 5.7.3 has just been released. It's a new release focused on some improvements and new features. Main ones are: - Upgrading Hibernate's version from 5.1.1.Final to 5.4.32.Final. This required some changes in tapestry-hibernate due to some non-backward-compatible changes between these 2 Hibernate versions. If your project doesn't work with this new Hibernate version, you should be able to use version 5.7.2 of tapestry-hibernate and tapestry-hibernate with 5.7.3 of everything else without issues. - Introducing tapestry-spock, an integration of Tapestry with the Spock testing framework, which used to be part of the Spock project. Unfortunately, the Tapestry site isn't updating at the moment due to an internal process being broken. Your feedback is always welcome! Cheers! -- Thiago