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

Cannot declare web service resource using @WebServiceRef

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 1.1.2.Final
    • Fix Version/s: 1.1.8.Final, 2.0.0.Alpha3
    • Component/s: None
    • Labels:
      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());
            }
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mkouba Martin Kouba
                  Reporter:
                  mkouba Martin Kouba
                • Votes:
                  2 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: