5 Replies Latest reply on Jan 16, 2009 6:41 AM by chetan padhye

    Throws exception in WS (back to remote client) without gener

    Michael J. Hammel Newbie

      I've got a Web Service running with a remote client. I've added my own exception class that I throw back to the remote client as needed. The client gets the exception okay. However, the thrown exception shows up on the server console as

      15:27:24,433 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
      com.cei.crunch.server.exception.WebServiceException: Testing remote exception passing.

      Is there a way to prevent this from happening on the server side? The thrown exception might just be a response like "item not found" when looking something up on the db, so it's not something that should show up in the server console long.

        • 1. Re: Throws exception in WS (back to remote client) without g
          Michael J. Hammel Newbie

          This is still a problem for me, and I'm hoping someone has a pointer as to how I can get rid of the server side stack trace's when I generate an application exception in my web service.

          Here is the Web Service:

          package com.cei.crunch.server.ws.KernelServices;
          import javax.ejb.*;
          import javax.persistence.*;
          import javax.jws.WebService;
          import javax.jws.WebMethod;
          import javax.jws.soap.SOAPBinding;
          import org.apache.log4j.Logger;
          import com.cei.crunch.ejb.*;
          import com.cei.crunch.exception.*;
          /* Make this an EJB3 service endpoint. */
          /* Make this an Web Services endpoint. */
           name = "KernelWS",
           endpointInterface = "com.cei.crunch.server.ws.KernelServices.KernelServicesEndpoint"
          @SOAPBinding(style = SOAPBinding.Style.RPC)
           * The .Crunch interface to Kernel Services
          public class KernelServices implements KernelServicesEndpoint {
           private static final Logger logPolicy = Logger.getLogger("com.cei.crunch.kernel.policy");
           public Policymgmt findPolicyMgmt(String guid) throws CrunchWSException
           PolicymgmtBean pb = null;
           Policymgmt pm = null;
           pb = new PolicymgmtBean();
           if ( pb == null )
           logPolicy.info("Failed to get PolicymgmtBean.");
           String msg = null;
           try {
           pm = pb.findPolicyMgmt(guid);
           catch (CrunchEJBException e) {
           throw new CrunchWSException(e.getMessage());
           if ( pm != null )
           logPolicy.info("Policymgmt info: \n" +
           "PolicyName: " + pm.getPolicyName() + "\n" +
           "Value : " + pm.getPolicyValue() + "\n"
           return pm;

          Here is the client that calls it:

          package wsKernel;
          import java.net.URL;
          import javax.xml.ws.*;
          import javax.jws.*;
          /* Web Services interfaces */
          import com.cei.crunch.server.ws.kernelservices.*;
          public class wsKernel {
           private static URL targetURL = null;
           private String subscriberID = null;
           private String pw = null;
           private String host = null;
           private String keystore = null;
           private String storepw = null;
           private String crunchServer = null;
           KernelServicesEndpoint ss = null;
           private Policymgmt pm = null;
           private String guid = null;
           private boolean serviceBind()
           try {
           KernelServicesService service = new KernelServicesService();
           ss = service.getKernelWSPort();
           /* Set NEW Endpoint Location */
           BindingProvider bp = (BindingProvider)ss;
           bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, crunchServer);
           /* Setup to authenticate with the server. */
           bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, subscriberID);
           bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, pw);
           return true;
           catch (Exception e) {
           System.out.println("Failed to login to server.");
           return false;
           public void run(String[] args) {
           /* Save the subscriber login information. */
           if ( args.length != 5 )
           System.out.println("Missing command line args (userid, password, server, keystore).");
           this.subscriberID = args[0];
           this.pw = args[1];
           this.host = args[2];
           this.keystore = args[3];
           this.storepw = args[4];
           /* Set the Stegi servers. */
           crunchServer = "https://" + this.host + ":8443/Crunch/KernelServices";
           System.out.println("Trying to connect to " + crunchServer + " as User: " + subscriberID + ", password: " + pw);
           /* Configure the keystore for access via HTTPS */
           System.setProperty("javax.net.ssl.trustStore", keystore);
           System.setProperty("javax.net.ssl.trustStorePassword", storepw);
           System.out.println("Trustore: " + keystore);
           System.out.println("TrustorePassword: " + storepw);
           /* Get the WSDL interfaces to the server. */
           if ( serviceBind() == false )
           System.out.println("Login failed.");
           /* Retrieve subscriber profile information. */
           System.out.println("Search for Policy guid: CRUNCH-POLICY-1");
           System.out.println("Search for non-existent Policy guid: BLAH");
           public boolean searchGuid(String guid)
           pm = null;
           try {
           pm = ss.findPolicyMgmt(guid);
           catch (Exception e) {
           System.out.println("Failed findPolicyMgmt(): " + e.getMessage());
           return false;
           if ( pm == null )
           System.out.println("findPolicyMgmt() failed.");
           return false;
           System.out.println("Policy name : " + pm.getPolicyName());
           return true;
           * main() has to be static, but that gets in the way of doing
           * anything useful. So we create a new instance and call
           * the run method to get things going.
           public static void main(String[] args) {
           new wsKernel().run(args);

          Here is the output on the client side when the client is run:

           [java] Trying to connect to https://localhost:8443/Crunch/KernelServices as User: admin, password: admin
           [java] Trustore: /home/mjhammel/src/cei/crunch/src/config/jboss/crunch.truststore
           [java] TrustorePassword: .crunch
           [java] Search for Policy guid: CRUNCH-POLICY-1
           [java] Policy name : COMP-ENABLED
           [java] Search for non-existent Policy guid: BLAH
           [java] Failed findPolicyMgmt(): PolicymgmtBean: no matching entry for guid = BLAH
           [java] com.cei.crunch.server.ws.kernelservices.CrunchWSException_Exception: PolicymgmtBean: no matching entry for guid = BLAH
           [java] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
           [java] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
           [java] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
           [java] at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
           [java] at org.jboss.ws.metadata.umdm.FaultMetaData.toServiceException(FaultMetaData.java:384)
           [java] at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.getSOAPFaultException(SOAPFaultHelperJAXWS.java:128)
           [java] at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.throwFaultException(SOAP11BindingJAXWS.java:109)
           [java] at org.jboss.ws.core.CommonSOAPBinding.unbindResponseMessage(CommonSOAPBinding.java:553)
           [java] at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:371)
           [java] at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:243)
           [java] at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:164)
           [java] at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:150)
           [java] at $Proxy17.findPolicyMgmt(Unknown Source)
           [java] at wsKernel.wsKernel.searchGuid(wsKernel.java:92)
           [java] at wsKernel.wsKernel.run(wsKernel.java:85)
           [java] at wsKernel.wsKernel.main(wsKernel.java:114)

          And here is the output on the server console from the same test run of the client:

          17:05:33,452 [CRUNCH] INFO (kernel.policy): Policymgmt info:
          PolicyName: COMP-ENABLED
          Value : 1
          17:05:33,452 INFO [policy] Policymgmt info:
          PolicyName: COMP-ENABLED
          Value : 1
          17:05:33,684 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
          com.cei.crunch.exception.CrunchWSException: PolicymgmtBean: no matching entry for guid = BLAH
           at com.cei.crunch.server.ws.KernelServices.KernelServices.findPolicyMgmt(KernelServices.java:48)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.wsf.container.jboss42.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:102)
           at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:220)
           at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:408)
           at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:272)
           at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:189)
           at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)
           at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           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:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Thread.java:595)

          The client side output is correct as far as I'm concerned - I told it to print the stack trace and the exception message is correct. But the SOAP stack trace on the server side shouldn't be printed since this is a simple application error. Obviously I've got some problem with how I hand off my exception to SOAP. I must not be telling it something it needs to know. But what?

          • 2. Re: Throws exception in WS (back to remote client) without g
            Alessio Soldano Master


            But the SOAP stack trace on the server side shouldn't be printed since this is a simple application error.

            The stack currently logs every exception before converting it into a soap fault message. We could argue about this choice, however I don't think it's a major issues, just fine tune your log4j conf if you don't want errors emitted by SOAPFaultHelperJAXWS to go to your logs.

            Obviously I've got some problem with how I hand off my exception to SOAP. I must not be telling it something it needs to know. But what?

            This is not related to the above issue about the logs; what problem are you having? please give use further details so that we can help you.

            • 3. Re: Throws exception in WS (back to remote client) without g
              Michael J. Hammel Newbie

              A follow up, just in case anyone else needs the info.

              I ignored this problem for quite some time and finally decided to return to it today. I finally figured out how to tweak log4j to hide those soap fault messages that come from my application throwing an exception. In the jboss-log4j.xml file (in my case, under server/default/conf), I added these lines at the bottom of the file:

               <category name="org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS">
               <priority value="FATAL"/>

              I just had to dig around to find the right category name for these messages. It just took awhile before I could find it.

              Hope that helps anyone with a similar concern.

              • 4. Re: Throws exception in WS (back to remote client) without g
                rsobchak Newbie

                By setting the priority to FATAL then no exceptions thrown from the web service will be logged to the console or server.log file. I still want system exceptions logged to the console and server.log but only want to restrict application exceptions to the server.log (application exceptions not logged to the console). How do I accomplish this?

                • 5. Re: Throws exception in WS (back to remote client) without g
                  chetan padhye Newbie

                  What can be the reason for following exception any idea ?

                  Exception report


                  description The server encountered an internal error () that prevented it from fulfilling this request.


                  $Proxy111.addManager(Unknown Source)

                  note The full stack trace of the root cause is available in the JBossWeb/2.0.1.GA logs.