Can I use RESTEasy to deploy an endpoint to the GateIn/eXo portal context?

Solution Unverified - Updated -

Environment

  • JBoss Portal Platform (JPP)
    • 6.x

Issue

How to deploy a JAX-RS resource and integrate it with the portal container. I add this to my portal configuration to configure the integration:

<component>
  <type>com.redhat.gss.rest.MyRESTService</type>
</component>

This is to be deployed using RESTEasy, but I'm experiencing issues trying to do this. How can this be done using RESTEasy?

A couple errors we see in our log:

java.lang.NullPointerException  
    at org.jboss.resteasy.util.PathHelper.replaceEnclosedCurlyBraces(PathHelper.java:53) 
    at org.jboss.resteasy.util.Encode.savePathParams(Encode.java:277) 
    at org.jboss.resteasy.util.Encode.encodeValue(Encode.java:303) 
    at org.jboss.resteasy.util.Encode.encodeFragment(Encode.java:182) 
    at org.jboss.resteasy.specimpl.UriBuilderImpl.fragment(UriBuilderImpl.java:329) 
java.lang.ClassCastException: org.exoplatform.services.rest.impl.RuntimeDelegateImpl cannot be cast to org.jboss.resteasy.spi.ResteasyProviderFactory,

During Arquillian tests with JPP getting the following issue

java.lang.ClassCastException: org.exoplatform.services.rest.impl.RuntimeDelegateImpl cannot be cast to org.jboss.resteasy.spi.ResteasyProviderFactory

Resolution

RESTEasy cannot be used to deploy JAX-RS resources that are to be integrated into the portal kernel/container.

The best way to make this work is to follow the directions in this knowledgebase solution: How can I add a JAX-RS resource to the GateIn/eXo portal context in JPP 6.x?.

If you must package your JAX-RS resource in a .war, then you need to disable the JAX-RS subsystem from your deployment so RESTEasy does not automatically try to deploy your resource outside of the eXo container.

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
  <deployment>
    <exclude-subsystems>
      <subsystem name="jaxrs"/>
    </exclude-subsystems>
  </deployment>
</jboss-deployment-structure>

Root Cause

  • Behind the scenes, eXo simply takes all JAX-RS resources found in the set of portal components and that implement org.exoplatform.services.rest.resource.ResourceContainer and adds them to the set of resources returned in its own javax.ws.rs.core.Application 1. Therefore you cannot use a separate JAX-RS implementation to deploy your resource than what eXo uses since eXo is actually deploying your resource in the same JAX-RS application as all the other portal resources.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments