1 Reply Latest reply on Apr 24, 2006 12:16 PM by wcrosman

    Could not pong from Oracle 9i

      Hi List,

      I am sending JMS messages from Oracle 9i java stored procedures to JBoss 3.2.3 message driven beans. The messages are getting sent and received OK, but after each message I get a connection exception. It appears that JBoss is not able to acknowledge the messages successfully.

      the actual exception is:
      [org.jboss.mq.il.oil.OILClientIL] Cannot connect to the ConnectionReceiver/Server
      java.net.ConnectException: Connection refused: connect
      ...(stack trace removed)

      And it's nested inside:
      [org.jboss.mq.il.oil.OILServerILService] Connection failure (3).
      org.jboss.mq.SpyJMSException: Could not pong; - nested throwable: (java.rmi.RemoteException: Cannot connect to the ConnectionReceiver/Server)
      ...(stack trace removed)


      I did a tcpdump on the conversation, and what appears to happen is that the Oracle box sends a FIN (which is ACKnowledged by the JBoss box) but JBoss attempts to send more data, to which the Oracle box responds - quite reasonably - with RST.

      In order to get Oracle's Java Stored Procedures to talk JMS to my JBoss server, I had to load the jbossall-client.jar classes into Oracle.
      Because the Oracle 9i Java environment doesn't completely support J2EE, I had to use a resolver of "((* PUBLIC) (* -))" which means that classes that reference missing classes still load, but throw runtime exceptions if you try to access the missing classes. This hasn't stopped JMS working.


      My java stored procedure looks like this:

      public static void troubleTicket(String pk) throws Exception {

      if (connection == null) {
      connect();
      }
      try {
      TextMessage message = session.createTextMessage("INV: " + pk);
      publisher.publish(message);
      } catch (JMSException jmse) {
      try {
      connection.stop();
      } catch (JMSException jmse1) {
      }
      try {
      connection.close();
      } catch (JMSException jmse2) {
      }
      try {
      connect();
      } catch (Exception e1) {
      }
      TextMessage message = session.createTextMessage("INV: " + pk);
      publisher.publish(message);
      }
      }


      private static synchronized void connect() throws Exception {

      Hashtable environment = new Hashtable();
      environment.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      environment.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      environment.put("java.naming.provider.url", "jnp://jboss-box:1099");

      InitialContext ctx = new InitialContext(environment);

      Topic topic = (Topic)ctx.lookup("topic/cacheInvalidationTopic");
      TopicConnectionFactory tcf = (TopicConnectionFactory)ctx.lookup("ConnectionFactory");
      connection = tcf.createTopicConnection();
      session = connection.createTopicSession(false, TopicSession.DUPS_OK_ACKNOWLEDGE);
      publisher = session.createPublisher(topic);
      connection.start();
      }


      I also had to set some permissions to get everything working currently they are:

      CALL dbms_java.grant_permission( 'MYUSER', 'SYS:java.net.SocketPermission', 'oracle-box:1024-', 'listen,resolve' );
      CALL dbms_java.grant_permission( 'MYUSER', 'SYS:java.net.SocketPermission', 'jboss-box', 'connect,accept,resolve' );


      I am wondering if I need to set some other permissions, but what permissions?
      I also wondered if the issue is different versions of J2SE or J2EE classes between oracle-box and jboss-box.
      I can write a java application that will send JMS messages to the same topic from oracle-box without the exceptions. so it's only when java is running inside Oracle.
      Any ideas anyone?