Skip to Content
avatar image
Former Member

SAP JMS JNDI Connection Factory issue when N/W hiccup occurs

Hi,

I am connecting to SAP PI v 7.3 JMS Broker using a JNDI Connection Factory. Everything is fine until the network goes down. The connection factory attempts to reconnect indefinitely until the network comes back up. However, after the network heals, I continue to find that SAP JMS Connection Factory is unable to dispense new connections claiming bad network. The following is the exception trace

Currently, the way to resolve is hard restart of the Java application which creates new JNDI context, connection factory etc. However, that is not acceptable solution. Ideally, I would like the connection factory to reissue proper connection when network heals.

Please let me know if this is a known issue or if there is work around for the same.

Thank you!

Ashwin

Caused by: com.sap.engine.services.rmi_p4.P4IOException: No alive connection. Check state of the server

                at com.sap.engine.services.rmi_p4.P4ObjectBrokerClientImpl.getException(P4ObjectBrokerClientImpl.java:824)

                at com.sap.engine.services.rmi_p4.P4ObjectBrokerClientImpl.getException(P4ObjectBrokerClientImpl.java:809)

                at com.sap.engine.services.rmi_p4.ClientConnection.sendRequest(ClientConnection.java:281)

                at com.sap.engine.services.rmi_p4.Call.sendSimpleRequest(Call.java:642)

                at com.sap.engine.services.rmi_p4.reflect.P4InvocationHandler.invokeInternal(P4InvocationHandler.java:125)

                ... 14 more

01:53:16,386 WARN  [DefaultJmsMessageListenerContainer] Could not refresh JMS Connection for destination 'Dev.Provista' - retrying in 5000 ms. Cause: Could not allocate JMS connection due to RMI error.; nested exception is com.sap.engine.services.rmi_p4.P4RuntimeException: Unexpected exception

javax.jms.JMSException: Could not allocate JMS connection due to RMI error.

                at com.sap.jms.client.rmi.RMIConnectionFactory.createConnection(RMIConnectionFactory.java:178)

                at com.sap.jms.client.rmi.RMIConnectionFactory.createConnection(RMIConnectionFactory.java:158)

                at com.sap.jms.client.rmi.RMIConnectionFactory.createConnection(RMIConnectionFactory.java:110)

                at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)

                at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:859)

                at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:838)

                at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:969)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:662)

01:53:21,474 WARN  [DefaultJmsMessageListenerContainer] Could not refresh JMS Connection for destination 'XXXX' - retrying in 5000 ms. Cause: Could not allocate JMS connection due to RMI error.; nested exception is com.sap.engine.services.rmi_p4.P4RuntimeException: Unexpected exception

javax.jms.JMSException: Could not allocate JMS connection due to RMI error.

                at com.sap.jms.client.rmi.RMIConnectionFactory.createConnection(RMIConnectionFactory.java:178)

                at com.sap.jms.client.rmi.RMIConnectionFactory.createConnection(RMIConnectionFactory.java:158)

                at com.sap.jms.client.rmi.RMIConnectionFactory.createConnection(RMIConnectionFactory.java:110)

                at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)

                at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:859)

                at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:838)

                at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:969)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:662)

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Feb 08, 2013 at 06:35 PM

    This is a miniaturized code snippet that replicates this issue

    The following jars are being used

    jms.jar

    sap.com~tc~exception~impl.jar

    sap.com~tc~je~clientlib~impl.jar

    sap.com~tc~logging~java~impl.jar

    The version of the above jars from SAP is {extracted from MANIFEST.MF}

    Implementation-Vendor-Id: sap.com

    Implementation-Version: 7.3003.20110520090334.0000

    ---------

    import java.util.Hashtable;

    import javax.naming.Context;

    import javax.naming.InitialContext;

    import javax.naming.NamingException;

    public class Main {

                        public static void main(String[] args) throws Exception {

                                  Context ctx = null;

                                  Hashtable env = new Hashtable();

      env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");

      env.put(Context.PROVIDER_URL, "sap-pi-machine-fqdn:50204");

                                  env.put(Context.SECURITY_PRINCIPAL, "user");

                                  env.put(Context.SECURITY_CREDENTIALS, "password");

      env.put("force_remote", "true"); // this result of execution does not change with or without this setting

                                  for(int i = 0; i < 100; i++) {

                                  try {

                                     ctx = new InitialContext(env);

                                     ctx.lookup("jmsfactory/default/TopicConnectionFactory");

                                     System.out.println("hello");

                                  } catch (NamingException ne) {

                                     ne.printStackTrace();

                                  } finally {

                                    try {

                                            ctx.close();

                                    } catch (Exception e) {

                                             e.printStackTrace();

                                    }

                                  }

                                            Thread.sleep(5000);

                                  }

                        }

    }

    -------

    Start the Java Application. Works fine. Then disconnect the network. Wait for a 10 seconds. Exceptions start occurring. Then fix the network. Verify that connectivity is established. However, the application continues to throw the following exception.

    ------

    Caused by: com.sap.engine.services.rmi_p4.P4IOException: No alive connection. Check state of the server

              at com.sap.engine.services.rmi_p4.P4ObjectBrokerClientImpl.getException(P4ObjectBrokerClientImpl.java:824)

              at com.sap.engine.services.rmi_p4.P4ObjectBrokerClientImpl.getException(P4ObjectBrokerClientImpl.java:809)

              at com.sap.engine.services.rmi_p4.ClientConnection.sendRequest(ClientConnection.java:281)

              at com.sap.engine.services.rmi_p4.P4ObjectBrokerClientImpl.resolveInitialReference(P4ObjectBrokerClientImpl.java:123)

              at com.sap.engine.services.rmi_p4.RemoteBroker.resolveInitialReference(RemoteBroker.java:41)

              at com.sap.engine.services.security.remote.login.RemoteLoginContext.<init>(RemoteLoginContext.java:153)

              ... 7 more

    -----

    The following blog post http://www.stechno.net/sap-notes.html?view=sapnote&id=1473530 seems suggest that is has been fixed but in a release prior to v7.3. I am using v7.3 jars and I expect the issue to have been fixed unless I am doing something wrong.

    Would gladly accept any help 😊

    Thank you!

    Ashwin

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Here is the snippet from the logs for the failed connection even when the network is back up.

      ClientConnection sends a request to Server but gets EOF. It worked before the network hiccup occurred.

      ----

      Feb 8, 2013 5:08:58 PM [1360364938416]:Warning : Thread[Thread-18,5,main]                            com.sap.engine.services.rmi_p4:    ClientConnection <33bdfcdb> to None:...:port created on : Fri Feb 08 17:08:58 CST 2013

      [EXCEPTION]

      java.io.EOFException: End of stream is reached unexpectedly during input from Socket[addr=/destination-server,port=xxxxx,localport=18892]

                at com.sap.engine.services.rmi_p4.ClientConnection.run(ClientConnection.java:416)

                at java.lang.Thread.run(Thread.java:662)