Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-555

Custom @Provider in a WAR containing a beans.xml file is not used

    Details

    • Similar Issues:
      Show 10 results 

      Description

      A custom @Provider in a WAR containing a beans.xml file is not used (the default Providers take precedence).

      Cause: org.jboss.resteasy.util.Types#getSomething does not find the MessageBodyReader interface in the class hierarchy, because the Provider class is proxied by Weld.

        Gliffy Diagrams

          Activity

          Hide
          harald.pehl Harald Pehl added a comment -

          As a workaround you can exclude the custom jackson provider from weld in beans.xml:

          <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:weld="http://jboss.org/schema/weld/beans"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd
          http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">
          <weld:scan>
          <weld:exclude name="your.custom.JacksonConfigurator" />
          </weld:scan>
          </beans>

          Of course you can no longer inject other beans into your provider.

          Show
          harald.pehl Harald Pehl added a comment - As a workaround you can exclude the custom jackson provider from weld in beans.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:weld="http://jboss.org/schema/weld/beans" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd "> <weld:scan> <weld:exclude name="your.custom.JacksonConfigurator" /> </weld:scan> </beans> Of course you can no longer inject other beans into your provider.
          Hide
          john7doe Simon Søndergaard added a comment - - edited

          We have a related problem with a MessageBodyWriter for a custom type. No other provider are registered for the type.

          My finding so far indicates that the proxy provided by Weld does not have the reflection data assumed by org.jboss.resteasy.util.getSomething() so it returns null.

          MessageBodyWriter<Journal> reflection data:
          .getInterfaces: [interface javax.ws.rs.ext.MessageBodyWriter]
          .getGenericInterfaces: javax.ws.rs.ext.MessageBodyWriter<com.systematic.mercurius.samples.journal.model.Journal> (type is ParameterizedTypeImpl )

          reflection data for proxy returned by Weld:

          .getInterfaces: [interface javax.ws.rs.ext.MessageBodyWriter, interface java.io.Serializable, interface org.jboss.interceptor.proxy.LifecycleMixin, interface org.jboss.interceptor.util.proxy.TargetInstanceProxy, interface javassist.util.proxy.ProxyObject]
          .getGenericInterfaces: [interface javax.ws.rs.ext.MessageBodyWriter, interface java.io.Serializable, interface org.jboss.interceptor.proxy.LifecycleMixin, interface org.jboss.interceptor.util.proxy.TargetInstanceProxy, interface javassist.util.proxy.ProxyObject] (type of javax.ws.rs.ext.MessageBodyWriter entry is Class<T>)

          Br,
          /Simon

          Show
          john7doe Simon Søndergaard added a comment - - edited We have a related problem with a MessageBodyWriter for a custom type. No other provider are registered for the type. My finding so far indicates that the proxy provided by Weld does not have the reflection data assumed by org.jboss.resteasy.util.getSomething() so it returns null. MessageBodyWriter<Journal> reflection data: .getInterfaces: [interface javax.ws.rs.ext.MessageBodyWriter] .getGenericInterfaces: javax.ws.rs.ext.MessageBodyWriter<com.systematic.mercurius.samples.journal.model.Journal> (type is ParameterizedTypeImpl ) reflection data for proxy returned by Weld: .getInterfaces: [interface javax.ws.rs.ext.MessageBodyWriter, interface java.io.Serializable, interface org.jboss.interceptor.proxy.LifecycleMixin, interface org.jboss.interceptor.util.proxy.TargetInstanceProxy, interface javassist.util.proxy.ProxyObject] .getGenericInterfaces: [interface javax.ws.rs.ext.MessageBodyWriter, interface java.io.Serializable, interface org.jboss.interceptor.proxy.LifecycleMixin, interface org.jboss.interceptor.util.proxy.TargetInstanceProxy, interface javassist.util.proxy.ProxyObject] (type of javax.ws.rs.ext.MessageBodyWriter entry is Class<T>) Br, /Simon
          Hide
          bill.burke Bill Burke added a comment -

          I am able to use a simple @Provider with CDI. How can I reproduce any of these problems? I am using JBoss AS 7.1.1.

          Show
          bill.burke Bill Burke added a comment - I am able to use a simple @Provider with CDI. How can I reproduce any of these problems? I am using JBoss AS 7.1.1.
          Hide
          bill.burke Bill Burke added a comment -

          Ok, i can reproduce it. Have the "Journal" class be a JAXB object and write a custom, overriding provider for it.

          Show
          bill.burke Bill Burke added a comment - Ok, i can reproduce it. Have the "Journal" class be a JAXB object and write a custom, overriding provider for it.
          Hide
          bill.burke Bill Burke added a comment -

          Yes, you were exactly right. This is a proxy problem. It is now fixed in 2.3.3. Thank you for patience.

          Show
          bill.burke Bill Burke added a comment - Yes, you were exactly right. This is a proxy problem. It is now fixed in 2.3.3. Thank you for patience.

            People

            • Assignee:
              bill.burke Bill Burke
              Reporter:
              agattik Alexandre Gattiker
            • Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development