[jboss-user] [JBoss Messaging] - Need Help : Can TomCat Client send message to destination in JMS of jboss Messaging (jboss 5.0.1)
Hai Nguyen
do-not-reply at jboss.com
Wed Dec 5 01:44:39 EST 2012
Hai Nguyen [https://community.jboss.org/people/micro_] created the discussion
"Need Help : Can TomCat Client send message to destination in JMS of jboss Messaging (jboss 5.0.1)"
To view the discussion, visit: https://community.jboss.org/message/780022#780022
--------------------------------------------------------------
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 = ( http://docs.oracle.com/javaee/6/api/javax/jms/QueueConnectionFactory.html QueueConnectionFactory) jndiContext.lookup("dvdshop_jms_conectionfactory");*
Please help me , thank you much.
my full code
package utility;
import eproject.dvdshop.entities.SendMail;
import http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html java.util.Properties;
import http://docs.oracle.com/javase/7/docs/api/java/util/logging/Level.html java.util.logging.Level;
import http://docs.oracle.com/javase/7/docs/api/java/util/logging/Logger.html java.util.logging.Logger;
import http://docs.oracle.com/javaee/6/api/javax/jms/JMSException.html javax.jms.JMSException;
import http://docs.oracle.com/javaee/6/api/javax/jms/ObjectMessage.html javax.jms.ObjectMessage;
import http://docs.oracle.com/javaee/6/api/javax/jms/Queue.html javax.jms.Queue;
import http://docs.oracle.com/javaee/6/api/javax/jms/QueueConnection.html javax.jms.QueueConnection;
import http://docs.oracle.com/javaee/6/api/javax/jms/QueueConnectionFactory.html javax.jms.QueueConnectionFactory;
import http://docs.oracle.com/javaee/6/api/javax/jms/QueueSender.html javax.jms.QueueSender;
import http://docs.oracle.com/javaee/6/api/javax/jms/QueueSession.html javax.jms.QueueSession;
import http://docs.oracle.com/javase/7/docs/api/javax/naming/Context.html javax.naming.Context;
import http://docs.oracle.com/javase/7/docs/api/javax/naming/InitialContext.html javax.naming.InitialContext;
import http://docs.oracle.com/javase/7/docs/api/javax/naming/NamingException.html javax.naming.NamingException;
/**
*
* @author zangnam
*/
public class SendMailUility {
http://www.coderanch.com/t/410859/java/java/String-StringBuffer-StringBuilder-Performance 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() {
http://docs.oracle.com/javaee/6/api/javax/jms/QueueConnectionFactory.html QueueConnectionFactory factory;
Queue queue;
http://docs.oracle.com/javaee/6/api/javax/jms/QueueConnection.html QueueConnection connection = null;
http://docs.oracle.com/javaee/6/api/javax/jms/QueueSender.html QueueSender sender = null;
http://docs.oracle.com/javaee/6/api/javax/jms/QueueSession.html 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);
http://docs.oracle.com/javase/7/docs/api/javax/naming/InitialContext.html InitialContext jndiContext = new http://docs.oracle.com/javase/7/docs/api/javax/naming/InitialContext.html InitialContext(props);
factory = ( http://docs.oracle.com/javaee/6/api/javax/jms/QueueConnectionFactory.html 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);
http://docs.oracle.com/javaee/6/api/javax/jms/ObjectMessage.html 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 ( http://docs.oracle.com/javaee/6/api/javax/jms/JMSException.html JMSException ex) {
Logger.getLogger(SendMailUility.class.getName()).log(Level.SEVERE, null, ex);
return false;
} catch ( http://docs.oracle.com/javase/7/docs/api/javax/naming/NamingException.html 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
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/780022#780022]
Start a new discussion in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20121205/9a19f4db/attachment-0001.html
More information about the jboss-user
mailing list