authTopic = (Topic) initialContext.lookup("topic/topicAuth");
authTopic = (Topic) initialContext.lookup(BeanConfig.PrefixTopicName+"topicAuth");
  public String getAboutMe(String username, String password) throws RemoteException  {    UserTransaction utx    = null;    PreparedStatement stmt = null;    ResultSet rs           = null;    Connection conn        = null;    int          userId       = -1;    StringBuffer html      = new StringBuffer();    // Authenticate the user      if ((username != null && !username.equals("")) || (password != null && !password.equals("")))      {        TopicConnection authConnection;        TopicSession authSession;        Topic authTopic;        try         {          // create a connection          authConnection = connectionFactory.createTopicConnection();          // lookup the destination          authTopic = (Topic) initialContext.lookup("topic/topicAuth");          // create a session          authSession  = authConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); // no transaction and auto ack        }         catch (Exception e)        {          throw new EJBException("Cannot connect to message bean MDB_Auth : " +e+"<br>");        }        try         {          // create a requestor to receive the reply          TopicRequestor requestor = new TopicRequestor(authSession, authTopic);          // create a message          MapMessage m = authSession.createMapMessage();          // set parameters          m.setStringProperty("nickname", username);          m.setStringProperty("password", password);          m.setJMSCorrelationID("auth");          // send the message and receive the reply          authConnection.start(); // allows message to be delivered (default is connection stopped)          MapMessage authReply = (MapMessage)requestor.request(m);          authConnection.stop();          // read the reply          userId = authReply.getInt("userId");          // close connection and session          requestor.close(); // also close the session          authConnection.close();        }         catch (Exception e)        {          throw new EJBException("user authentication failed: " +e+"<br>");        }        if (userId == -1)        {           html.append("You don't have an account on RUBiS!<br>You have to register first.<br>");           return html.toString();        }      }    // Try to find the user corresponding to the userId    String firstname = null, lastname = null, nickname = null, email = null, date = null;    int rating = 0;    try    {      conn = dataSource.getConnection();      stmt = conn.prepareStatement("SELECT * FROM users WHERE id=?");      stmt.setInt(1, userId);      rs = stmt.executeQuery();    }    catch (Exception e)    {      try { stmt.close(); } catch (Exception ignore) {}      try { conn.close(); } catch (Exception ignore) {}      throw new RemoteException("Failed to execute Query for user: " +e);    }    try     {      if (rs.first())      {        firstname = rs.getString("firstname");        lastname = rs.getString("lastname");        nickname = rs.getString("nickname");        email = rs.getString("email");        date = rs.getString("creation_date");        rating = rs.getInt("rating");      }      stmt.close();      conn.close();      html.append("<h2>Information about "+nickname+"<br></h2>");      html.append("Real life name : "+firstname+" "+lastname+"<br>");      html.append("Email address  : "+email+"<br>");      html.append("User since     : "+date+"<br>");      html.append("Current rating : <b>"+rating+"</b><br>");    }    catch (Exception e)    {      try { stmt.close(); } catch (Exception ignore) {}      try { conn.close(); } catch (Exception ignore) {}      throw new RemoteException("This user does not exist (got exception: " +e+")<br>");    }    try     {      utx = messageDrivenContext.getUserTransaction();      utx.begin();      conn = dataSource.getConnection();      html.append(listItem(userId, conn));      html.append(listBoughtItems(userId, conn));      html.append(listWonItems(userId, conn));      html.append(listBids(userId, username, password, conn));      html.append(listComments(userId, conn));      conn.close();      utx.commit();    }     catch (Exception e)    {      try { conn.close(); } catch (Exception ignore) {}      try { utx.rollback(); } catch (Exception ignore) {}      throw new RemoteException("Cannot get information about items and bids: " +e+"<br>");    }    return html.toString();  }