geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Katia Aresti Gonzalez" <kaare...@hotmail.com>
Subject Geronimo and JMS
Date Thu, 28 Apr 2005 17:34:56 GMT
<html><div style='background-color:'><DIV class=RTE>Hi!!</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>Im writing a simple JMS application, and I have a little problem. I have
done 2 classes, here is the source code:</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE><FONT face="Courier New, Courier, Monospace"><STRONG>import
javax.jms.*;<BR>import javax.naming.*;</STRONG></FONT></DIV>
<DIV class=RTE><FONT face="Courier New, Courier, Monospace"><STRONG>public
class EnviaPS{<BR>&nbsp;public static void main (String args[]){<BR></STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;try
{<BR>&nbsp;&nbsp;&nbsp;InitialContext ctx = new InitialContext();<BR>&nbsp;&nbsp;&nbsp;TopicConnectionFactory
tcf = (TopicConnectionFactory)ctx.lookup("java:comp/env/jms/ConnectionFactoryLocalTx");<BR>&nbsp;&nbsp;&nbsp;TopicConnection
connection = tcf.createTopicConnection();<BR>&nbsp;&nbsp;&nbsp;Topic topic
= (Topic)ctx.lookup("java:comp/env/jms/<STRONG>ATopic</STRONG>");<BR>&nbsp;&nbsp;&nbsp;connection.start();<BR>&nbsp;&nbsp;&nbsp;TopicSession
session = connection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);<BR>&nbsp;&nbsp;&nbsp;TopicPublisher
publisher = session.createPublisher(topic);<BR>&nbsp;&nbsp;&nbsp;TextMessage
message = 
session.createTextMessage();<BR>&nbsp;&nbsp;&nbsp;message.setText("Hola
mundo!!");<BR>&nbsp;&nbsp;&nbsp;publisher.publish(message);<BR>&nbsp;&nbsp;&nbsp;System.out.println("Mensaje
enviado: " + message.getText());<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;}
catch (NamingException e){<BR>&nbsp;&nbsp;&nbsp;e.printStackTrace();<BR>&nbsp;&nbsp;}
catch (JMSException e) {<BR>&nbsp;&nbsp;&nbsp;e.printStackTrace();<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>}</FONT></DIV>
<DIV class=RTE><FONT face="Courier New"></FONT>&nbsp;</DIV>
<DIV class=RTE><FONT face="Courier New"><STRONG>import javax.jms.*;<BR>import
javax.naming.*;</STRONG></FONT></DIV>
<DIV class=RTE><FONT face="Courier New"><STRONG>public class RecibePS implements
MessageListener{<BR></STRONG>&nbsp;<BR>&nbsp;public static void
main (String args[]){<BR>&nbsp;&nbsp;new RecibePS().suscribe();<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;public
void suscribe(){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;try
{<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;InitialContext
ctx = new InitialContext();<BR>&nbsp;&nbsp;&nbsp;TopicConnectionFactory
tcf = (TopicConnectionFactory)ctx.lookup("java:comp/env/jms/ConnectionFactoryLocalTx");<BR>&nbsp;&nbsp;&nbsp;TopicConnection
connection = tcf.createTopicConnection();<BR>&nbsp;&nbsp;&nbsp;Topic topic
= (Topic)ctx.lookup("java:comp/env/jms/<STRONG>ATopic</STRONG>");<BR>&nbsp;&nbsp;&nbsp;TopicSession
session = connection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);<BR>&nbsp;&nbsp;&nbsp;TopicSubscriber
suscrito = 
session.createSubscriber(topic);<BR>&nbsp;&nbsp;&nbsp;suscrito.setMessageListener(this);<BR>&nbsp;&nbsp;&nbsp;connection.start();<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;}
catch (NamingException e){<BR>&nbsp;&nbsp;&nbsp;e.printStackTrace();<BR>&nbsp;&nbsp;}
catch (JMSException e) {<BR>&nbsp;&nbsp;&nbsp;e.printStackTrace();<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;public
void onMessage(Message mensaje){<BR>&nbsp;&nbsp;// Se recibe un mensaje<BR>&nbsp;&nbsp;try{<BR>&nbsp;&nbsp;&nbsp;//
Si es un mensaje de texto, lo mostramos<BR>&nbsp;&nbsp;&nbsp;if (mensaje
instanceof TextMessage){<BR>&nbsp;&nbsp;&nbsp;&nbsp;TextMessage m =
(TextMessage)mensaje;<BR>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("Mensaje
recibido: " + m.getText());<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}
catch (JMSException e){<BR>&nbsp;&nbsp;&nbsp;e.printStackTrace();<BR>&nbsp;&nbsp;}&nbsp;<BR>&nbsp;}<BR>&nbsp;<BR>}</FONT></DIV>
<DIV class=RTE><FONT face="Courier New"></FONT>&nbsp;</DIV>
<DIV class=RTE><FONT face="Courier New">I first undeploy the "org/apache/geronimo/SystemJMS"
and deployed again with a new topic calles ATopic. Then, i run the files agains the server
using a .bat.</FONT></DIV>
<DIV class=RTE><FONT face="Courier New"></FONT>&nbsp;</DIV>
<DIV class=RTE>set classpath=c:\gero\repository\openejb\jars\openejb-core-2.0-SNAPSHOT.jar;c:\gero\lib\cglib-full-2.0.2.jar;c:\gero\lib\geronimo-kernel-1.0-SNAPSHOT.jar;c:\gero\repository\geronimo\jars\geronimo-security-1.0-SNAPSHOT.jar;c:\gero\repository\geronimo-spec\jars\geronimo-spec-j2ee-jacc-1.0-rc4.jar;c:\gero\repository\geronimo\jars\geronimo-kernel-1.0-SNAPSHOT.jar;D:\cmp\build\classes;C:\j2sdkee1.3.1\lib\j2ee.jar;d:\jms;d:\jms\jstl-1.1.1.jar;d:\jms\standard-1.1.1.jar</DIV>
<DIV class=RTE>java EnviaPS<BR>pause<BR>java RecibePS<BR>pause</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>I get a JNDI Error. Could somebody say me whats going wrong? Do i have
to put more jars on the claspath to run the standalone files? what more do i need? </DIV>
<DIV class=RTE>Thank you very much!!!!!!!!</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>Katia</DIV></div><br clear=all><hr>Tu horóscopo
diario, semanal y gratuito.  <a href="http://g.msn.com/8HMAESES/2728??PS=47575" target="_top">Cartas,
tarot y predicciones en MSN Horóscopo</a> </html>


Mime
View raw message