PDA

Visualizza la versione completa : [JAVA] Open JMS


robyp
17-09-2004, 12:26
Ciao,

Sto imparando ad usare open jms. Ho installato il "bus" e avviato con startup.bat mi dice che Ŕ attivo sull'indirizzo rmi://127.0.0.1:1099/JMSServer:

11:25:57.129 INFO [main] - Embedded RMI registry running on port 1099
11:25:57.644 INFO [main] - Started service [RmiRegistryService]
11:25:57.644 INFO [main] - Started service [ThreadPoolManager]
11:25:57.644 INFO [main] - Started service [EventManagerThread]
11:25:58.363 INFO [main] - Removed expired messages.
11:25:58.363 INFO [main] - Started service [DatabaseService]
11:25:58.363 INFO [main] - Started service [Scheduler]
11:25:58.363 INFO [main] - Started service [LeaseManagerReaper]
11:25:58.363 INFO [main] - Registering Garbage Collection every 60000 for memor
y.
11:25:58.379 INFO [main] - Registering Garbage Collection every 120000 for othe
r resources.
11:25:58.379 INFO [main] - Started service [GCCollectionService]
11:25:58.441 INFO [main] - Started service [MessageManager]
11:25:58.550 INFO [main] - Creating server interface for the rmi connector
11:25:58.675 INFO [main] - JMS Server is bound to rmi://127.0.0.1:1099/OpenJMSS
erver
11:25:58.738 INFO [main] - JMS Admin Server is bound to rmi://127.0.0.1:1099/Jm
sAdminServer
11:25:58.800 INFO [main] - Creating JNDI interface for the rmi connector

Ho provato ad inizializzare e a collegarmi al bus ma mi da un Eccezione quando creo il context con "new Initial context(properties)"
La classe che ho creato Ŕ questa:

package openjms;

import java.util.*;
import javax.jms.*;
import javax.naming.*;


public class client {
/**
* Valore di default del factory name: JmsQueueConnectionFactory
*/
public static final String DEFAULT_FACTORY_NAME = "JmsQueueConnectionFactory";
/**
* Valore di default della modalitÓ di connessione: rmi
*/
public static final String DEFAULT_MODE = "rmi";
/**
* Valore della modalitÓ RMI: rmi
*/
public static final String RMI_MODE = "rmi";
/**
* Valore della modalitÓ TCP: tcp
*/
public static final String TCP_MODE = "tcp";
/**
* Valore della modalitÓ TCPS: tcps
*/
public static final String TCPS_MODE = "tcps";
/**
* Valore della modalitÓ HTTP: http
*/
public static final String HTTP_MODE = "http";
/**
* Valore della modalitÓ HTTPS: https
*/
public static final String HTTPS_MODE = "https";
/**
* Valore di default della prioritÓ: 3
*/
public static final int DEFAULT_PRIORITY = 3;

public static final String PORT_NUMBER_PROPERTY = "org.exolab.jms.jndi.port";
public static final String HOST_PROPERTY = "org.exolab.jms.jndi.host";
public static final String NAME_PROPERTY = "org.exolab.jms.jndi.name";
public static final String HTTP_CLIENT_URL_PROPERTY = "org.exolab.jms.jndi.http_client_url";
public static final String HTTP_CLIENT_SERVER_ADDRESS_PROPERTY = "org.exolab.jms.jndi.http.client.address";

private String factoryName;
private String queueName;
private int secondToSleep;
private int priority;
private long timeToLive;
private boolean isPersistent;
private QueueConnectionFactory factory;
private Context context;
private QueueSession session;
private QueueConnection connection;
private QueueSender sender;
private Context ctx;
private String url;

public client() {
try{

String jndiport;
String jndihost;
java.util.Properties prop = new java.util.Properties();

//Setto la prioritÓ del messaggio
this. priority = Integer.parseInt(prop.getProperty("priority", Integer.toString(this.DEFAULT_PRIORITY)));
//Setto il parametro factoryName
this.factoryName = prop.getProperty("factoryName", this.DEFAULT_FACTORY_NAME);
//Setto il parametro timeToLive this.timeToLive = Long.parseLong(prop.getProperty("timeToLive", "0"));
//Setto il parametro isPersistent this.isPersistent = Boolean.getBoolean(prop.getProperty("isPersistent"));
jndiport = prop.getProperty("jndiport", "");
//Setto il parametro jndiport
jndihost = prop.getProperty("jndihost");


prop.put(Context.INITIAL_CONTEXT_FACTORY, org.exolab.jms.jndi.InitialContextFactory.class.ge tName());
String url;
if( (jndihost == null) && (jndiport == "") ) url= RMI_MODE + "://127.0.0.1:1099/OpenJMSServer";
else url = RMI_MODE + "://" + jndihost + ":" + jndiport + "/" + "OpenJMSServer";
prop.put(Context.PROVIDER_URL, url);
ctx = new InitialContext(prop);
//Fine inizializzazione



}catch(Exception e){System.out.println(e.getMessage().toString());}
}

public static void main(String []args)throws Exception{
client c = new client();
}
}

PerchŔ mi da eccezione alla riga "ctx = new InitialContext(prop); "??
Qualcuno lo sa?
Grazie!
Roby

robyp
17-09-2004, 12:34
L'errore che mi da Ŕ un NullPointerException
:master:

Loading