[jboss-user] [Messaging, JMS & JBossMQ] - Error when saving message in database
cashMAR
do-not-reply at jboss.com
Fri May 25 00:39:53 EDT 2007
Here is the problem, i'm using JMS and postgreSQL database in backend.Following stacktrace is generated:
************************************
11:32:08,943 ERROR [STDERR] org.jboss.mq.SpyJMSException: Could not store message: 1 msg=0 hard NOT_STORED PERSISTENT queue=QUEUE.mailQueue priority=4 lateClone=false hashCode=5856205; - nested throwable: (org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.jboss.mq.SpyTextMessage. Use setObject() with an explicit Types value to specify the type to use.)
11:32:08,943 ERROR [STDERR] at org.jboss.mq.pm.jdbc2.PersistenceManager.add(PersistenceManager.java:1097)
11:32:08,943 ERROR [STDERR] at org.jboss.mq.server.PersistentQueue.addMessage(PersistentQueue.java:58)
11:32:08,943 ERROR [STDERR] at org.jboss.mq.server.JMSQueue.addMessage(JMSQueue.java:180)
11:32:08,943 ERROR [STDERR] at org.jboss.mq.server.JMSDestinationManager.addMessage(JMSDestinationManager.java:415)
11:32:08,943 ERROR [STDERR] at org.jboss.mq.server.JMSDestinationManager.addMessage(JMSDestinationManager.java:399)
11:32:08,944 ERROR [STDERR] at org.jboss.mq.server.JMSServerInterceptorSupport.addMessage(JMSServerInterceptorSupport.java:106)
11:32:08,944 ERROR [STDERR] at org.jboss.mq.security.ServerSecurityInterceptor.addMessage(ServerSecurityInterceptor.java:168)
11:32:08,944 ERROR [STDERR] at org.jboss.mq.server.TracingInterceptor.addMessage(TracingInterceptor.java:226)
11:32:08,944 ERROR [STDERR] at org.jboss.mq.server.JMSServerInvoker.addMessage(JMSServerInvoker.java:112)
11:32:08,944 ERROR [STDERR] at org.jboss.mq.il.uil2.ServerSocketManagerHandler.handleMsg(ServerSocketManagerHandler.java:111)
11:32:08,944 ERROR [STDERR] at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleMsg(SocketManager.java:395)
11:32:08,944 ERROR [STDERR] at org.jboss.mq.il.uil2.msgs.BaseMsg.run(BaseMsg.java:398)
11:32:08,944 ERROR [STDERR] at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748)
11:32:08,944 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
11:32:08,944 ERROR [STDERR] Caused by: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.jboss.mq.SpyTextMessage. Use setObject() with an explicit Types value to specify the type to use.
11:32:08,944 ERROR [STDERR] at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1656)
11:32:08,944 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setObject(WrappedPreparedStatement.java:478)
11:32:08,944 ERROR [STDERR] at org.jboss.mq.pm.jdbc2.PersistenceManager.setBlob(PersistenceManager.java:1190)
11:32:08,944 ERROR [STDERR] at org.jboss.mq.pm.jdbc2.PersistenceManager.add(PersistenceManager.java:1128)
11:32:08,944 ERROR [STDERR] at org.jboss.mq.pm.jdbc2.PersistenceManager.add(PersistenceManager.java:1082)
11:32:08,944 ERROR [STDERR] ... 13 more
Here is the code for publishing message in queue:
| private void sendMail(String where) {
| QueueConnection cnn;
| QueueSender sender;
| QueueSession sess;
| Queue queue;
| try {
| InitialContext ctx = new InitialContext();
| queue = (Queue) ctx.lookup("queue/mailQueue");
| QueueConnectionFactory factory =
| (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
| cnn = factory.createQueueConnection();
| sess = cnn.createQueueSession(false,
| QueueSession.AUTO_ACKNOWLEDGE);
| TextMessage msg = sess.createTextMessage("HAHAHA");
| sender = sess.createSender(queue);
| sender.send(msg);
| sess.close();
| }
| catch (JMSException e) {
| e.printStackTrace();
| }
| catch (Exception e) {
| e.printStackTrace();
| }
|
| }
|
It's queue consumer:
| @MessageDriven(activationConfig =
| {
| @ActivationConfigProperty(propertyName="destinationType",
| propertyValue="javax.jms.Queue"),
| @ActivationConfigProperty(propertyName="destination",
| propertyValue="queue/mailQueue")
| })
|
| public class MailSenderMDB implements MessageListener {
| @Resource(mappedName = "java:/mail/VCSMail")
| private Session mailer;
| public void onMessage(Message message) {
| TextMessage textMessage = (TextMessage) message;
| System.out.println("message = " + textMessage);
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048554#4048554
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048554
More information about the jboss-user
mailing list