title: TFS SDK 11.0.0 - Cannot save WorkItem - workItem.save() - java.lang.NullPointerException
body: <p>We are using TFS SDK version 11.0.0 connect "TFS: 2015 update 3" to get data and create defect (Bug, Issue, ...) through API. However, we encounter with NullPointerException when creating new defect by using workItem.save() method. Do we use the correct version of the TFS SDK with 'TFS 2-15 update 3'? If yes, why it through exception.</p>
  
  <pre><code>        &lt;dependency&gt;
              &lt;groupId&gt;com.microsoft.tfs.sdk&lt;/groupId&gt;
              &lt;artifactId&gt;com.microsoft.tfs.sdk&lt;/artifactId&gt;
              &lt;version&gt;11.0.0&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>Java Code: NOTE: We check workItem first before saving. Use workItem.isValid() ---> return TRUE</p>
  
  <p><a href="https://github.com/denimgroup/threadfix/blob/2.3/threadfix-main/src/main/java/com/denimgroup/threadfix/service/defects/utils/tfs/TFSClientImpl.java" rel="nofollow noreferrer">https://github.com/denimgroup/threadfix/blob/2.3/threadfix-main/src/main/java/com/denimgroup/threadfix/service/defects/utils/tfs/TFSClientImpl.java</a></p>
  
  <p>public String createDefect(String projectName, DefectMetadata metadata, String description) {
      .......
      if (checkItemValues(item)) {
          item.save(); // Throws NullPointerException HERE
      } else {
          LOG.error("Failed to create issue because one or more fields were invalid. "
                  + "Check the above logs for more details.");
      }
      ....... 
  }</p>
  
  <p>Exception Detail:
  WARN [http-nio-8080-exec-3] TFSClientImpl.createDefect(421) | Ran into TFSUnauthorizedException while trying to retrieve products.
  java.lang.NullPointerException
      at com.fasterxml.aalto.out.ByteXmlWriter.writeAttribute(ByteXmlWriter.java:461)
      at com.fasterxml.aalto.out.StreamWriterBase._writeDefaultNamespace(StreamWriterBase.java:1466)
      at com.fasterxml.aalto.out.NonRepairingStreamWriter.writeDefaultNamespace(NonRepairingStreamWriter.java:107)
      at com.microsoft.tfs.core.ws.runtime.types.DOMAnyContentType.writeElement(DOMAnyContentType.java:306)
      at com.microsoft.tfs.core.ws.runtime.types.DOMAnyContentType.writeElements(DOMAnyContentType.java:274)
      at com.microsoft.tfs.core.ws.runtime.types.DOMAnyContentType.writeAsElement(DOMAnyContentType.java:151)
      at ms.tfs.workitemtracking.clientservices._03._ClientService5Soap_Update.writeAsElement(_ClientService5Soap_Update.java:83)
      at ms.tfs.workitemtracking.clientservices._03._ClientService5Soap12Service$35.writeSOAPRequest(_ClientService5Soap12Service.java:898)
      at com.microsoft.tfs.core.ws.runtime.client.SOAPRequestEntity12.writeRequest(SOAPRequestEntity12.java:94)
      at com.microsoft.tfs.core.ws.runtime.client.BufferedSOAPRequestEntity.ensureRequestIsBuffered(BufferedSOAPRequestEntity.java:133)
      at com.microsoft.tfs.core.ws.runtime.client.BufferedSOAPRequestEntity.getContentLength(BufferedSOAPRequestEntity.java:65)
      at com.microsoft.tfs.core.httpclient.methods.EntityEnclosingMethod.getRequestContentLength(EntityEnclosingMethod.java:391)
      at com.microsoft.tfs.core.httpclient.methods.EntityEnclosingMethod.addContentLengthRequestHeader(EntityEnclosingMethod.java:474)
      at com.microsoft.tfs.core.httpclient.methods.EntityEnclosingMethod.addRequestHeaders(EntityEnclosingMethod.java:436)
      at com.microsoft.tfs.core.httpclient.HttpMethodBase.writeRequestHeaders(HttpMethodBase.java:2596)
      at com.microsoft.tfs.core.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2451)
      at com.microsoft.tfs.core.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1313)
      at com.microsoft.tfs.core.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:508)
      at com.microsoft.tfs.core.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:197)
      at com.microsoft.tfs.core.httpclient.HttpClient.executeMethod(HttpClient.java:464)
      at com.microsoft.tfs.core.httpclient.HttpClient.executeMethod(HttpClient.java:376)
      at com.microsoft.tfs.core.ws.runtime.client.SOAPService.executeSOAPRequestInternal(SOAPService.java:588)
      at com.microsoft.tfs.core.ws.runtime.client.SOAPService.executeSOAPRequest(SOAPService.java:473)
      at ms.tfs.workitemtracking.clientservices._03._ClientService5Soap12Service.update(_ClientService5Soap12Service.java:909)
      at com.microsoft.tfs.core.clients.workitem.internal.update.BaseUpdatePackage.update(BaseUpdatePackage.java:88)
      at com.microsoft.tfs.core.clients.workitem.internal.WorkItemImpl.internalSave(WorkItemImpl.java:673)
      at com.microsoft.tfs.core.clients.workitem.internal.WorkItemImpl.save(WorkItemImpl.java:388)
      at com.denimgroup.threadfix.service.defects.utils.tfs.TFSClientImpl.createDefect(TFSClientImpl.java:411)
      at com.denimgroup.threadfix.service.defects.TFSDefectTracker.createDefect(TFSDefectTracker.java:77)
      at com.denimgroup.threadfix.service.DefectSubmissionServiceImpl.submitDefect(DefectSubmissionServiceImpl.java:42)
      at com.denimgroup.threadfix.service.DefectServiceImpl.createDefect(DefectServiceImpl.java:267)
      at sun.reflect.GeneratedMethodAccessor4695.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
      at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
      at com.sun.proxy.$Proxy101.createDefect(Unknown Source)
      at com.denimgroup.threadfix.webapp.controller.DefectsController.onSubmit(DefectsController.java:112)
      at sun.reflect.GeneratedMethodAccessor4689.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:775)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
      at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:965)
      at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:867)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:841)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:720)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
      at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213)
      at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171)
      at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
      at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
      at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:231)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at com.denimgroup.threadfix.webapp.filter.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:286)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at com.denimgroup.threadfix.webapp.filter.ClickjackHeaderFilter.doFilter(ClickjackHeaderFilter.java:36)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:65)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:166)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at com.denimgroup.threadfix.webapp.filter.SessionTimeoutFilter.doFilter(SessionTimeoutFilter.java:126)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.saml.metadata.MetadataGeneratorFilter.doFilter(MetadataGeneratorFilter.java:87)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at com.denimgroup.threadfix.webapp.filter.EnterpriseFilter.doFilter(EnterpriseFilter.java:69)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at com.denimgroup.threadfix.webapp.filter.CacheBustFilter.doFilter(CacheBustFilter.java:61)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
      at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:106)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
      at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:141)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:745)</p>