3 Replies Latest reply on Aug 17, 2006 12:43 PM by Erik Westland

    SocketException with an MDPOJO

    Malte Meiboom Newbie

      Hello

      I get a

      2006-07-10 16:34:24,140 DEBUG [org.jboss.mq.il.uil2.ServerSocketManagerHandler] Exiting on IOE
      java.net.SocketException: socket closed
       at java.net.SocketInputStream.socketRead0(Native Method)
       at java.net.SocketInputStream.read(SocketInputStream.java:129)
       at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
       at java.io.BufferedInputStream.read(BufferedInputStream.java:235)
      [...]
      2006-07-10 16:34:24,140 DEBUG [org.jboss.mq.il.uil2.SocketManager] End ReadTask.run
      2006-07-10 16:34:24,140 DEBUG [org.jboss.mq.il.uil2.SocketManager] Failed to handle: org.jboss.mq.il.uil2.msgs.CloseMsg19351667[msgType: m_connectionClosing, msgID: 7, error: null]
      java.io.IOException: Client is not connected
       at org.jboss.mq.il.uil2.SocketManager.internalSendMessage(SocketManager.java:265)
       at org.jboss.mq.il.uil2.SocketManager.sendReply(SocketManager.java:239)
      [...]
      2006-07-10 16:34:24,140 DEBUG [org.jboss.mq.il.uil2.SocketManager] Failed to send error reply
      java.io.IOException: Client is not connected
       at org.jboss.mq.il.uil2.SocketManager.internalSendMessage(SocketManager.java:265)
      


      This happens with this code
      package de.s2i.service.tools;
      
      import org.jboss.annotation.ejb.DeliveryMode;
      import org.jboss.annotation.ejb.MessageProperties;
      import org.jboss.annotation.ejb.Producer;
      
      @Producer
      public interface Echo {
      
       public void doEcho(String payload);
      
      }
      

      and
      package de.s2i.service.tools;
      
      import javax.annotation.Resource;
      import javax.ejb.ActivationConfigProperty;
      import javax.ejb.EJB;
      import javax.ejb.MessageDriven;
      import javax.ejb.MessageDrivenBean;
      import javax.ejb.MessageDrivenContext;
      import javax.jms.Message;
      import javax.jms.MessageListener;
      
      import org.jboss.annotation.ejb.Consumer;
      import org.jboss.annotation.ejb.CurrentMessage;
      
      @Consumer(activationConfig= {
       @ActivationConfigProperty(propertyName="destinationType",
       propertyValue="javax.jms.Queue"),
       @ActivationConfigProperty(propertyName="destination",
       propertyValue="queue/echo"),
       @ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue="AUTO_ACKNOWLEDGE")
      })
      public class EchoBean implements Echo {
      
       @CurrentMessage
       private javax.jms.Message currentMessage;
      
       public void doEcho(String payload) {
       System.out.println("EchoBean: "+payload);
       if (currentMessage != null) {
       try {
       if (currentMessage.getJMSReplyTo() != null) {
       System.out.println("CurMsg: "+currentMessage.getJMSReplyTo().toString());
       } else {
       System.out.println("CurMsg: no ReplyTo");
       }
       }catch (Exception e) {
       System.out.println("doEcho::Exception: "+e.toString());
       }
       }
       }
      }
      

      and
      package de.s2i.service.tools;
      
      import java.util.Properties;
      
      import javax.naming.InitialContext;
      
      import org.jboss.ejb3.mdb.ProducerManager;
      import org.jboss.ejb3.mdb.ProducerObject;
      import javax.jms.JMSException;
      
      public class EchoClient {
      
       public static void main(String[] args) {
       try {
       String urlName = "jnp://localhost:1099";
       Properties p = new Properties();
       p.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
       p.put("java.naming.provider.url", urlName);
       p.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
       InitialContext ctx=new InitialContext(p);
       Echo echoClient=(Echo)ctx.lookup(Echo.class.getName());
      
       ProducerObject po = (ProducerObject)echoClient;
       ProducerManager pm=po.getProducerManager();
      
       System.out.println("Going to connect ...");
       pm.setUsername("guest");
       pm.setPassword("guest");
      
       pm.connect();
      
       System.out.println("Connected - calling echo");
       try {
       echoClient.doEcho("stuff");
       } finally {
       System.out.println("sleep for 10 sec ...");
       Thread.sleep(10000);
       pm.close();
       }
       } catch (Exception e) {
       System.out.println("Exception "+e.toString());
       }
       System.out.println("Leaving ...");
       }
      
      }
      


      in the logfile i see
      2006-07-10 16:34:14,218 INFO [STDOUT] EchoBean: stuff
      2006-07-10 16:34:14,218 INFO [STDOUT] CurMsg: no ReplyTo
      


      So one way seems to work ... (is it ok, that the JMSReplyTo is empty? Is this already the problem?)

      As you can see I put a Thread.sleep(10000) in the client before actually closing the ProducerManager, this is when the Server throws the Exception (not before).

      It looks a bit like the server wants to send the client some data, but the client is not paying attention to it's socket ...

      What do I make wrong?

      greetings
      Malte

      PS: jboss 4.0.4GA, EJB 3.0 RC8 FD