Create a correct 201 Created response with JAX-RS

public Response createProject(@Context UriInfo uriInfo, JsonObject json) {
        Project project = projectConverter.fromJson(json);
        project = em.merge(project);

        URI uri = uriInfo.getBaseUriBuilder()
                .resolveTemplate(PathExpressions.workspaceId, getCurrentWorkspace().getId())
                .resolveTemplate(PathExpressions.projectId, project.getId())

        return Response.created(uri).build();
The @Context UriInfo uriInfo provides information about the current URI. 
The .path(ProjectResource.class)  call will return the path used for the ProjectResource.class. 
The .resolveTemplate("{workspaceId:\\d+}", getCurrentWorkspace().getId())  will replace the workspaceId template variable for the actual wokspace id.

Once the whole path has been created, it is only needed to put it into a created response.

Load test data to DB with javaEE

In the persistence.xml file, it is possible to use the property javax.persistence.sql-load-script-source
This property allows you to populate your datasource with given data.
The value is just a sql script file containing the insert statements to be used.
Analogous, you can also use properties to drop data. Many other options are available. If you are interested, just take a look at the section *9.4 Schema Generation* from [*JSR-000338 JavaTM Persistence 2.1*](

My persistence.xml file is like follows:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
<persistence-unit name="Cookinghelper" transaction-type="JTA">
        <property name="hibernate.show_sql" value = "false" />
        <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
        <property name="javax.persistence.sql-load-script-source" value="META-INF/test-data.sql"/>