problem executing jdbc statement via mdb
jmiguel77 May 24, 2010 3:10 AMhi
i have an odd issue trying to execute a callable statement via a MessageDrivenBean. the scenario is like this:
i have @Stateles session bean that produces the message
@Stateless
 public class MensajesServiceImpl implements MensajesService,
         MensajesServiceRemote {
    @Resource(mappedName = "java:/JmsXA")
     private ConnectionFactory connectionFactory;
    @Resource(mappedName = "queue/balanceComprobacionQueue")
     private Queue balanceComprobacionQueue;
    public void llamarEjecucionArbolCuenta(final Integer periodo)
             throws JMSException {
         QueueConnectionFactory qcf = (QueueConnectionFactory)  connectionFactory;
         QueueConnection queueConnection = qcf.createQueueConnection();
         QueueSession queueSession =  queueConnection.createQueueSession(false,
                 Session.AUTO_ACKNOWLEDGE);
         QueueSender queueSender = queueSession
                 .createSender(balanceComprobacionQueue);
         ObjectMessage message = queueSession.createObjectMessage();
         message.setIntProperty(Constantes.PERIODO_MESSAGE_PROPERTY,  periodo);
         queueSender.send(message);
     }
 }
the message is received by the MDB
@MessageDriven(activationConfig  = {
         @ActivationConfigProperty(propertyName = "destinationType",  propertyValue = "javax.jms.Queue"),
         @ActivationConfigProperty(propertyName = "destination",  propertyValue = "queue/balanceComprobacionQueue") })
 public class BalanceComprobacionMessageDrivenBean implements  MessageListener {
    @EJB
     private BalanceComprobacionService balanceComprobacionService;
    @Override
     public void onMessage(final Message message) {
         try {
             if (message instanceof ObjectMessage) {
                 ObjectMessage periodoMessage = (ObjectMessage) message;
                 Integer periodo = periodoMessage
                          .getIntProperty(Constantes.PERIODO_MESSAGE_PROPERTY);
                  balanceComprobacionService.ejecutarArbolCuentas(periodo);
             }
         } catch (JMSException e) {
             e.printStackTrace();
         } catch (EjecucionFallidaException e) {
             e.printStackTrace();
         }
}
}
as you can see, in the MDB i am injecting another stateless session bean (BalanceComprobacionService) and calling a method registered in that session bean; the method i am executing is this
@Stateless
 public class BalanceComprobacionDaoImpl implements  BalanceComprobacionDao {
    @Resource(mappedName = "java:/myDataSource")
     private DataSource dataSource;
    @Override
     public void ejecutarArbolCuentas(final Integer periodo)
             throws EjecucionFallidaException {
         Connection connection = null;
         try {
             String sql = "{ call arbol_cuenta(?) }";
             connection = dataSource.getConnection();
             CallableStatement statement = connection.prepareCall(sql);
             statement.setInt(1, periodo);
             statement.execute();
         } catch (SQLException e) {
             throw new EjecucionFallidaException(e);
         } finally {
             try {
                 connection.close();
             } catch (SQLException e) {
                 throw new EjecucionFallidaException(e);
             }
         }
     }
 }
everything works fine, until the statement.execute(); at this point, the execution just stops; it doesn't give any error, exception, nor in the jboss server or the database, it just stops right there
i am using jboss 4.2.3.GA with jdk 1.6_0.15; the database is postgresql 8.3
i don't think the problem is related with the database or the function i am calling, because if i test the BalanceComprobacionDaoImpl by itself, it works ok, it's just when i test the whole process that it stops at the callable statement execution
please help, thanks
