Note that there are some explanatory texts on larger screens.

plurals
  1. POTomEE embedded and custom JAX-RS application deployment
    primarykey
    data
    text
    <p>I guys, I'm using TomEE 1.6.0 (jax-rs) with a custom Application :</p> <pre><code>@ApplicationPath("/rest") public class Whatever extends Application {...} </code></pre> <p>I do it in order to customize the base path for my REST services and to add a custom provider for every endpoints of this Application :</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1"&gt; &lt;pojo-deployment class-name="Whatever"&gt; &lt;properties&gt; cxf.jaxrs.providers = WhateverProvider &lt;/properties&gt; &lt;/pojo-deployment&gt; &lt;/openejb-jar&gt; </code></pre> <p>I have a sample JAX-RS endpoint defined like this :</p> <pre><code>@Path("/whatever") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public class WhateverEndpoint {...} </code></pre> <p>Everything works fine when deploying in TomEE jax-rs (<strong>tomee-maven-plugin:start</strong>). I can call my services on <strong>/rest/whatever</strong></p> <p>The problem is when I want to unit test this service with TomEE Embedded, <strong>WhateverEndpoint</strong> is not deployed...</p> <p>The configuration I use for the tests setup (@BeforeClass) is the following :</p> <pre><code>Properties properties = new Properties(); properties.setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true"); context = EJBContainer.createEJBContainer(properties).getContext(); </code></pre> <p>I can test the DAO and so on but not the Endpoints... When I add a @javax.ejb.* annotation like this :</p> <pre><code>@Singleton @Path("/whatever") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public class WhateverEndpoint {...} </code></pre> <p>I have something better in the logs :</p> <pre><code>INFO - Initializing network services INFO - REST Application: http://127.0.0.1:4204/web -&gt; org.apache.openejb.server.rest.InternalApplication INFO - Service URI: http://127.0.0.1:4204/web/whatever -&gt; EJB Whatever INFO - GET http://127.0.0.1:4204/web/whatever/a -&gt; A a(HttpServletRequest) INFO - ** Bound Services ** INFO - NAME IP PORT INFO - httpejbd 127.0.0.1 4204 INFO - admin 127.0.0.1 4200 INFO - ejbd 127.0.0.1 4201 INFO - ejbds 127.0.0.1 4203 </code></pre> <p>What should I do to make it works properly with my custom JAX-RS Application, Path and Provider, just like the TomEE JAX-RS do and without adding ejb annotations ? Should I define additional properties and which one when creating my EJBContainer ? I've see some in the sample applications :</p> <ul> <li><a href="https://github.com/apache/tomee/blob/trunk/examples/rest-on-ejb" rel="nofollow">https://github.com/apache/tomee/blob/trunk/examples/rest-on-ejb</a></li> <li><a href="https://github.com/apache/tomee/blob/trunk/examples/rest-example" rel="nofollow">https://github.com/apache/tomee/blob/trunk/examples/rest-example</a></li> </ul> <p>But none of them are working.</p> <p>Here is my pom.xml :</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.apache.openejb&lt;/groupId&gt; &lt;artifactId&gt;javaee-api&lt;/artifactId&gt; &lt;version&gt;6.0-5&lt;/version&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.openejb&lt;/groupId&gt; &lt;artifactId&gt;tomee-embedded&lt;/artifactId&gt; &lt;version&gt;${tomee.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.openejb&lt;/groupId&gt; &lt;artifactId&gt;openejb-cxf-rs&lt;/artifactId&gt; &lt;version&gt;${openejb.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.openejb&lt;/groupId&gt; &lt;artifactId&gt;tomee-jaxrs&lt;/artifactId&gt; &lt;version&gt;${tomee.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload