Skip to Content
author's profile photo
Former Member

Error in JCo Connection

JCO.Exception (JCO_ERROR_LOGON_FAILURE; JCo Error #:103): :2W:003

Authorization failures during the logon phase usually caused by unknown username, wrong password, invalid certificates, etc.

Could somebody give a answer on this Error-Message?

I use the JCO-Service example to get a connection from EP 6 SP1 to SAP/R3.

import bean.JCoBean;

import com.sap.mw.jco.IFunctionTemplate;

import com.sap.mw.jco.IRepository;

import com.sap.mw.jco.JCO;

import com.sapportals.htmlb.DropdownListBox;

import com.sapportals.htmlb.InputField;

import com.sapportals.htmlb.event.Event;

import com.sapportals.htmlb.page.DynPage;

import com.sapportals.htmlb.page.PageException;

import com.sapportals.portal.htmlb.page.JSPDynPage;

import com.sapportals.portal.htmlb.page.PageProcessorComponent;

import com.sapportals.portal.prt.component.IPortalComponentContext;

import com.sapportals.portal.prt.component.IPortalComponentRequest;

import com.sapportals.portal.prt.component.IPortalComponentProfile;

import com.sapportals.portal.prt.component.IPortalComponentResponse;

import com.sapportals.portal.prt.service.jco.IJCOClientService;

import com.sapportals.portal.prt.runtime.PortalRuntime;

public class JCoBasics extends PageProcessorComponent {

    public DynPage getPage() {

        return new MyDynPage();

    }

// DynPage

    public class MyDynPage extends JSPDynPage {

        private final static int INITIAL_STATE = 0;

        private final static int WELCOME_STATE = 1;

        private final static int ERROR_STATE = 2;

        private int state = INITIAL_STATE;

        private final static String DROPDOWN_KEY = "myDropDown";

        private final static String INPUT_KEY = "user_name_input";

        private final static String BEAN_KEY = "MyJCoBean";

        private String user;

        private String sapSystem;

        JCoBean myJCoBean;

        public MyDynPage() {

            this.setTitle("JCo Example");

        }

        public void doInitialization() {

            state = INITIAL_STATE;

            IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

            IPortalComponentContext myContext = request.getComponentContext();

            IPortalComponentProfile myProfile = myContext.getProfile();

            sapSystem = myProfile.getProperty("SystemIdentifier");

            myJCoBean = new JCoBean();

            myJCoBean.setSapSystem(sapSystem);

            myJCoBean.setTitle("Example Using JCo to Access a SAP System");

            myContext.putValue(BEAN_KEY, myJCoBean);

        }

        public void doProcessAfterInput() throws PageException {

        }

        public void doProcessBeforeOutput() throws PageException {

             switch (state) {

                case WELCOME_STATE:

                    setJspName("JCoBasicsResult.jsp");

                    break;

                case ERROR_STATE:

                    setJspName("JCoBasicsError.jsp");

                    break;

                default:

                    setJspName("JCoBasicsStart.jsp");

                    break;

            }

        }

        // method is called, when the user has pressed a button on the result page or error page

        public void onBack(Event event) throws PageException {

            state = INITIAL_STATE;

        }

        // method is called, when the user has pressed a button on the initial page

        public void onClick(Event event) throws PageException {

            state = WELCOME_STATE;

            InputField myInputField = (InputField) getComponentByName(INPUT_KEY);

            if (myInputField != null) {

                this.user = myInputField.getValueAsDataType().toString();

            }

            IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

            IPortalComponentContext myContext = request.getComponentContext();

            myJCoBean = (JCoBean) myContext.getValue(BEAN_KEY);

            myJCoBean.setSapName(user);

            try {

                // get a client service

                IJCOClientService clientService = (IJCOClientService) PortalRuntime.getRuntimeResources().getService("com.sap.portal.runtime.application.jcoclient.jcoclient");

                JCO.Client client = clientService.getJCOClient(myJCoBean.getSapSystem(), request);

                // connect to SAP system

                client.connect();

                // prepare function module call

                IRepository m_Repository = null;

                IFunctionTemplate m_ft_bapi_user_get_detail = null;

                m_Repository = JCO.createRepository("repository", client);

                m_ft_bapi_user_get_detail = m_Repository.getFunctionTemplate("BAPI_USER_GET_DETAIL");

                JCO.Function function = new JCO.Function(m_ft_bapi_user_get_detail);

                JCO.ParameterList importList = function.getImportParameterList();

                importList.setValue(user, "USERNAME");

                // call the fuction module

                client.execute(function);

                // get the result

                JCO.ParameterList outputList = function.getExportParameterList();

                myJCoBean.setFirstName(outputList.getStructure("ADDRESS").getString("FIRSTNAME"));

                myJCoBean.setLastName(outputList.getStructure("ADDRESS").getString("LASTNAME"));

                myJCoBean.setFullName(outputList.getStructure("ADDRESS").getString("FULLNAME"));

                // Close the connection

                client.disconnect();

                // catch any exception

            } catch (JCO.Exception ex) {

                myJCoBean.setErrorMessage("JCO.Exception (" + ex.getGroup() + "): " + ex.getMessage());

                state = ERROR_STATE;

                switch (ex.getGroup()) {

                    case JCO.Exception.JCO_ERROR_PROGRAM:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_PROGRAM; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("A general program exception has occurred");

                        break;

                    case JCO.Exception.JCO_ERROR_COMMUNICATION:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_COMMUNICATION; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("Exception caused by network problems, connection breakdowns, gateway problems, inavailability of the remote SAP system, etc");

                        break;

                    case JCO.Exception.JCO_ERROR_LOGON_FAILURE:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_LOGON_FAILURE; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("Authorization failures during the logon phase usually caused by unknown username, wrong password, invalid certificates, etc. ");

                        break;

                    case JCO.Exception.JCO_ERROR_SYSTEM_FAILURE:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_SYSTEM_FAILURE; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("A system failure in the remote SAP system has occurred ");

                        break;

                    case JCO.Exception.JCO_ERROR_APPLICATION_EXCEPTION:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_APPLICATION_EXCEPTION; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("An application exception has occurred in the remote SAP system ");

                        break;

                    case JCO.Exception.JCO_ERROR_RESOURCE:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_RESOURCE; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("Indicates that JCO has run out of resources such as connections in a connection pool ");

                        break;

                    case JCO.Exception.JCO_ERROR_PROTOCOL:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_PROTOCOL; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("An internal communication protocol error has been detected ");

                        break;

                    case JCO.Exception.JCO_ERROR_INTERNAL:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_INTERNAL; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("An exception inside of JCo ");

                        break;

                    case JCO.Exception.JCO_ERROR_CANCELLED:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_CANCELLED; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("A registered JCo server has been cancelled ");

                        break;

                    case JCO.Exception.JCO_ERROR_STATE_BUSY:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_STATE_BUSY; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("The remote SAP system is busy. Try again later ");

                        break;

                    case JCO.Exception.JCO_ERROR_NULL_HANDLE:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_NULL_HANDLE; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("An internally used connection handle is invalid ");

                        break;

                    case JCO.Exception.JCO_ERROR_CONVERSION:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_CONVERSION; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("A conversion between two representations of either a parameter, structure, or table field has failed ");

                        break;

                    case JCO.Exception.JCO_ERROR_FUNCTION_NOT_FOUND:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_FUNCTION_NOT_FOUND; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("A function interface or one of the data structures could not completely be retrieved from the repository ");

                        break;

                    case JCO.Exception.JCO_ERROR_ILLEGAL_TID:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_ILLEGAL_TID; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("An invalid transaction ID has been encountered. The TID was either longer than 24 characters or contained illegal characters ");

                        break;

                    case JCO.Exception.JCO_ERROR_UNSUPPORTED_CODEPAGE:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_UNSUPPORTED_CODEPAGE; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("Either the remote SAP system or the local systems runs under a codepage which is not supported by JCo ");

                        break;

                    case JCO.Exception.JCO_ERROR_ABAP_EXCEPTION:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_ABAP_EXCEPTION; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("An exception has been thrown by a function module in the remote system ");

                        break;

                    case JCO.Exception.JCO_ERROR_FIELD_NOT_FOUND:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_FIELD_NOT_FOUND; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("A referenced field in either a JCO.ParameterList, JCO.Structure, or JCO.Table does not exist ");

                        break;

                    case JCO.Exception.JCO_ERROR_NOT_SUPPORTED:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_NOT_SUPPORTED; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("A feature is not being supported by the current version of JCo ");

                        break;

                    case JCO.Exception.JCO_ERROR_SERVER_STARTUP:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_SERVER_STARTUP; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("Something went wrong during the startup phase of a JCo server usually caused by passing a wrong gateway host or gateway service");

                        break;

                    case JCO.Exception.JCO_ERROR_XML_PARSER:

                        myJCoBean.setErrorMessage("JCO.Exception (JCO_ERROR_XML_PARSER; JCo Error #:" + ex.getGroup() + "): " + ex.getMessage());

                        myJCoBean.setErrorDetail("A parse error due to an invalid XML document has occurred ");

                        break;

                }

                ;

            }

            ;

        }

    }

}

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Dec 21, 2003 at 06:40 PM

    Should work,

    try to trace the sap systenm, user and password - or SSO2 certificate.

    Take it and try connect to R/3 in a test iview.

    There is also a test iview in EP.

    If it fails you system landscape is wrong, or usermapping is wrong.

    BR,

    Oliver

    Add comment
    10|10000 characters needed characters exceeded