[jboss-user] [JBossWS] - Re: Throws exception in WS (back to remote client) without g

mjhammel do-not-reply at jboss.com
Mon Jan 21 19:13:38 EST 2008


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. */
  | @Stateless
  | 
  | /* Make this an Web Services endpoint. */
  | @WebService(
  |     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");
  | 
  |     @WebMethod
  |     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.");
  |         else
  |         {
  |             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.");
  |             e.printStackTrace();
  |             System.exit(1);
  |         }
  |         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).");
  |             System.exit(1);
  |         }
  |         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.");
  |             System.exit(1);
  |         }
  | 
  |         /* Retrieve subscriber profile information. */
  |         System.out.println("Search for Policy guid: CRUNCH-POLICY-1");
  |         searchGuid("CRUNCH-POLICY-1");
  | 
  |         System.out.println("Search for non-existent Policy guid: BLAH");
  |         searchGuid("BLAH");
  |     }
  | 
  |     public boolean searchGuid(String guid)
  |     {
  |         pm = null;
  |         try {
  |             pm = ss.findPolicyMgmt(guid);
  |         }
  |         catch (Exception e) {
  |             System.out.println("Failed findPolicyMgmt(): " + e.getMessage());
  |             e.printStackTrace();
  |             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:

client.test.kernel:
  |      [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?


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4121996#4121996

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4121996



More information about the jboss-user mailing list