title: JAX-WS and CDI not working together on WAS Liberty Profile 8.5.5.6
body: <p>I am experiencing strange behavior when I attempt to combine a JAX-WS web service endpoint class and a simple CDI injection.  When I try to inject the object into the WebService implementation class, the injected object's PostConstruct method is never called.  Indeed the classes constructor is not called either.</p>
  <p>Here is my JAX-WS implementation class and the injection point:</p>
  <pre><code>@WebService(serviceName=&quot;eBusinessWebService&quot;)
  public class eBusinessWebServiceImpl
  {
  
      @WebMethod
      public SubmissionValidationResults xmlValidation(String xml, String submissionType, String schemaVersion)
              throws SOAPException
      {          
          // Validate schema
          SubmissionValidationResults results = fileSubmissionServiceHandler.validateXML(xml, submissionType,
                  schemaVersion);
          
          return results;
      }
  
      @Inject
      private FileSubmissionServiceHandler fileSubmissionServiceHandler;
  
      @Inject
      private BRSubmissionService brSubmissionService;
  }
  </code></pre>
  <p>And here is my injected class, the FileSubmissionServiceHandler:</p>
  <pre><code>public class FileSubmissionServiceHandler
  {
      public FileSubmissionServiceHandler()
      {
          System.out.println(&quot;Constructor being called on FileSubmissionServiceHandler&quot;);
      }
  
      @PostConstruct
      public void init()
      {
          final String webserviceURL = &quot;https://hostname/FileSubmissionService/FileSubmissionService.svc&quot;;
          final String username = &quot;username&quot;;
          final String password = &quot;password&quot;;
          
          this.webservice = new BasicHttpsBinding_IFileSubmissionServiceProxy(username, password);
          Descriptor desc = webservice._getDescriptor();
          desc.setEndpoint(webserviceURL);
      }
      
      public SubmissionValidationResults validateXML(String xml, String submissionType,
              String schemaVersion) throws WebServiceException
      {
          SubmissionValidationResults results = null;
          FormType type = FormType.getByName(submissionType);
          String submissionTypeCode = type.getCode();
  
          try
          {
              results = this.webservice.validateXmlFile(xml, submissionTypeCode, schemaVersion);
              
          }
          catch (Exception e)
          {
              logger.error(&quot;Internal FileSubmissionService threw an exception&quot;, e);
              throw e;
          }
  
          return convertSubmissionValidationResults(results);
      }
  
      private BasicHttpsBinding_IFileSubmissionServiceProxy webservice;
  }
  </code></pre>
  <p>I was asked to post my server XML (overriding port settings due to two copies of the Liberty profile running at one time):</p>
  <pre><code>&lt;server description=&quot;new server&quot;&gt;
  
  &lt;!-- Enable features --&gt;
  &lt;featureManager&gt;
      &lt;feature&gt;jaxws-2.2&lt;/feature&gt;
      &lt;feature&gt;servlet-3.1&lt;/feature&gt;
      &lt;feature&gt;cdi-1.2&lt;/feature&gt;
  &lt;/featureManager&gt;
  
  &lt;!--For a user registry configuration, configure your user registry. For 
      example, configure a basic user registry using the basicRegistry element. 
      Specify your own user name below in the name attribute of the user element. 
      For the password, generate an encoded password using bin/securityUtility 
      encode and add it in the password attribute of the user element. Then uncomment 
      the user element. --&gt;
  &lt;basicRegistry id=&quot;basic&quot; realm=&quot;BasicRealm&quot;&gt;
      &lt;user name=&quot;wasadmin&quot; password=&quot;{xor}KD4sPjsyNjE=&quot; /&gt;
  &lt;/basicRegistry&gt;
  
  &lt;keyStore password=&quot;{xor}KD4sPjsyNjE=&quot; /&gt;
  
  &lt;!-- To access this server from a remote client add a host attribute to 
      the following element, e.g. host=&quot;*&quot; --&gt;
  &lt;httpEndpoint host=&quot;*&quot; httpPort=&quot;9090&quot; httpsPort=&quot;9445&quot;
      id=&quot;defaultHttpEndpoint&quot; /&gt;
  
  &lt;wasJmsEndpoint wasJmsPort=&quot;7277&quot; wasJmsSSLPort=&quot;7287&quot; /&gt;
  
  &lt;iiopEndpoint host=&quot;localhost&quot; id=&quot;defaultIiopEndpoint&quot;
      iiopPort=&quot;2814&quot;&gt;
      &lt;iiopsOptions iiopsPort=&quot;2815&quot; /&gt;
  &lt;/iiopEndpoint&gt;
  
  &lt;applicationMonitor updateTrigger=&quot;mbean&quot; /&gt;
  
  &lt;enterpriseApplication id=&quot;eBusinessWebService_EAR&quot;
      location=&quot;eBusinessWebService_EAR.ear&quot; name=&quot;eBusinessWebService_EAR&quot; /&gt;
  </code></pre>
  
  <p>And Logs:</p>
  <pre><code>Launching defaultServer (WebSphere Application Server 8.5.5.6/wlp-1.0.9.cl50620150610-1749) on Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_79-b15 (en_US)
  [AUDIT   ] CWWKE0001I: The server defaultServer has been launched.
  [AUDIT   ] CWWKE0100I: This product is licensed for development, and limited production use. The full license terms can be viewed here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/license/base_ilan/ilan/8.5.5.6/lafiles/en.html
  [AUDIT   ] CWWKZ0058I: Monitoring dropins for applications. 
  [WARNING ] CWNEN0047W: Resource annotations on the fields of the xxx.important.not.external.service.eBusinessWebServiceImpl class will be ignored. The annotations could not be obtained because of the exception : java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware
  [AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:9090/eBusinessWebService/
  [AUDIT   ] CWWKZ0001I: Application eBusinessWebService_EAR started in 3.011 seconds.
  [AUDIT   ] CWWKF0012I: The server installed the following features: [jaxws-2.2, cdi-1.2, servlet-3.1, jndi-1.0, javaMail-1.5, jaxb-2.2].
  [AUDIT   ] CWWKF0011I: The server defaultServer is ready to run a smarter planet.
  20-01-2016 - 10:02:47 - INFO  (eBusinessWebServiceImpl.java:31) - --- Validating Incomming Form XML ---
  20-01-2016 - 10:02:47 - INFO  (eBusinessWebServiceImpl.java:33) - Received Payload: XML [Hello]
  20-01-2016 - 10:02:47 - INFO  (eBusinessWebServiceImpl.java:34) - SubmissionType [from the]
  20-01-2016 - 10:02:47 - INFO  (eBusinessWebServiceImpl.java:35) - SchemaVersion [other side]
  [WARNING ] Application {http://service.external.not.important.xxx/}eBusinessWebService#{http://service.external.not.important.xxx/}xmlValidation has thrown exception, unwinding now
  java.lang.NullPointerException
  </code></pre>
  <p>I have redacted some of the less relevant details of each class, but the basic operations are the same.  When I attempt to access the &quot;validateXML&quot; method of the fileSubmissionServiceHandler object, a null pointer exception is thrown, and I never see the output from the postConstruct or constructor methods in my FileSubmissionServiceHandler class.  Using the debugger, these methods are never reached.</p>
  <p>Things I have checked so far:</p>
  <ol>
  <li>I have an empty beans.xml file in my WEB-INF folder</li>
  <li>I am including the javaee-7.0 feature in the server.xml which includes jax-ws and cdi</li>
  <li>I also tried adding both application scope and request scope to the FileSubmissionServiceHandler with no effect.</li>
  </ol>
  <p>Does anyone have any ideas why this would not work?</p>