Topic
3 replies Latest Post - ‏2010-07-20T12:55:23Z by sascha.schefenacker
sascha.schefenacker
sascha.schefenacker
4 Posts
ACCEPTED ANSWER

Pinned topic JCo exception Error Handler

‏2010-07-19T08:04:40Z |
Hi,

i create currently a SAP Portlet that needs to react on different JCo errors.
Badly the JCo error itself is not part of the return object - clear, because the call get not executed.

so i try to find a way to catch different error reasons:
  • no connection to backend -- com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: SAP_CMINIT3 : rc=20 > Connect to SAP gateway failed
  • wrong user -> red -- com.sap.mw.jco.JCO$Exception: (103) RFC_ERROR_LOGON_FAILURE: Name or password is incorrect (repeat logon)
  • password old, need to update

and then react on this.
i guess the "Error Handler" builder might be the right point to start.
but even with the option "Catch all unhandled exceptions" it does not do anything.
even not on the action <mySAPaction>.execute

could you please help me finding out how to handle the different error types?
Updated on 2010-07-20T12:55:23Z at 2010-07-20T12:55:23Z by sascha.schefenacker
  • sascha.schefenacker
    sascha.schefenacker
    4 Posts
    ACCEPTED ANSWER

    Re: JCo exception Error Handler

    ‏2010-07-20T11:22:58Z  in response to sascha.schefenacker
    a general error handling does now work.
    exception class: com.sap.mw.jco.JCO$Exception was the key i missed.

    but i still struggle how to decide which kind of exception it is.
    login/connect/..
    i see it in the text, but how could i access that string in portlet factory?
    • sascha.schefenacker
      sascha.schefenacker
      4 Posts
      ACCEPTED ANSWER

      Re: JCo exception Error Handler

      ‏2010-07-20T11:26:25Z  in response to sascha.schefenacker
      current error display:

      An error has occurred.
      The error message returned was: "Error in method main. Error in method testCall.execute. Name or password is incorrect (repeat logon)".

      Please refer to the logs folder in your deployed application for additional error information.

      Click here for a detailed error message. Click here to hide the detailed error message.

      Exception Error in method main. Error in method testCall.execute. Name or password is incorrect (repeat logon)

      Stack Trace
      com.sap.mw.jco.JCO$Exception: (103) RFC_ERROR_LOGON_FAILURE: Name or password is incorrect (repeat logon)
      at com.sap.mw.jco.rfc.MiddlewareRFC$Client.connect(MiddlewareRFC.java:1125)
      at com.sap.mw.jco.JCO$Client.connect(JCO.java:3138)
      at com.sap.mw.jco.JCO$Pool.initPool(JCO.java:4548)
      at com.sap.mw.jco.JCO$PoolManager.getClient(JCO.java:5979)
      at com.sap.mw.jco.JCO$PoolManager.getClient(JCO.java:5929)
      at com.sap.mw.jco.JCO.getClient(JCO.java:8171)
      at com.sap.mw.jco.JCO$Repository.getRepositoryClient(JCO.java:19311)
      at com.sap.mw.jco.JCO$Repository.queryFunctionInterface(JCO.java:19390)
      at com.sap.mw.jco.JCO$Repository.getFunctionInterface(JCO.java:19500)
      at com.sap.mw.jco.JCO$BasicRepository.getFunctionTemplate(JCO.java:18520)
      at com.bowstreet.builders.webapp.methods.SAPAccess.getFunctionTemplate(SAPAccess.java:127)
      at com.bowstreet.builders.webapp.methods.SAPCall.(SAPCall.java:31)
      at com.bowstreet.builders.webapp.methods.SAPAccess.createSAPCall(SAPAccess.java:118)
      at com.bowstreet.builders.webapp.methods.SAPFunctionCallHelper.callSAPFunction(SAPFunctionCallHelper.java:96)
      at com.bowstreet.builders.webapp.methods.SAPFunctionCallHelper.executeUsingConnection(SAPFunctionCallHelper.java:51)
      at com.bowstreet.builders.webapp.methods.SAPFunctionCallHelper.execute(SAPFunctionCallHelper.java:31)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:618)
      at com.bowstreet.webapp.engine.actions.MethodAction.callAction(MethodAction.java:90)
      at com.bowstreet.webapp.engine.WebAppAccessImpl.callMethod(WebAppAccessImpl.java:405)
      at genjava.samples._SAPTest.main(_SAPTest.java:112)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:618)
      at com.bowstreet.webapp.engine.actions.MethodAction.callAction(MethodAction.java:90)
      at com.bowstreet.webapp.engine.WebAppAccessImpl.callMethod(WebAppAccessImpl.java:405)
      at com.bowstreet.webapp.engine.WebAppAccessImpl.processAction(WebAppAccessImpl.java:1063)
      at com.bowstreet.webapp.engine.WebAppAccessImpl.processAction(WebAppAccessImpl.java:1163)
      at com.bowstreet.webapp.engine.WebAppRequestRunner.doRequest(WebAppRequestRunner.java:364)
      at com.bowstreet.webapp.engine.WebAppRunner.doActualRequest(WebAppRunner.java:923)
      at com.bowstreet.webapp.engine.WebAppRunner.doRequest(WebAppRunner.java:535)
      at com.bowstreet.webapp.engine.WebAppRunner.doRequest(WebAppRunner.java:300)
      at com.bowstreet.webapp.engine.WebAppRunner.doRequest(WebAppRunner.java:237)
      at com.bowstreet.webapp.engine.WebAppServlet.doPost(WebAppServlet.java:73)
      at com.bowstreet.webapp.engine.WebAppServlet.doGet(WebAppServlet.java:53)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1095)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1036)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:118)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:832)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:679)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:565)
      at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
      at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:748)
      at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1461)
      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:119)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
      at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
      at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
      at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
      at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
      at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
      at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
      at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
      at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
  • sascha.schefenacker
    sascha.schefenacker
    4 Posts
    ACCEPTED ANSWER

    Re: JCo exception Error Handler

    ‏2010-07-20T12:55:23Z  in response to sascha.schefenacker
    found in another forum a link to the help center area that covers that part.

    HttpServletRequest request = webAppAccess.getHttpServletRequest();
    Throwable ex = (Throwable)request.getAttribute("bowstreet.errorhandler.Exception");
    String actionName = (String)request.getAttribute("bowstreet.errorhandler.ActionName");
    String errorMessage = ex.toString() + " occurred in: " + actionName;

    //log the error
    webAppAccess.logError(actionName, ex);

    //set a the value of a variable to the error message
    webAppAccess.getVariables().setString("ErrorVariable", errorMessage);

    //display a page prompting for new information
    webAppAccess.processPage("errorPage");
    that code helps to get the message.
    and on the message content a IF could be based.
    solved :)