aspose file tools*
The moose likes Tomcat and the fly likes Need Help : Can TomCat Client send message to destination in JMS ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Need Help : Can TomCat Client send message to destination in JMS ?" Watch "Need Help : Can TomCat Client send message to destination in JMS ?" New topic
Author

Need Help : Can TomCat Client send message to destination in JMS ?

zang nam
Greenhorn

Joined: Nov 23, 2012
Posts: 5
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;
}
}
}



Dec 03, 2012 2:01:21 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet action threw exception
java.lang.NoSuchMethodError: javassist.scopedpool.ScopedClassPool.<init>(Ljava/lang/ClassLoader;Ljavassist/ClassPool;Ljavassist/scopedpool/ScopedClassPoolRepository;Z)V
at org.jboss.aop.classpool.AOPClassPool.<init>(AOPClassPool.java:68)
at org.jboss.aop.classpool.AOPClassPool.<init>(AOPClassPool.java:58)
at org.jboss.aop.classpool.AOPClassPoolFactory.create(AOPClassPoolFactory.java:40)
at javassist.scopedpool.ScopedClassPoolRepositoryImpl.createScopedClassPool(ScopedClassPoolRepositoryImpl.java:99)
at javassist.scopedpool.ScopedClassPoolRepositoryImpl.registerClassLoader(ScopedClassPoolRepositoryImpl.java:125)
at org.jboss.aop.classpool.AOPClassPoolRepository.registerClassLoader(AOPClassPoolRepository.java:157)
at org.jboss.aop.AspectManager.registerClassLoader(AspectManager.java:845)
at org.jboss.aop.ClassAdvisor.attachClass(ClassAdvisor.java:273)
at org.jboss.aop.AspectManager.initialiseClassAdvisor(AspectManager.java:751)
at org.jboss.aop.AspectManager.getAdvisor(AspectManager.java:732)
at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.<clinit>(ClientConnectionFactoryDelegate.java)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:140)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:949)
at java.lang.reflect.Field.getFieldAccessor(Field.java:930)
at java.lang.reflect.Field.getLong(Field.java:548)
at java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1643)
at java.io.ObjectStreamClass.access$700(ObjectStreamClass.java:69)
at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:467)
at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:455)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:455)
at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:352)
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:589)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1601)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1964)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1888)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at java.rmi.MarshalledObject.get(MarshalledObject.java:159)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:765)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:682)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at utility.SendMailUility.SenMail(SendMailUility.java:58)
at action.RegisterProccessAction.execute(RegisterProccessAction.java:89)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)



 
 
subject: Need Help : Can TomCat Client send message to destination in JMS ?