title: Throwing exception in constructor of EJB web service
body: <p>I have an EJB Web Service.  I have created custom fault classes that are thrown by web service methods and this works great.  My client catches those custom exceptions and handles them fine.  The issue I've run into is that if an exception happens in the constructor of the bean and I throw my custom exception the client doesn't receive my custom exception it receives the following:</p>
  
  <pre><code>javax.xml.ws.soap.SOAPFaultException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
  at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
  at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111)
  at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
  at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
  at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
  at $Proxy34.getLots(Unknown Source)
  </code></pre>
  
  <p>My question is: can custom exceptions be thrown in the constructor of an EJB and be received from the client?  If so what am I doing wrong.  </p>
  
  <p>My code:</p>
  
  <p>EJB Constructor</p>
  
  <pre><code>public LotManagement() throws LotManagementException
  {
      try {
          pm = new PromisManager();
      } catch (UnknownHostException ex) {
          java.util.logging.Logger.getLogger(LotManagement.class.getName()).log(Level.SEVERE, null, ex);
      } catch (IOException ex) {
          FaultBean LotManagementFaultBean = new FaultBean();
          throw new LotManagementException(ex.getMessage() + "\n\n" + propMan.getProperty("ContactMessage"), LotManagementFaultBean, ex.getCause());
      }
  }
  </code></pre>
  
  <p>Fault Bean</p>
  
  <pre><code>package com.onsemi.cim.exception;
  import javax.xml.ws.WebFault;
  
  @WebFault(name="LotManagementException")
  
  public class LotManagementException extends Exception {
  
  private static final long serialVersionUID = 1L;
  
  private FaultBean faultBean;
  
  public LotManagementException() {
      super();
  }
  
  public LotManagementException(String message, FaultBean faultBean,
          Throwable cause) {
      super(message, cause);
      this.faultBean = faultBean;
  }
  
  public LotManagementException(String message, FaultBean faultBean) {
      super(message);
      this.faultBean = faultBean;
  }
  
  public FaultBean getFaultInfo() {
      return faultBean;
  }
  
  }
  </code></pre>