1 Reply Latest reply on Apr 14, 2015 4:56 AM by Khaleel Ibrahim

    Need Help : Can TomCat Client send message to destination in JMS  of jboss Messaging  (jboss 5.0.1)

    Hai Nguyen Newbie

      I have Web client run on Tomcat Web server 6 and MDB run at JbossAS 5 , i use Ejb3.0

      From Tomcat client I want to send a message to destination jms.

      I get error at line


      factory = (QueueConnectionFactory) jndiContext.lookup("dvdshop_jms_conectionfactory");

      Please help me , thank you much.

      my full code


      package utility;


      import eproject.dvdshop.entities.SendMail;

      import java.util.Properties;

      import java.util.logging.Level;

      import java.util.logging.Logger;

      import javax.jms.JMSException;

      import javax.jms.ObjectMessage;

      import javax.jms.Queue;

      import javax.jms.QueueConnection;

      import javax.jms.QueueConnectionFactory;

      import javax.jms.QueueSender;

      import javax.jms.QueueSession;

      import javax.naming.Context;

      import javax.naming.InitialContext;

      import javax.naming.NamingException;


      /**

      *

      * @author zangnam

      */

      public class SendMailUility {

      String INITIAL_CONTEXT_FACTORY;

      String PROVIDER_URL;

      String URL_PKG_PREFIXES;

      String smtpServer;

      String pwd;

      String from;

      String to;

      String subject;

      String body;


      public SendMailUility(String INITIAL_CONTEXT_FACTORY, String PROVIDER_URL, String URL_PKG_PREFIXES, String smtpServer, String pwd, String from, String to, String subject, String body) {

      this.INITIAL_CONTEXT_FACTORY = INITIAL_CONTEXT_FACTORY;

      this.PROVIDER_URL = PROVIDER_URL;

      this.URL_PKG_PREFIXES = URL_PKG_PREFIXES;

      this.smtpServer = smtpServer;

      this.pwd = pwd;

      this.from = from;

      this.to = to;

      this.subject = subject;

      this.body = body;

      }


      public boolean SenMail() {


      QueueConnectionFactory factory;

      Queue queue;

      QueueConnection connection = null;

      QueueSender sender = null;

      QueueSession queueSession = null;

      try {

      Properties props = new Properties();

      props.put(Context.INITIAL_CONTEXT_FACTORY,this.INITIAL_CONTEXT_FACTORY);

      props.put(Context.PROVIDER_URL,this.PROVIDER_URL);

      props.put(Context.URL_PKG_PREFIXES, this.URL_PKG_PREFIXES);

      InitialContext jndiContext = new InitialContext(props);

      factory = (QueueConnectionFactory) jndiContext.lookup("dvdshop_jms_conectionfactory");

      queue = (Queue) jndiContext.lookup("jms/dvdshop_sendmail");

      connection = factory.createQueueConnection();

      queueSession = connection.createQueueSession(false, queueSession.AUTO_ACKNOWLEDGE);

      sender = queueSession.createSender(queue);

      ObjectMessage objMessage = queueSession.createObjectMessage();

      SendMail mailObject = new SendMail();

      mailObject.setFrom(this.from);

      mailObject.setTo(this.to);

      mailObject.setSubject(this.subject);

      mailObject.setSmtpServer(this.smtpServer);

      mailObject.setPwd(this.pwd);

      mailObject.setBody(this.body);

      objMessage.setObject(mailObject);

      sender.send(objMessage);

      return true;

      } catch (JMSException ex) {

      Logger.getLogger(SendMailUility.class.getName()).log(Level.SEVERE, null, ex);

      return false;

      } catch (NamingException ex) {

      Logger.getLogger(SendMailUility.class.getName()).log(Level.SEVERE, null, ex);

      return false;

      }

      }

      }


      Error

      java.lang.NoSuchMethodError: javassist.scopedpool.ScopedClassPool.<init>(Ljava/lang/ClassLoader;Ljavassist/ClassPool;Ljavassist/scopedpool/ScopedClassPoolRepository;Z)V

      org.jboss.aop.classpool.AOPClassPool.<init>(AOPClassPool.java:68)

      org.jboss.aop.classpool.AOPClassPool.<init>(AOPClassPool.java:58)

      org.jboss.aop.classpool.AOPClassPoolFactory.create(AOPClassPoolFactory.java:40)

      javassist.scopedpool.ScopedClassPoolRepositoryImpl.createScopedClassPool(ScopedClassPoolRepositoryImpl.java:99)

      javassist.scopedpool.ScopedClassPoolRepositoryImpl.registerClassLoader(ScopedClassPoolRepositoryImpl.java:125)

      org.jboss.aop.classpool.AOPClassPoolRepository.registerClassLoader(AOPClassPoolRepository.java:157)

      org.jboss.aop.AspectManager.registerClassLoader(AspectManager.java:845)

      org.jboss.aop.ClassAdvisor.attachClass(ClassAdvisor.java:273)

      org.jboss.aop.AspectManager.initialiseClassAdvisor(AspectManager.java:751)

      org.jboss.aop.AspectManager.getAdvisor(AspectManager.java:732)

      org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.<clinit>(ClientConnectionFactoryDelegate.java)

      sun.misc.Unsafe.ensureClassInitialized(Native Method)

      sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)

      sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:140)

      java.lang.reflect.Field.acquireFieldAccessor(Field.java:949)

      java.lang.reflect.Field.getFieldAccessor(Field.java:930)

      java.lang.reflect.Field.getLong(Field.java:548)

      java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1643)

      java.io.ObjectStreamClass.access$700(ObjectStreamClass.java:69)

      java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:467)

      java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:455)

      java.security.AccessController.doPrivileged(Native Method)

      java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:455)

      java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:352)

      java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:589)

      java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1601)

      java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)

      java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)

      java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)

      java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1964)

      java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1888)

      java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)

      java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)

      java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)

      java.rmi.MarshalledObject.get(MarshalledObject.java:159)

      org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)

      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:765)

      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:682)

      javax.naming.InitialContext.lookup(InitialContext.java:411)

      eproject.dvdshop.utils.SendMailUility.SenMail(SendMailUility.java:58)

      action.RegisterProccessAction.execute(RegisterProccessAction.java:94)

      org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)

      org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)

      org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)

      org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)

      javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

      javax.servlet.http.HttpServlet.service(HttpServlet.java:717