title: Custom exceptions handling - java Web Services
body: <p>Its my first time posting here so please be patient and correct me whenever necessary...</p>
  
  <p>I am building simple web service-based application using NetBeans with GlassFish. NetBeans does help a lot in terms of generating code for new web services and their operations, one thing drives me mad though - web service exception handling. Operation like: </p>
  
  <pre><code>@WebMethod(operationName = "checkUserExist")
  public String checkUserExist(@WebParam(name = "login") String login, @WebParam(name = "password") String password) throws LoginException {
  
      String auth_code = "";
      bk_end.Validate val = new bk_end.Validate();
  
      boolean isValidated = val.check(login, password);
  
      if(isValidated)
      {
          auth_code = val.return_AuthCode();
          bank_services.CustomerSerice.setAuth_Code(auth_code);
          return auth_code;
      }
  
      throw new LoginException("Something is wrong!");
  
  }
  </code></pre>
  
  <p>and the exception class:</p>
  
  <pre><code>public class LoginException extends Exception
  {
      String message;
  
  
      public LoginException(String message)
      {
          super();
          this.message = message;
      }
  
      public String getErrorMessage()
      {
          return this.message;
      }
  }
  </code></pre>
  
  <p>throws a massive 
  Exceptions details : java.lang.reflect.InvocationTargetException
  plus tons of other exceptions..
  I realise it is a very much so nooby question, but after many hours of trying various things I just do not know what tot do. 
  I've read about the @WebFault thing but got no idea how to specify this correctly (attach my exception to a particular method..)</p>
  
  <p>Please help, all ideas are more than welcome!</p>
  
  <p>Exceptions that I'm getting:
  Service invocation threw an exception with message : null; Refer to the server log for more details</p>
  
  <pre><code>Exceptions details : java.lang.reflect.InvocationTargetException
  javax.servlet.ServletException: java.lang.reflect.InvocationTargetException
      at org.glassfish.webservices.monitoring.WebServiceTesterServlet.doPost(WebServiceTesterServlet.java:330)
      at org.glassfish.webservices.monitoring.WebServiceTesterServlet.invoke(WebServiceTesterServlet.java:106)
      at org.glassfish.webservices.EjbWebServiceServlet.service(EjbWebServiceServlet.java:114)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
      at com.sun.grizzly.http.servlet.ServletAdapter$FilterChainImpl.doFilter(ServletAdapter.java:1002)
      at com.sun.grizzly.http.servlet.ServletAdapter$FilterChainImpl.invokeFilterChain(ServletAdapter.java:942) 
      at com.sun.grizzly.http.servlet.ServletAdapter.doService(ServletAdapter.java:404)
      ...
  Caused by: java.lang.reflect.InvocationTargetException 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:601)
      at org.glassfish.webservices.monitoring.WebServiceTesterServlet.doPost(WebServiceTesterServlet.java:301)
      ... 24 more
  Caused by: bank_services.LoginException_Exception: excepts.LoginException
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
      at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:145)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:123)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:93)
      at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:144)
      at $Proxy383.checkUserExist(Unknown Source) ... 29 more             
  </code></pre>