TomEE/OpenEJB JAXRS refactoring


Until TomEE 1.5.1 JAXRS deployment policy was to map a servlet by endpoint.

This had two drawbacks:

  • you had to put @Path at class level for all JAXRS classes
  • The entry point for a request was the servlet router (Tomcat) and not the JAXRS one so the routing wasn’t as fine as possible with JAXRS

The advantage was each endpoint were configurable separately.

That’s said in real life it was very rarely used. So finally more drawback than advantages. That’s why deployment was reworked to deploy the application instead of deploying endpoints (classes).

What does it mean in practise?

  • for 100% JAXRS applications already working on TomEE -> nothing
  • for applications not working because of missing @Path at class level -> it should work now
  • for applications using openejb-jar.xml to configure endpoints -> configuration to update (see below)

Configuration

Before the deployment unit was the endpoint so you were able to configure the endpoint (providers, databinding…). Now the deployment unit is the application so you configure the application. To do it define a pojo-deployment in openejb-jar.xml specifying the application class name as class-name. If you didn’t define an application class just use “jaxrs-application” as class-name value.

Then the configuration is the same as before:

<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
  <pojo-deployment class-name="jaxrs-application">
    <properties>
      cxf.jaxrs.providers = org.foo.BarProvider, some-id-of-resourcexml
    </properties>
  </pojo-deployment>
</openejb-jar>

If you still want to deploy by endpoint (and loose the advantages of the previous part) just set the system property:

openejb.jaxrs.application = false

Note: for providers it can be interesting to note you can put them in the Application#getClasses() too (and get rid of openejb-jar.xml)

Advertisement

2 thoughts on “TomEE/OpenEJB JAXRS refactoring

  1. chrisowensboston

    “Note: for providers it can be interesting to note you can put them in the Application#getClasses() too (and get rid of openejb-jar.xml)” — What does this mean?

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s