0 Replies Latest reply on Feb 18, 2004 7:24 AM by ammon

    HELP :::::::: ctx.lookup("ConnectionFactory") NULLPOINTEXCEP

    ammon Newbie

      I am passing from weblogic to jboss 3.2.3. I am meeting problems in using JMS. from the client(applet) I have the following code:
      package clients.common.messaging;

      import clients.common.util.AppletProperties;
      import clients.common.debug.Debug;
      import javax.jms.JMSException;
      import javax.jms.Session;
      import javax.naming.NamingException;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import java.util.*;
      import java.awt.event.ActionListener;
      import javax.jms.TopicConnectionFactory;
      import javax.jms.TopicConnection;
      import javax.jms.TopicSession;
      import javax.jms.TopicSubscriber;
      import javax.jms.Topic;
      import javax.jms.MessageListener;
      import javax.jms.ExceptionListener;
      import javax.jms.TextMessage;
      import clients.applets.zones.Zones;
      import clients.common.swing.JMessageBar;

      * Ricevitore dei messaggi JMS.
      * Descrizione:
      * Ricevitore dei messaggi JMS.
      * La classe riceve e inoltra il messaggio ricevuto al JMSMessaggeManager.
      * @version 1.0

      public class JMSMessageReceiver
      implements MessageListener, ExceptionListener {

      String connectFactory="java:/XAConnectionFactory";

      public JMSMessageReceiver(String topicName, AppletProperties appletProperties,
      JMSMessagesManager jmsMessagesManager) {
      this.appletProperties = appletProperties;
      this.jmsMessagesManager = jmsMessagesManager;
      urlProvider = appletProperties.getJMSProvider();
      ctxInizialeWeblogic = appletProperties.getCtxInizialeWeblogic();
      this.topicName = topicName;
      try {
      InitialContext ic = getInitialContext(urlProvider);
      init(ic, topicName);
      catch (Exception e) {

      * Message listener interface.
      * @param msg message
      public void onMessage(javax.jms.Message msg) {
      try {
      String message;
      if (msg instanceof TextMessage) {
      message = ( (TextMessage) msg).getText();
      jmsMessagesManager.addMessages(message, topicName);
      else {
      message = msg.toString();
      catch (JMSException jmse) {
      Debug.printWarning("Errore durante la ricezione del messaggio.");

      public void onException(JMSException exception) {
      Debug.printWarning("JMSServer is go down.");
      if (appletProperties.getApplet() instanceof Zones) {
      Zones zones = (Zones)appletProperties.getApplet();

      * Creates all the necessary objects for sending
      * messages to a JMS topic.
      * @param ctx JNDI initial context
      * @param topicName name of topic
      * @exception NamingException if problem occurred with JNDI context interface
      * @exception JMSException if JMS fails to initialize due to internal error
      public void init(Context ctx, String topicName) {
      Object tmp = ctx.lookup("ConnectionFactory");
      tconFactory = (TopicConnectionFactory) tmp;
      tcon = tconFactory.createTopicConnection();
      tsession = tcon.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
      topic = (Topic) ctx.lookup(topicName);
      tsubscriber = tsession.createSubscriber(topic);
      }catch(Exception e){

      * Closes JMS objects.
      * @exception JMSException if JMS fails to close objects due to internal error
      public void close() throws JMSException {

      private static InitialContext getInitialContext(String url) throws NamingException {
      String jndiUrl = "jnp://xxxxx:1099";
      java.util.Properties props = new Properties();
      props.setProperty(Context.PROVIDER_URL, jndiUrl);
      props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props.setProperty (Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");

      try {
      return new InitialContext(props);
      catch (Exception e) {
      connected = false;
      return null;

      public boolean isConnected() {
      return connected;

      private ActionListener receiverMessageListener; // listener per la ricezione dei messaggi.
      private AppletProperties appletProperties;

      // proprietà dall'applet.
      * @label addMessage (xml)
      private JMSMessagesManager jmsMessagesManager; // Message manager (Classe a cui vengono rigirati i messaggi letti.)
      public final static String JNDI_FACTORY = "org.jnp.interfaces.NamingContextFactory";//cambiato
      public final static String JMS_FACTORY = "TopicConnectionFactory";
      private String topicName; // Nome dala topic su cui arrivano i messaggi
      private String urlProvider; // Provider T3
      private String ctxInizialeWeblogic;
      private TopicConnectionFactory tconFactory;
      private TopicConnection tcon;
      private TopicSession tsession;
      private TopicSubscriber tsubscriber;
      private Topic topic;
      private static boolean connected = true;
      private boolean quit = false;


      When I make the lookup with "ConnectionFactory" I have a NullPointException. But I have always NullPointException also with XAConnectionFactory, OIL...
      I must declare something in jboss-web.xml or jboss.xml. You have the patience to explain what I must to make .....

      tanks ...