Need urgent help with JMS producer !
serkan.s.eskici.online.nl Aug 26, 2011 6:29 AMHi,
I'm trying to send a message to a queue from a POJO and I keep getting the following error:
org.jboss.seam.InstantiationException: Could not instantiate Seam component: notQueueSender at org.jboss.seam.Component.newInstance(Component.java:2170) at org.jboss.seam.Component.getInstance(Component.java:2024) at org.jboss.seam.Component.getInstance(Component.java:1986) at org.jboss.seam.Component.getInstance(Component.java:1980) at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2375) at org.jboss.seam.Component.getValueToInject(Component.java:2327) at org.jboss.seam.Component.injectAttributes(Component.java:1739) at org.jboss.seam.Component.inject(Component.java:1557) at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97) at org.jboss.seam.util.Work.workInTransaction(Work.java:61) at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:52) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185) at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103) at nl.portbase.spoc.validation.RetryServiceHandler_$$_javassist_seam_10.retry(RetryServiceHandler_$$_javassist_seam_10.java) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.seam.util.Reflections.invoke(Reflections.java:22) at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144) at org.jboss.seam.async.AsynchronousInvocation$1.process(AsynchronousInvocation.java:62) at org.jboss.seam.async.Asynchronous$ContextualAsynchronousRequest.run(Asynchronous.java:80) at org.jboss.seam.async.AsynchronousInvocation.execute(AsynchronousInvocation.java:44) at org.jboss.seam.async.ThreadPoolDispatcher$RunnableAsynchronous.run(ThreadPoolDispatcher.java:142) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207) 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:619) Caused by: java.lang.RuntimeException: exception invoking: create at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:154) at org.jboss.seam.Component.callComponentMethod(Component.java:2275) at org.jboss.seam.Component.callCreateMethod(Component.java:2198) at org.jboss.seam.Component.newInstance(Component.java:2158) ... 39 more Caused by: javax.jms.JMSException: No currently active Session. This JMS provider cannot be used outside a MessageListener.onMessage() invocation at org.apache.activemq.ra.InboundSessionProxy.getSessionAndProducer(InboundSessionProxy.java:82) at org.apache.activemq.ra.InboundSessionProxy.createSender(InboundSessionProxy.java:225) at org.jboss.seam.jms.ManagedQueueSender.create(ManagedQueueSender.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.seam.util.Reflections.invoke(Reflections.java:22) at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144) ... 42 more
And this is the code block where I'm doing the JMS call:
@AutoCreate @Name("retryServiceHandler") public class RetryServiceHandler { @Logger private Log log; @In(create = true) private QueueSession queueSession; @In private QueueSender notQueueSender; @In private QueueSender hazmatQueueSender; @In private EntityManager entityManager; @Asynchronous @Transactional public void retry(String msRefid, boolean msgRetry, @Duration long duration) { LCANotification not = (LCANotification) entityManager.createQuery("from LCANotification n where n.msRefId = :id") .setParameter("id", msRefid) .getSingleResult(); try { if (msgRetry) notQueueSender.send(queueSession.createTextMessage(marshall(not))); else hazmatQueueSender.send(queueSession.createTextMessage(marshall(not))); } catch (Exception e) { log.error("Calling the 'RETRY service' failed: {0}", getErrorMessage(e)); not.addState(NOT_SENT); changeStateToInvalid(not); Events.instance().raiseAsynchronousEvent(EVENT_SEND_NOTIFICATION_ALERT, EVENT_TYPE_9, not); } }
And this method is triggered from a SLSB like this:
@TransactionAttribute public void retry() { RetryServiceHandler handler = (RetryServiceHandler) Component.getInstance(RetryServiceHandler.class); handler.retry(msRefid, true, waitTimeInSecs * 1000); }
The strange thing is that I can send messages into the queue from a MDB, that is: I read a message from a MDB then I send it back to another queue. And this just works. But when I try to send a message outside a MDB, then it doesn't work. And according to the Seam manual it should be possible to send messages just from a POJO.
I've 2 deployments: 1 EAR file and 1 WAR, and it both cases sending messages doesn't work.
Further info, I'm using:
- Seam 2.2.1.final
- JBoss 5.1.GA
- ActiveMQ 5.4
- PostGres 8.4
Can someone please provide any help or a hint about this issue ?
Thx !