Using tapestry-jpa just with tapestry-ioc in non-web project

66 views Asked by At

this is a very basic question, and I'm kind of sorry, but I don't seem to be able to get a simple Tapestry-IOC based application to work with the built-in Tapestry JPA module.

The application is not necessarily meant as a web project so the dependencies are just tapestry-ioc and tapestry-jpa for the JPA integration. I used the hibernate-entitymanager before and everything worked fine. But I thought I might rather use the official JPA support of Tapestry.

So what I did was to get the above mentioned dependencies (in Tapestry version 5.3.7) and to write the beginning of a test. This beginning looks like this

Registry registry = RegistryBuilder.buildAndStartupRegistry(MyModule.class);
EntityManager em = registry.getService(EntityManager.class);

That's all. Because as soon as I try this I get the error that no service would implement the EntityManager interface.

So I added the Tapestry JPA module:

Registry registry = RegistryBuilder.buildAndStartupRegistry(MyModule.class, JpaModule.class);

But then again I get an error that the JpaModule wants to contribute to the ApplicationStatePersistenceStrategySource service which is not present. This service seems to be defined in the TapestryModule so I did

Registry registry = RegistryBuilder.buildAndStartupRegistry(MyModule.class, JpaModule.class, TapestryModule.class);

But this causes an error due to the missing servlet API. So now I get to the point where I would have to define the web environment for Tapestry. But I don't want this, I just wanted to use the JPA integration.

Is this even possible? And if so, how do I do it? Following the documentation at http://tapestry.apache.org/integrating-with-jpa.html does not help in this regard.

Thank you very much for reading, any hint appreciated!

1

There are 1 answers

1
Bob Harner On BEST ANSWER

Quick answer -- I could be wrong -- but I thought Tapestry-jpa was intended for using JPA with Tapestry-core (the web framework). I don't think there would be any benefit over plain JPA in your case.