Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-993

Cannot declare web service resource using @WebServiceRef

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 1.1.8.Final, 2.0.0.Alpha3
    • 1.1.2.Final
    • None
    • None

    Description

      Following web service resource definition (see CDI 1.0 section 3.5 Resources) results in:
      WELD-000025 Tried to create an EEResourceProducerField, but no @Resource, @PersistenceContext, @PersistenceUnit, @WebServiceRef or @EJB is present

      public class SheepWSProducer {
      
          @Produces
          @WebServiceRef
          SheepWS sheepWS;
      }
      

      There is no CDI TCK test for this yet.

      The problem is very likely related to weird checking code in org.jboss.weld.bean.builtin.ee.EEResourceProducerField.checkEEResource() - the first group evaluates to false and is inverted to true with "!" operator and thus exception is thrown:

      ...
       if (!
      (
      getWeldAnnotated().isAnnotationPresent(ejbApiAbstraction.RESOURCE_ANNOTATION_CLASS) 
      || getWeldAnnotated().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_CONTEXT_ANNOTATION_CLASS) 
      || getWeldAnnotated().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_UNIT_ANNOTATION_CLASS) 
      || getWeldAnnotated().isAnnotationPresent(ejbApiAbstraction.EJB_ANNOTATION_CLASS)
      ) 
      || getWeldAnnotated().isAnnotationPresent(wsApiAbstraction.WEB_SERVICE_REF_ANNOTATION_CLASS)
      )
            {
               throw new IllegalStateException(INVALID_RESOURCE_PRODUCER_FIELD, getWeldAnnotated());
            }
      ...
      

      Should be replaced with something like:

      ...
       if (!
      (
      getWeldAnnotated().isAnnotationPresent(ejbApiAbstraction.RESOURCE_ANNOTATION_CLASS) 
      || getWeldAnnotated().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_CONTEXT_ANNOTATION_CLASS) 
      || getWeldAnnotated().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_UNIT_ANNOTATION_CLASS) 
      || getWeldAnnotated().isAnnotationPresent(ejbApiAbstraction.EJB_ANNOTATION_CLASS)
      || getWeldAnnotated().isAnnotationPresent(wsApiAbstraction.WEB_SERVICE_REF_ANNOTATION_CLASS)
      )
      )
            {
               throw new IllegalStateException(INVALID_RESOURCE_PRODUCER_FIELD, getWeldAnnotated());
            }
      

      Attachments

        Issue Links

          Activity

            People

              mkouba@redhat.com Martin Kouba
              mkouba@redhat.com Martin Kouba
              Votes:
              2 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: