4.6.0-SNAPSHOT of the standalone

On 10 May 2013, at 19:39, Romain Manni-Bucau <[email protected]> wrote:

> Which version do you use?
> Le 10 mai 2013 20:33, "Chris.Christo" <[email protected]> a écrit :
> 
>> sorry, where on trunk?
>> 
>> Regardless, I played around with this and managed to get it working.
>> 
>> However I have stumbled on something a little strange.
>> 
>> Basically when the exception mappers are defined at the @Config level, any
>> @EJB's within the rest class, that is being tested, do not get injected.
>> 
>> To explain a little better, here (on pastebin) we have to classes. They
>> are practically identical except for where the ExceptionMapper classes are
>> loaded, one at the @Config level and one within the @Module level defined
>> on the EjbDeployment of the OpenejbJar.
>> 
>> They both pass the test, which basically means that that the exception
>> mapping was setup correctly. However the second class
>> (ExceptionMapperAtConfigTest) passes on the basis that the service marked
>> @EJB is not injected i.e null. So basically we want this test to fail.
>> 
>> ExceptionMapperAtDeploymentTest: http://pastebin.com/aWQjjePD
>> 
>> ExceptionMapperAtConfigTest: http://pastebin.com/GFcKYWzs
>> 
>> 
>> On a side note, to have the exception mappers picked up at the @Config
>> level, you have to have the '@Classes({ GoodExceptionMapper.class,
>> BadExceptionMapper.class })' annotation defined on the method. I have no
>> idea why??
>> 
>> 
>> 
>> On 10 May 2013, at 17:35, Romain Manni-Bucau <[email protected]>
>> wrote:
>> 
>>> Hi
>>> 
>>> on trunk it is set once by jaxrs application only which is far ore easier
>>> to handle
>>> 
>>> *Romain Manni-Bucau*
>>> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
>>> *Blog: **http://rmannibucau.wordpress.com/*<
>> http://rmannibucau.wordpress.com/>
>>> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
>>> *Github: https://github.com/rmannibucau*
>>> 
>>> 
>>> 
>>> 2013/5/10 Chris.Christo <[email protected]>
>>> 
>>>> Hi
>>>> 
>>>> Hey I was just wondering if I can set my exception mappers in the
>>>> properties part of my test under the @Configuration, rather than having
>> to
>>>> apply an exception mapper to each EjbDeployment of the OpenejbJar.
>>>> 
>>>> So right now I have something like this link:
>>>> 
>>>> 
>>>> 
>> https://svn.apache.org/repos/asf/tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/CheckedExceptionMapperTest.java
>>>> 
>>>> To pick out the specific point in the link:
>>>> 
>>>> @Module
>>>> @Classes({ ExampleExceptionMapper.class })
>>>> public EjbModule module() {
>>>>   final SingletonBean bean = new SingletonBean(ExampleRest.class);
>>>>   bean.setRestService(true);
>>>> 
>>>>   final EjbJar ejbJar = new EjbJar("beans");
>>>>   ejbJar.addEnterpriseBean(bean);
>>>> 
>>>>   final OpenejbJar openejbJar = new OpenejbJar();
>>>>   openejbJar.addEjbDeployment(new EjbDeployment(bean));
>>>> 
>>>>   final Properties properties =
>>>> openejbJar.getEjbDeployment().iterator().next().getProperties();
>>>>   properties.setProperty("cxf.jaxrs.providers",
>>>> 
>> "org.apache.openejb.server.cxf.rs.CheckedExceptionMapperTest$ExampleExceptionMapper");
>>>> 
>>>>   final EjbModule module = new EjbModule(ejbJar);
>>>>   module.setOpenejbJar(openejbJar);
>>>> 
>>>>   return module;
>>>> }
>>>> 
>>>> So here I define the exception mapper (ExampleExceptionMapper) on the
>>>> properties of the specific EjbDeployment of the ExampleRest class in the
>>>> OpenejbJar.
>>>> 
>>>> Is there a way to just define it in the global properties with
>>>> @Configuration? I've tried something like this to no avail:
>>>> 
>>>> @Configuration
>>>> public Properties config() {
>>>>       final Properties props = new Properties();
>>>>       ...
>>>>       props.setProperty("openejb.cxf.jax-rs.providers",
>>>> ExampleExceptionMapper.class.getName());
>>>>       props.setProperty("openejb.jaxrs.providers.auto", "true");
>>>>       ...
>>>>       return props;
>>>> }
>>>> 
>>>> 
>>>> 
>>>> Thanks,
>>>> 
>>>> Chris
>>>> 
>>>> 
>> 
>> 

Reply via email to