Servlet / Jini Lookup pbm

Discussion in 'Java' started by felix, Mar 15, 2005.

  1. felix

    felix Guest

    Hello,

    I'm trying to contact a Jini lookup service (reggie) from a simple
    servlet. I'm using Tomcat 5.5.7, Java 1.5.0_01, Jini 1.2.1 and
    Solaris8.

    The problem is that, after the call to LookupDiscoveryManager() (see
    source code below), the "discovered()" method is never called back.

    Here is what I get in my browser after an exec :
    ********
    before LookupDiscoveryManager
    end
    ********

    I have successfully run a similar code in a standalone Java app (i.e.
    without Tomcat / servlet), and everything is OK.

    In fact, I have no error message nor Exception thrown. :-( I simply
    don't have any response from reggie.

    Any help would be appreciate,
    Olive

    PS: I'm new to Tomcat and Jini.



    =====================
    == core servlet
    =====================

    protected void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {

    response.setContentType("text/plain");
    PrintWriter out = response.getWriter();

    new searchALookup(out).start();
    try {
    Thread.sleep(30000);
    } catch (InterruptedException ie) {
    out.println("InterruptedException: " + ie.getMessage());
    }
    out.println("end");
    out.close();
    }



    ======================
    == searchALookup.java
    ======================

    import java.io.*;
    import net.jini.core.discovery.LookupLocator;
    import net.jini.core.lookup.*;
    import net.jini.discovery.*;

    public class searchALookup extends Thread implements DiscoveryListener
    {

    private LookupDiscoveryManager discover;
    private PrintWriter sortie;

    public chercheLookup(PrintWriter out) {
    sortie = out;
    }

    public void run() {
    try {
    startServiceDiscovery();
    } catch (IOException ioe) {
    sortie.println("Error while connecting to service");
    }
    }

    public synchronized void discovered(DiscoveryEvent dev) {
    sortie.println("--> Discovered");
    ServiceRegistrar[] lookup = dev.getRegistrars();
    // We may have discovered one or more lookup services
    sortie.println(lookup.length +" lookups decouverts");
    }

    public synchronized void discarded(DiscoveryEvent dev) {
    sortie.println("discarded");
    }

    private void startServiceDiscovery()
    throws IOException {

    String[] groups = null;
    LookupLocator[] locators = null;

    try{
    LookupLocator locator =
    new LookupLocator("jini://REGGIE_HOSTNAME");
    locators = new LookupLocator[]{locator};
    groups=DiscoveryGroupManagement.NO_GROUPS;
    }catch(java.net.MalformedURLException e){
    groups = new String[]{"public"};
    sortie.println("Groups ="+groups[0]);
    }

    // Initialize for receiving events from the lookup service
    sortie.println("before LookupDiscoveryManager");
    discover = new LookupDiscoveryManager(groups, locators, this);
    }
    }
     
    felix, Mar 15, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    370
    =?Utf-8?B?R2FicmllbCBGbG9yZXMgUi4=?=
    Jan 5, 2005
  2. circuit_breaker
    Replies:
    2
    Views:
    2,093
    Jack Jia
    Apr 4, 2004
  3. Zheng Da
    Replies:
    0
    Views:
    917
    Zheng Da
    Feb 26, 2006
  4. laniik

    Q: reading PBM

    laniik, Apr 27, 2005, in forum: C++
    Replies:
    3
    Views:
    451
    Karl Heinz Buchegger
    Apr 28, 2005
  5. Mr. X.
    Replies:
    0
    Views:
    334
    Mr. X.
    Jul 5, 2007
Loading...

Share This Page