[jboss-user] [Messaging, JMS & JBossMQ] - MDB @PostConstruct error
sandrocchio_0.1
do-not-reply at jboss.com
Sat Mar 17 07:02:53 EDT 2007
Hi there,
I'm trying to run a sample MDB which should send emails.
Jboss 4.0.5 GA - EJB3
anonymous wrote : I can correctly deploy the EJB Module,
| 10:28:17,683 INFO [Ejb3Deployment] EJB3 deployment time took: 26
| 10:28:17,692 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=Mail-EJBModule.jar,name=MailMDB,service=EJB3 with dependencies:
| 10:28:17,722 INFO [EJBContainer] STARTED EJB: eu.virtualLab.mail.MailMDB ejbName: MailMDB
| 10:28:17,725 WARN [MessagingContainer] Could not find the queue destination-jndi-name=queue/outGoingEmail
| 10:28:17,727 WARN [MessagingContainer] destination not found: queue/outGoingEmail reason: javax.naming.NameNotFoundException: outGoingEmail not bound
| 10:28:17,729 WARN [MessagingContainer] creating a new temporary destination: queue/outGoingEmail
| 10:28:17,762 INFO [outGoingEmail] Bound to JNDI name: queue/outGoingEmail
| 10:28:17,854 INFO [EJB3Deployer] Deployed: file:/etc/jboss-4.0.5.GA/server/default/deploy/Mail-EJBModule.jar
| 11:27:17,659 INFO [Ejb3Deployment] EJB3 deployment time took: 66
| 11:27:17,670 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=Mail-EJBModule.jar,name=MailMDB,service=EJB3 with dependencies:
| 11:27:17,712 INFO [EJBContainer] STARTED EJB: eu.virtualLab.mail.MailMDB ejbName: MailMDB
| 11:27:17,760 INFO [EJB3Deployer] Deployed: file:/etc/jboss-4.0.5.GA/server/default/deploy/Mail-EJBModule.jar
but I can't run it from a Client, belowe the stack trace from JBoss
anonymous wrote : 11:38:55,699 INFO [ClientDeployer] Removing client ENC from: Mail-EJBModuleClient
| 11:38:55,737 INFO [ClientDeployer] Client ENC bound under: Mail-EJBModuleClient
| 11:38:56,686 ERROR [JmsServerSession] Unexpected error delivering message org.jboss.mq.SpyObjectMessage {
| Header {
| jmsDestination : QUEUE.outGoingEmail
| jmsDeliveryMode : 2
| jmsExpiration : 0
| jmsPriority : 4
| jmsMessageID : ID:9-11741279366781
| jmsTimeStamp : 1174127936678
| jmsCorrelationID: null
| jmsReplyTo : null
| jmsType : null
| jmsRedelivered : false
| jmsProperties : {sent=1174127936673}
| jmsPropReadWrite: false
| msgReadOnly : true
| producerClientId: ID:9
| }
| }
| java.lang.RuntimeException: java.lang.NullPointerException
| at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(LifecycleInterceptorHandler.java:113)
| at org.jboss.ejb3.EJBContainer.invokePostConstruct(EJBContainer.java:505)
| at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:112)
| at org.jboss.ejb3.StrictMaxPool.get(StrictMaxPool.java:122)
| at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
The client code is
QueueConnection cnn = null;
| QueueSender sender = null;
| QueueSession sess = null;
| Queue queue = null;
|
| try {
| InitialContext ctx = new InitialContext();
| queue = (Queue) ctx.lookup("queue/outGoingEmail");
| QueueConnectionFactory factory =
| (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
| cnn = factory.createQueueConnection();
| sess = cnn.createQueueSession(false,
| QueueSession.AUTO_ACKNOWLEDGE);
|
| EmailBody email = new EmailBody(new String[]{"sandro at my-domain.net"},
| "test MailMDB module", "test MailMDB module");
| ObjectMessage msg = sess.createObjectMessage();
| msg.setObject(email);
|
|
| // The sent timestamp acts as the message's ID
| long sent = System.currentTimeMillis();
| msg.setLongProperty("sent", sent);
|
| sender = sess.createSender(queue);
| sender.send(msg);
|
| // sess.commit ();
| sess.close();
|
| } catch (JMSException ex) {
| ex.printStackTrace();
|
| } catch (Exception e) {
| e.printStackTrace();
| }
|
|
and the MDB
@MessageDriven(mappedName = "jms/MailMDB", activationConfig = {
| @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
| @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
| @ActivationConfigProperty(propertyName="destination", propertyValue="queue/outGoingEmail")
| })
| public class MailMDB implements MessageListener {
|
| private SessionContext context;
| private javax.mail.Message msg = null;
| Properties htmlTags = new Properties();
| private final Logger logger = Logger.getLogger(getClass().getName());
|
| @PostConstruct
| public void initialize() {
| logger.info("[initialize] PostConstruct. ok!");
| Session session =(Session)context.lookup("java:comp/env/mail/Mail");
| logger.info("[initialize] Mail Factory session from app. server. ok!");
from the logger the code seems to break off in the line where it try to get a Mail session.
What's my mistake here?
Thank you in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029011#4029011
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029011
More information about the jboss-user
mailing list