salut !
je voudrais pouvoir utiliser Jms sur Jboss, mais voila, mon prog me renvoit l'erreur suivante:
Starting...
javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable.]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:707)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.xml.sax.Sender.main(Sender.java:24)
Caused by: java.rmi.RemoteException: Service unavailable.
at org.jboss.ha.framework.interfaces.HARMIClient.invokeRemote(HARMIClient.java:158)
at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:196)
at $Proxy0.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
... 3 more
Ending...
je débute avec Jboss, avec eclipse aussi, enfin bref, avec J2EE.
j'ai lu un article sur la configuration de Jboss mais, je desespère de trouver comment configuré le serveur !
que signifit "javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable"??
que parametre dois je modifier ?
Code :
- public class Sender {
- public static void main(String[] args) {
- System.out.println("Starting..." );
- QueueConnectionFactory aQCF = null;
- QueueConnection aQC = null;
- QueueSession aQS = null;
- QueueSender aSender = null;
- try {
- InitialContext aIC = new InitialContext(Resource.getResources());
- aQCF = (QueueConnectionFactory) aIC.lookup("ConnectionFactory" );
- aQC = aQCF.createQueueConnection();
- aQS = aQC.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue aQueue = (Queue) aIC.lookup("queue/A" );
- //ici, une queue qui tourne sur jboss
- aSender = aQS.createSender(aQueue);
- aQC.start();
- for (int i = 0; i < 10; i++) {
- aSender.send(aQS.createObjectMessage(new Integer(i)));
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- if (aSender != null) {
- aSender.close();
- }
- if (aQS != null) {
- aQS.close();
- }
- if (aQC != null) {
- aQC.stop();
- aQC.close();
- }
- } catch (JMSException e) {
- e.printStackTrace();
- }
- }
- System.out.println("Ending..." );
- }
- }
|
Code :
- package com.xml.sax;
- import java.io.InputStreamReader;
- import javax.jms.JMSException;
- import javax.jms.MessageListener;
- import javax.jms.ObjectMessage;
- import javax.jms.QueueConnection;
- import javax.jms.QueueConnectionFactory;
- import javax.jms.QueueReceiver;
- import javax.jms.QueueSession;
- import javax.naming.InitialContext;
- import sun.misc.Queue;
- import com.sun.corba.se.internal.iiop.messages.Message;
- public abstract class Receiver {
- protected void doAll() {
- QueueConnectionFactory aQCF = null;
- QueueConnection aQC = null;
- QueueSession aQS = null;
- QueueReceiver aQR = null;
- try {
- InitialContext aIC = new InitialContext(Resource.getResources());
- aQCF = (QueueConnectionFactory) aIC.lookup("ConnectionFactory" );
- aQC = aQCF.createQueueConnection();
- aQS = createQueueSession(aQC);
- final QueueSession aQS1 = aQS;
- Queue aQueue = (Queue) aIC.lookup("queue/A" );
- aQR = aQS.createReceiver(aQueue);
- MessageListener aML = new MessageListener() {
- public void onMessage(Message aMessage) {
- try {
- processMessage(aMessage, aQS1);
- } catch (JMSException e) {
- e.printStackTrace();
- }
- }
- };
-
- aQR.setMessageListener(aML);
- aQC.start();
- InputStreamReader aISR = new InputStreamReader(System.in);
- char aAnswer = ' ';
- do {
- aAnswer = (char) aISR.read();
- if ((aAnswer == 'r') || (aAnswer == 'R')) {
- aQS.recover();
- }
- } while ((aAnswer != 'q') && (aAnswer != 'Q'));
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- if (aQR != null) {
- aQR.close();
- }
- if (aQS != null) {
- aQS.close();
- }
- if (aQC != null) {
- aQC.stop();
- aQC.close();
- }
- } catch (JMSException e) {
- e.printStackTrace();
- }
- }
- }
- protected void processMessage(Message aMessage, QueueSession aQS) throws JMSException {
- if (aMessage instanceof ObjectMessage) {
- ObjectMessage aOM = (ObjectMessage) aMessage;
- System.out.print(aOM.getObject() + " " );
- System.out.print(" message recieved " );
- }
- }
- protected abstract QueueSession createQueueSession(
- QueueConnection aQC
- ) throws JMSException;
- }
|