title: Web Services Exception
body: <p>I have a problem that is driving me crazy. I have developed some Web Services with Netbeans in Linux and they work just fine (with Tomcat). I can call the services with SOAPUI and everything looks good.
  The problem arises when I build a WAR file and try to deploy it in a Tomcat installation over Windows. Then I get this:</p>
  
  <pre><code>...
  INFO: WSSERVLET13: JAX-WS context listener destroyed
  Sep 17, 2012 4:28:08 PM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
  INFO: WSSERVLET12: JAX-WS context listener initializing
  Sep 17, 2012 4:28:09 PM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
  SEVERE: WSSERVLET11: failed to parse runtime descriptor: javax.xml.ws.WebServiceException: Unable to create JAXBContext
  javax.xml.ws.WebServiceException: Unable to create JAXBContext
      at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:166)
      at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:94)
      at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:258)
      at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:338)
      at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:201)
      at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:505)
      at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
      at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
      at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:124)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1255)
      at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:714)
      at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:219)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:186)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  Caused by: java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
  java.lang.StackTraceElement does not have a no-arg default constructor.
      this problem is related to the following location:
          at java.lang.StackTraceElement
          at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
          at java.lang.Throwable
          at public java.lang.Throwable[] my.org.jaxws.MyExceptionBean.suppressed
          at umy.org.jaxws.MyExceptionBean
  
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:153)
      ... 38 more
  Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
  java.lang.StackTraceElement does not have a no-arg default constructor.
      this problem is related to the following location:
          at java.lang.StackTraceElement
          at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
          at java.lang.Throwable
          at public java.lang.Throwable[] my.org.jaxws.MyExceptionBean.suppressed
          at my.org.jaxws.MyExceptionBean
  
      at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:472)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.&lt;init&gt;(JAXBContextImpl.java:302)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
      at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
      at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:106)
      at com.sun.xml.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:109)
      at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:161)
      at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:154)
      ... 40 more
  </code></pre>
  
  <p>So I guess there is a problem with the exception I raise in a service:</p>
  
  <pre><code>@WebMethod(...)
  public ..... throws Exception {
   if ()...
   else
      throw new MyException(); // extends java.lang.Exception
  }
  </code></pre>
  
  <p>First thing I do not understand is why this works fine in my Netbeans Tomcat over Linux and not in the Windows Tomcat I have installed.
  I have checked some information:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/2064447/jax-ws-map-exceptions-to-faults">JAX-WS - Map Exceptions to faults</a></li>
  <li><a href="https://stackoverflow.com/questions/7232331/unable-to-create-jaxbcontext-creating-my-wsdl">Unable to create JAXBContext creating my wsdl</a></li>
  <li><a href="http://io.typepad.com/eben_hewitt_on_java/2009/07/using-soap-faults-and-exceptions-in-java-jaxws-web-services.html" rel="nofollow noreferrer">SOAP faults</a></li>
  <li><a href="http://www.ibm.com/developerworks/webservices/library/ws-jaxws-faults/index.html" rel="nofollow noreferrer">IBM</a></li>
  </ul>
  
  <p>And see more other Websites. It is not clear for me what to do. Some webs advice to use a "workaround" including the @WebFault and create additional methods in the class and a dummy POJO class. I have many exceptions and seems a lot of work. Some suggest to remove a JAR (I do not really have) from the classpath. I am still wondering what I have in my Netbeans Tomcat that is not in my Windows Tomcat. I am quite new in this.</p>
  
  <p>Is there an easy way to solve this? Many thanks.</p>
  
  <p><strong>==== EDIT ====</strong></p>
  
  <p>As suggested in some answers, I have unsuccessfully tried:</p>
  
  <pre><code>@XmlTransient
      @Override
      public StackTraceElement[] getStackTrace() {
          return super.getStackTrace();
      }
  
      @XmlTransient
      @Override
      public Throwable getCause() {
          return super.getCause();
      }
  </code></pre>
  
  <p>Also, if I use @WebFault, I get another exception (this time even on Linux):</p>
  
  <pre><code>SEVERE: WSSERVLET11: failed to parse runtime descriptor: java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
  java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
          at com.sun.xml.ws.model.RuntimeModeler.processExceptions(RuntimeModeler.java:1162)
          at com.sun.xml.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:898)
          at com.sun.xml.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:666)
          at com.sun.xml.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:420)
          at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:254)
          at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:338)
          at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:201)
          at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:505)
          at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
          at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
          at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:124)
          at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
          at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
          at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:521)
          at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1359)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:616)
          at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:857)
          at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:795)
          at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1500)
          at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:849)
          at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:351)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:199)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
          at java.lang.Thread.run(Thread.java:636)
  </code></pre>
  
  <p>I have tried to implement the messageName() but nothing worked.
  I have followed the indications of other questions but does not work. The code is:</p>
  
  <pre><code>import javax.xml.bind.annotation.XmlAttribute;
  import javax.xml.bind.annotation.XmlType;
  
  @XmlType(name = "InputMessageValidationFaultType")
  public class FaultBean {
  
  @XmlAttribute
      protected String message;
  
      public String getMessage(){
          return message;
      }
  
      public void setMessage(String message){
          this.message = message;
      }
  
  }
  
  
  
  
  import javax.xml.ws.WebFault;
  import javax.xml.bind.annotation.XmlRootElement;
  import javax.xml.bind.annotation.XmlTransient;
  
  
  @WebFault(faultBean = "FaultBean")
  public class MyException extends Exception {
  
      private static final long serialVersionUID = 1L;
  
      private FaultBean faultBean;
  
      public  MyException(){
          super();
      }
  
      public  MyException( String message , FaultBean faultBean , Throwable cause){
          super(message, cause);
          this.faultBean = faultBean;
      }    
  
      public  MyException( String message, FaultBean faultBean ){
          super(message);
          this.faultBean = faultBean;
      }    
  
      public FaultBean getFaultInfo() {
          return faultBean;
      }
  
  }
  </code></pre>
  
  <p>It is still strange for me that everything works just fine on my Netbeans/Tomcat/Linux and fails when I move the WAR to the Tomcat/Windows....</p>