The Artima Developer Community
Sponsored Link

Jini Forum
please help Running javaspaces

5 replies on 1 page. Most recent reply: Jun 3, 2002 8:08 PM by venkat

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
venkat

Posts: 4
Nickname: venkat
Registered: Jun, 2002

please help Running javaspaces Posted: Jun 3, 2002 12:18 AM
Reply to this message Reply
Advertisement
Hi!

iam able to run the javaspaces but end of the day i get the message
space is not found,
from the examples by steven halter and sing li.
please can u tell me what might the problem, iam using jini1.2, j2sdk1.4 on win2k.
thanks a lot
venkat


Rohit

Posts: 38
Nickname: rohit
Registered: May, 2002

Re: please help Running javaspaces Posted: Jun 3, 2002 12:57 AM
Reply to this message Reply
if you can send the details like , what are the coomands you are using to run services ,and some sample code where u r trying to get space

venkat

Posts: 4
Nickname: venkat
Registered: Jun, 2002

Re: please help Running javaspaces Posted: Jun 3, 2002 1:35 AM
Reply to this message Reply
Thanks Rohit.
i am sending the command and the codeaswell.
please reply me asap.
thanks once again, iam just compiling the examples programs from steven halters book, javaspaces examples by example, www.slhater.com
thanks
venkat


Browser:

set PATH=c:\j2sdk1.4.0\bin;%PATH%

java -jar "c:\jini1_2_1\lib\tools.jar" -port 8080 -dir "c:\jini1_2_1\lib" -trees -verbose

to run rmi

rmid -J-Dsun.rmi.activation.execPolicy=none

reggie service

java -Djava.security.policy="c:\jini1_2_1\example\lookup\policy.all" -jar "c:\jini1_2_1\lib\reggie.jar" http://192.168.10.27:8080/reggie-dl.jar "c:\jini1_2_1\example\lookup\policy.all" "c:\reggie.log public"

transaction manager (mahalo)

java -Djava.security.policy="c:\jini1_2_1\example\txn\policy.all" -jar "c:\jini1_2_1\lib\mahalo.jar" http://192.168.10.27:8080/mahalo-dl.jar "c:\jini1_2_1\example\txn\policy.all" "c:\temp\txn_log public"

java spaces

java -Djava.security.policy="c:\jini1_2_1\example\books\policy.all" -Djava.rmi.server.codebase=http://192.168.10.27:8080/outrigger-dl.jar -jar "c:\jini1_2_1\lib\transient-outrigger.jar" -Dcom.sun.jini.outrigger.spaceName=JavaSpaces public

set CLASSPATH="c:\j2sdk1.4.0\bin;c:\jini1_2_1\lib\jini-core.jar;c:\jini1_2_1\lib\ji ni-ext.jar;c:\jsbe;."

javac -d . -classpath %classpath%;"c:\jsbe" "c:\jsebe1_0\jsbe\util\SpaceUtil.java"

Creating Jar Files

1> jar xvf "c:\jini1_2_1\lib\jini-ext.jar" net\jini\lookup\ServiceDiscoveryManager$LookupCacheImpl$LookupListener_Stub.cla ss

2> jar xvf "c:\jini1_2_1\lib\jini-core.jar" net\jini\core\event\UnknownEventException.class net\jini\core\event\RemoteEventListener.class net\jini\core\event\RemoteEvent.class



another http server

java -jar "c:\jini1_2_1\lib\tools.jar" -port 8082 -dir c:\jsbe\classes\ch3-dl\ -verbose



java -Djava.security.policy="c:\jini1_2_1\example\books\policy.all" -Doutrigger.spacename=JavaSpaces -Dcom.sun.jini.lookup.groups=public -cp c:\jini1_2_1\lib\jini-ext.jar;c:\jini1_2_1\lib\jini-core.jar;c:\jsbe\; -Djava.rmi.server.codebase=http://192.168.10.27:8082/ jsbe.ch3.FindTest

SpaceUtil Code
---------------
package jsbe.util;

import net.jini.space.*;
import net.jini.core.lookup.*;
import net.jini.lookup.*;
import net.jini.discovery.*;
import java.rmi.RMISecurityManager;
import net.jini.lookup.entry.Name;
import net.jini.core.entry.Entry;
import net.jini.core.transaction.server.TransactionManager;


public class SpaceUtil {

private static String[] spaceGroups;
private static String[] tmGroups;
private static final int MAX_WAIT = 30000;
private static Class[] sTypes;
private static Class[] tmTypes;
private static LookupCache cache;
private static LookupDiscovery lDisc = null;
private static ServiceDiscoveryManager sdm = null;

static {
// If no one has set a Security Manager, create a new one
// and set it ourselves
if (System.getSecurityManager () == null) {
System.setSecurityManager (new RMISecurityManager());
}

// The string "" denotes the public group
spaceGroups = new String[] {""};
tmGroups = new String[] {""};

sTypes = new Class[1];
sTypes[0] = JavaSpace.class;

tmTypes = new Class[1];
tmTypes[0] = TransactionManager.class;
}

/**
* Set the groups to look for the JavaSpace within.
*/
public static void setSpaceGroups(String[] inGroups) {
spaceGroups = inGroups;
}

/**
* Set the groups to look for the transaction manager within.
*/
public static void setTMGroups(String[] inGroups) {
tmGroups = inGroups;
}

/**
* Find any space in the group
*/
public static JavaSpace findSpace() {
JavaSpace space = null;

try {
LookupDiscovery lDisc =
new LookupDiscovery(spaceGroups);
ServiceDiscoveryManager sdm =
new ServiceDiscoveryManager(lDisc, null);
ServiceItem si = null;

si = sdm.lookup(new ServiceTemplate(null,
sTypes, null),
null, MAX_WAIT);

if (si != null)
space = (JavaSpace)si.service;

} catch (Exception e) {
e.printStackTrace ();
}

return space;
}

/**
* Find the specified named JavaSpace.
* If the provided name is null, use
* the System property "com.sun.jini.outrigger.spacename".
* If that has not been set, then use the default name,
* "JavaSpaces".
* @return The appropriate JavaSpace
*/
public static JavaSpace findSpace(String spaceName) {
JavaSpace space = null;

try {
LookupDiscovery lDisc =
new LookupDiscovery(spaceGroups);
ServiceDiscoveryManager sdm =
new ServiceDiscoveryManager(lDisc, null);
ServiceItem si = null;

if (spaceName == null) { // No space name provided
// try to get a default name from the System
spaceName = System.getProperty(
"com.sun.jini.outrigger.spacename");
if (spaceName == null) {
// Use the default name JavaSpaces
spaceName = "JavaSpace";
}
}

Entry[] attributes = new Entry[1];
attributes[0] = new Name(spaceName);

si = sdm.lookup(new ServiceTemplate(null,
sTypes, attributes),
null, MAX_WAIT);


if (si != null)
space = (JavaSpace)si.service;

} catch (Exception e) {
e.printStackTrace ();
}

return space;
}

public static JavaSpace[] findSpaces() {
JavaSpace[] spaces = null;

try {
if (cache == null) {
setCache();
}
if (cache != null) {
ServiceItem[] si = cache.lookup(null,
20);

if (si != null && si.length > 0) {
spaces = new JavaSpace[si.length];
for (int i=0; i < si.length; i++) {
spaces = (JavaSpace)si.service;
}
}
}
} catch (Exception e) {
e.printStackTrace ();
}

return spaces;
}

private synchronized static void setCache() {
try {
if (cache == null) {
lDisc =
new LookupDiscovery(spaceGroups);
sdm =
new ServiceDiscoveryManager(lDisc,null);

cache =
sdm.createLookupCache(
new ServiceTemplate(null,
sTypes,
null),
null, null);

ServiceItem si = cache.lookup(null);

for (int i =0; (i < 100) && (si == null); i++) {
Thread.sleep(1000);
si = cache.lookup(null);
System.out.println(i);
}

}
} catch (Exception e) {
e.printStackTrace ();
}
}

/**
* Find any transaction manager in the groups
*/
public static TransactionManager findTransactionManager() {
TransactionManager tm = null;

try {
LookupDiscovery lDisc = new LookupDiscovery(tmGroups);
ServiceDiscoveryManager sdm =
new ServiceDiscoveryManager(lDisc, null);
ServiceItem si = null;

si = sdm.lookup(new ServiceTemplate(null,
tmTypes, null),
null, MAX_WAIT);

if (si != null)
tm = (TransactionManager)si.service;

} catch (Exception e) {
e.printStackTrace ();
}

return tm;
}

/**
* Find the specified named transaction manager.
* If the provided name is null, use
* the System property "com.sun.jini.mahalo.managerName".
* If that has not been set, then use the default name,
* "TransactionManager".
* @return The appropriate transaction manager
*/
public static TransactionManager
findTransactionManager(String tmName) {
TransactionManager tm = null;

try {

if (tmName == null) { // No space name provided
// try to get a default name from the System
tmName = System.getProperty(
"com.sun.jini.mahalo.managerName");
if (tmName == null) {
// Use the default name TransactionManager
tmName = "TransactionManager";
}
}

LookupDiscovery lDisc = new LookupDiscovery(tmGroups);
ServiceDiscoveryManager sdm =
new ServiceDiscoveryManager(lDisc, null);

Entry[] attributes = new Entry[1];
attributes[0] = new Name(tmName);

ServiceItem si = sdm.lookup(new ServiceTemplate(null,
tmTypes, attributes),
null, MAX_WAIT);

if (si != null)
tm = (TransactionManager)si.service;

} catch (Exception e) {
e.printStackTrace ();
}

return tm;
}
}





Find Test code
--------------
package jsbe.ch3;

import net.jini.space.*;
import net.jini.core.lookup.*;
import net.jini.lookup.*;
import net.jini.discovery.*;
import java.rmi.RMISecurityManager;
import net.jini.lookup.entry.Name;
import net.jini.core.entry.Entry;
import net.jini.core.transaction.server.TransactionManager;


import jsbe.util.* ;

public class FindTest {

public void run() {
try {

JavaSpace space = SpaceUtil.findSpace("JavaSpaces");

if (space != null) {
System.out.println ("The space was found.");
} else
System.out.println ("The space was not found.");

space = SpaceUtil.findSpace(null);

if (space != null) {
System.out.println ("The default space was found.");
} else
System.out.println (
"The default space was not found.");

space = SpaceUtil.findSpace();

if (space != null) {
System.out.println ("A space was found.");
} else
System.out.println ("A space was not found.");

} catch (Exception e) {
e.printStackTrace ();
}

}

public static void main(String[] args) {
FindTest ft = new FindTest();
ft.run();
}
}

venkat

Posts: 4
Nickname: venkat
Registered: Jun, 2002

Re: please help Running javaspaces Posted: Jun 3, 2002 1:39 AM
Reply to this message Reply
hi! rohit.
the site is www.slhalter.com sorry,
iam able to locate default space, but when i write in to that space it gives the message as
space not found
thanks
venkat

Rohit

Posts: 38
Nickname: rohit
Registered: May, 2002

Re: please help Running javaspaces Posted: Jun 3, 2002 3:48 AM
Reply to this message Reply
just had a quick look at code, not sure this is the porblem or not,
in code , i am not able to see any write being issued,anyhow may be u r doing that somewhere else, but be sure of two words which in this code something confusing, and may be u r just swapping them, using one in place of another

JavaSpace or JavaSpaces which u r setting on command line,make sure u r searching for right one

venkat

Posts: 4
Nickname: venkat
Registered: Jun, 2002

Re: please help Running javaspaces Posted: Jun 3, 2002 8:08 PM
Reply to this message Reply
hi! Rohit
i have changed the name, still its not working, iam able to find default space, but when i want to write in to that is popping the message space not found.
thanks for ur time.
what could be missing.
please mail me back.
thanks
venkat

Flat View: This topic has 5 replies on 1 page
Topic: jsp sessions Previous Topic   Next Topic Topic: Writing entries into a JavaSpace and transactions

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use