Servlet / Jini Lookup pbm

F

felix

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);
}
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top