Works with RestEASY 1.1.GA but not with newer versions
Works ONLY with singleton resources
Requires Tapestry 5.1.x

User guide for Tapestry-resteasy module

Tapestry-resteasy provides integration with JBoss' RESTEasy, an implementation JAX-RS (Java API for RESTful Web Services). JAX-RS is a very nice little spec and if you know what it is about, the following should be very easy to understand. Otherwise, read up on it at Jersey's overview (the reference implementation) or the actual specification. JBoss' RESTEasy provides a few more features over the reference implementation.

To use tapestry-resteasy (an independent module of Tynamo), you need to add the following dependency to your pom.xml:


Modify your web.xml to include the following:







Create a package named "rest" for your rest services.
Code your singleton resource.
Good practices:

For example:


import org.tynamo.examples.simple.MyDomainObject;

import java.util.List;

public class MyDomainObjectResource

	private PersistenceService persistenceService;

	public MyDomainObjectResource(PersistenceService persistenceService) {
		this.persistenceService = persistenceService;

	public List<MyDomainObject> getAllDomains()
		return (persistenceService.getInstances(MyDomainObject.class));

	public Response post(MyDomainObject domainObject)
		return Response.ok().build();

	public MyDomainObject getDomainObject(@PathParam("id") Long id)
		MyDomainObject domainObject = persistenceService.getInstance(MyDomainObject.class, id);
		if (domainObject == null)
			throw new WebApplicationException(Response.Status.NOT_FOUND);
		return domainObject;


Don't forget to annotate your entities with JAXB annotations. You need at least @XmlRootElement.

For example:

package org.tynamo.examples.simple.entities;

import org.hibernate.validator.NotNull;
import org.tynamo.descriptor.annotation.PropertyDescriptor;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "mydomainobject")
public class MyDomainObject
	private Long id;

	private String name;

	@GeneratedValue(strategy = GenerationType.AUTO)
	@PropertyDescriptor(index = 0)
	public Long getId()
		return id;

	public void setId(Long id)
	{ = id;

	@NotNull(message = "name can't be null")
	public String getName()
		return name;

	public void setName(String name)
	{ = name;

	public boolean equals(Object o)
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		MyDomainObject that = (MyDomainObject) o;

		return getId() != null ? getId().equals(that.getId()) : that.getId() == null;

	public int hashCode()
		return (getId() != null ? getId().hashCode() : 0);

	public String toString()
		return getName();

Finally contribute your singleton resource to your AppModule:

	 * Contributions to the RESTeasy main Application, insert all your singletons RESTeasy services here.
	public static void contributeApplication(Configuration<Object> singletons, ObjectLocator locator)

And enjoy.


If you get this exception:

Caused by: java.lang.ClassCastException: cannot be cast to org.codehaus.stax2.XMLInputFactory2

Add this to your system properties:

like so:

<!-- Run the application using "mvn jetty:run" -->
		<!-- Log to the console. -->
		<requestLog implementation="org.mortbay.jetty.NCSARequestLog">
			<!-- This doesn't do anything for Jetty, but is a workaround for a Maven bug
				 that prevents the requestLog from being set. -->

Check google for more information: