Hello to everybody.
I will provide below all information that I can do it, as requested
by Dan and Gregg.
* context: I have two machines, jaguar (192.168.0.3) and xavante
(192.168.0.5). Reggie, mahalo and the service (as well their relative
web servers) are running on xavante. The client (and its rleated web
server) is running on jaguar.
* configuration file used to start the web server, reggie and mahalo,
named 'start-transient-ws-jeri-mahalo.config':
----
import com.sun.jini.start.NonActivatableServiceDescriptor;
import com.sun.jini.start.ServiceDescriptor;
com.sun.jini.start {
//
// HTTPD Service
//
private static httpd_codebase = "";
private static httpd_policy = "/home/helcio/jini/servicos/jsk-all.policy";
private static httpd_classpath =
"/usr/local/apache-river-2.1.1/lib/classserver.jar";
private static httpd_impl = "com.sun.jini.tool.ClassServer";
private static httpd_service =
new NonActivatableServiceDescriptor(
httpd_codebase, httpd_policy, httpd_classpath, httpd_impl,
new String[]{"-port", "8080", "-dir",
"/usr/local/apache-river-2.1.1/lib-dl/", "-verbose"});
//
// Mahalo (Transaction Service)
//
private static mahalo_codebase = "http://192.168.0.105:8080/mahalo-dl.jar"
+ " http://192.168.0.105:8080/jsk-dl.jar";
private static mahalo_policy = "/home/helcio/jini/servicos/jsk-all.policy";
private static mahalo_classpath =
"/usr/local/apache-river-2.1.1/lib/mahalo.jar";
private static mahalo_config =
"/home/helcio/jini/servicos/transient-jeri-mahalo.config";
private static mahalo_impl = "com.sun.jini.mahalo.TransientMahaloImpl";
private static mahalo_service =
new NonActivatableServiceDescriptor(
mahalo_codebase, mahalo_policy, mahalo_classpath,
mahalo_impl, new String[] { mahalo_config });
//
// Reggie (Lookup Service)
//
private static reggie_codebase = "http://192.168.0.105:8080/reggie-dl.jar"
+ " http://192.168.0.105:8080/jsk-dl.jar";
private static reggie_policy = "/home/helcio/jini/servicos/jsk-all.policy";
private static reggie_classpath =
"/usr/local/apache-river-2.1.1/lib/reggie.jar";
private static reggie_config =
"/home/helcio/jini/servicos/transient-jeri-reggie.config";
private static reggie_impl = "com.sun.jini.reggie.TransientRegistrarImpl";
private static reggie_service =
new NonActivatableServiceDescriptor(
reggie_codebase, reggie_policy, reggie_classpath,
reggie_impl, new String[] { reggie_config });
static serviceDescriptors = new ServiceDescriptor[] {
httpd_service,
mahalo_service,
reggie_service
};
}
----
* transient-jeri-reggie.config:
----
com.sun.jini.reggie {
initialMemberGroups = new String[] { "public" };
}
----
* transient-jeri-mahalo.config:
----
com.sun.jini.mahalo {
initialLookupGroups = new String[] { "public" };
}
----
* complete trace obtained when I run client:
----
helcio@jaguar:~/jini/exemplos/transacoes$ ./start-transClient
beginning of client's constructor:
--> installing a security manager...ok.
--> creating a lookup discovery object...ok.
--> adding a discovery listener...ok.
end of server's constructor.
beggining of 'discovered' method invocation:
--> obtaining a proxy to service...java.rmi.ConnectException:
connection refused or timed out to
BasicObjectEndpoint[5bab97fe-7824-46c6-ae70-ef9fadc8db66,TcpEndpoint[127.0.1.1:41700]];
nested exception is:
java.net.ConnectException: Connection refused
at net.jini.jeri.BasicInvocationHandler.wrapSafeIOException(Unknown
Source)
at net.jini.jeri.BasicInvocationHandler.invokeRemoteMethodOnce(Unknown
Source)
at net.jini.jeri.BasicInvocationHandler.invokeRemoteMethod(Unknown
Source)
at net.jini.jeri.BasicInvocationHandler.invoke(Unknown Source)
at com.sun.jini.reggie.$Proxy0.lookup(Unknown Source)
at com.sun.jini.reggie.RegistrarProxy.lookup(RegistrarProxy.java:112)
at
client.TransAbstractConfigurationClient.discovered(TransAbstractConfigurationClient.java:111)
at net.jini.discovery.LookupDiscovery$Notifier$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at net.jini.discovery.LookupDiscovery$Notifier.run(Unknown Source)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
at
java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
at
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:546)
at
net.jini.jeri.tcp.TcpEndpoint$ConnectionEndpointImpl.connectToSocketAddress(Unknown
Source)
at
net.jini.jeri.tcp.TcpEndpoint$ConnectionEndpointImpl.connectToHost(Unknown
Source)
at net.jini.jeri.tcp.TcpEndpoint$ConnectionEndpointImpl.connect(Unknown
Source)
at net.jini.jeri.connection.ConnectionManager.connect(Unknown Source)
at net.jini.jeri.connection.ConnectionManager$ReqIterator.next(Unknown
Source)
at net.jini.jeri.BasicObjectEndpoint$1.next(Unknown Source)
... 9 more
----
* client's code:
---
package client;
import common.AbstractConfiguration;
import java.rmi.*;
import net.jini.core.lease.*;
import net.jini.core.lookup.*;
import net.jini.core.transaction.server.*;
import net.jini.discovery.*;
import net.jini.export.*;
import net.jini.lease.*;
import net.jini.lookup.*;
import net.jini.jeri.*;
import net.jini.jeri.tcp.*;
public class TransAbstractConfigurationClient
implements TransactionParticipant, DiscoveryListener {
private AbstractConfiguration proxy2Service = null;
private TransactionManager proxy2TxnMgr = null;
private LookupDiscovery discover = null;
public static void main(String[] args) {
new TransAbstractConfigurationClient();
try {
Thread.currentThread().sleep(100000L);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
public TransAbstractConfigurationClient() {
System.out.println("beginning of client's constructor:");
System.out.print("--> installing a security manager...");
System.setSecurityManager(new RMISecurityManager());
System.out.print("ok.\n");
try {
System.out.print("--> creating a lookup discovery object...");
discover = new LookupDiscovery(LookupDiscovery.ALL_GROUPS);
System.out.print("ok.\n");
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
System.out.print("--> adding a discovery listener...");
discover.addDiscoveryListener(this);
System.out.print("ok.\n");
System.out.println("end of server's constructor.");
}
public int prepare(TransactionManager proxy2TxnMgr, long transactionID) {
System.out.println("preparing...");
return TransactionConstants.PREPARED;
}
public void commit(TransactionManager proxy2TxnMgr, long transactionID) {
System.out.println("committing...");
}
public void abort(TransactionManager proxy2TxnMgr, long transactionID) {
System.out.println("aborting...");
}
public int prepareAndCommit(TransactionManager proxy2TxnMgr,
long transactionID) {
int result = prepare(proxy2TxnMgr, transactionID);
if (result == TransactionConstants.PREPARED) {
commit(proxy2TxnMgr, transactionID);
result = TransactionConstants.COMMITTED;
}
return result;
}
public void discovered(DiscoveryEvent evt) {
System.out.println("beggining of 'discovered' method invocation:");
ServiceRegistrar[] proxies2Lus = evt.getRegistrars();
ServiceRegistrar proxy2Lus = proxies2Lus[0];
Class[] classes = null;
ServiceTemplate template = null;
try {
classes = new Class[] { AbstractConfiguration.class };
template = new ServiceTemplate(null,classes,null);
System.out.print("--> obtaining a proxy to service...");
proxy2Service = (AbstractConfiguration) proxy2Lus.lookup(template);
System.out.print("ok.\n");
classes = new Class[] { TransactionManager.class };
template = new ServiceTemplate(null,classes,null);
System.out.print("--> obtaining a proxy to txn manager...");
proxy2TxnMgr = (TransactionManager) proxy2Lus.lookup(template);
System.out.print("ok.\n");
TransactionManager.Created transaction = null;
System.out.print("--> creating a transaction...");
transaction = proxy2TxnMgr.create(Lease.FOREVER);
System.out.print("ok.\n");
long transactionID = transaction.id;
System.out.print("--> creating an exporter...");
Exporter exporter =
new BasicJeriExporter(TcpServerEndpoint.getInstance(0),
new BasicILFactory());
System.out.print("ok.\n");
TransactionParticipant myProxy = null;
System.out.print("--> exporting proxy for txn manager...");
myProxy = (TransactionParticipant) exporter.export(this);
System.out.print("ok.\n");
System.out.print("--> joining transaction...");
proxy2TxnMgr.join(transactionID,myProxy,0);
System.out.print("ok.\n");
System.out.print("--> invoking 'setConfiguration' method...");
Integer integer = new Integer(2);
proxy2Service.setConfiguration(integer);
System.out.print("ok.\n");
System.out.print("--> invoking 'setTxnParameters' method...");
proxy2Service.setTxnParameters(proxy2TxnMgr,transactionID);
System.out.print("ok.\n");
System.out.println("-->\nlater (after settled up all device)...\n");
System.out.print("--> commiting transaction...");
proxy2TxnMgr.commit(transactionID);
System.out.print("ok.\n");
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
System.out.println("end of 'discovered' method invocation.");
}
public void discarded(DiscoveryEvent evt) {
System.out.println("'discarded' method was invoked, but there is
nothing to do here.");
}
}
---
* service implementation's code:
---
package txn;
import common.AbstractConfiguration;
import java.rmi.*;
import net.jini.core.transaction.*;
import net.jini.core.transaction.server.*;
import net.jini.export.*;
import net.jini.jeri.*;
import net.jini.jeri.tcp.*;
public class TransAbstractConfigurationImpl
implements AbstractConfiguration, TransactionParticipant {
private TransactionManager proxy2TxnMgr;
private long transactionID;
private TransactionParticipant myProxy;
private Object aco;
public TransAbstractConfigurationImpl() throws RemoteException {
System.out.println("\tbeginning of service's constructor:");
System.setSecurityManager(new RMISecurityManager());
proxy2TxnMgr = null;
transactionID = -1;
System.out.print("\t--> creating an exporter...");
Exporter exporter =
new BasicJeriExporter(TcpServerEndpoint.getInstance(0),
new BasicILFactory());
System.out.print("ok.\n");
try {
System.out.print("\t--> exporting proxy for txn manager...");
myProxy = (TransactionParticipant) exporter.export(this);
System.out.print("ok.\n");
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
System.out.println("\tend of service's constructor.");
}
public void setConfiguration(Object aco) throws RemoteException {
System.out.println("beginning of 'setConfiguration' method
invocation:");
System.out.print("--> receiving abstract configuration object...");
this.aco = aco;
System.out.print("ok.\n");
System.out.println("end of 'setConfiguration' method invocation.");
}
public void setTxnParameters(TransactionManager proxy2TxnMgr,
long transactionID) throws RemoteException {
System.out.println("beginning 'setTxnParameters' method invocation:");
this.proxy2TxnMgr = proxy2TxnMgr;
this.transactionID = transactionID;
try {
System.out.print("--> joining transaction...");
proxy2TxnMgr.join(transactionID,myProxy,0);
System.out.print("ok.\n");
} catch (UnknownTransactionException e) {
e.printStackTrace();
System.exit(1);
} catch (CannotJoinException e) {
e.printStackTrace();
System.exit(1);
} catch (CrashCountException e) {
e.printStackTrace();
System.exit(1);
} catch (RemoteException e) {
e.printStackTrace();
System.exit(1);
}
System.out.println("ending 'setTxnParameters' method invocation.");
}
public int prepare(TransactionManager mgr, long id) {
System.out.println("preparing...");
return TransactionConstants.PREPARED;
}
public void commit(TransactionManager mgr, long id) {
System.out.println("commiting (after that, abstract
configuration object will be translated to real SNMP objects..:
.");
}
public void abort(TransactionManager mgr, long id) {
System.out.println("aborting...");
}
public int prepareAndCommit(TransactionManager mgr, long id) {
int result = prepare(mgr,id);
if (result == TransactionConstants.PREPARED) {
commit(mgr,id);
result = TransactionConstants.COMMITTED;
}
return result;
}
}
---
* server's code:
---
package txn;
import common.AbstractConfiguration;
import java.rmi.*;
import net.jini.core.lease.*;
import net.jini.core.lookup.*;
import net.jini.core.transaction.server.*;
import net.jini.discovery.*;
import net.jini.jeri.*;
import net.jini.jeri.tcp.*;
import net.jini.export.*;
import net.jini.lease.*;
import net.jini.lookup.*;
public class TransAbstractConfigurationServer
implements DiscoveryListener, LeaseListener {
private TransAbstractConfigurationImpl impl = null;
private AbstractConfiguration proxy4Client = null;
private TransactionParticipant proxy4TxnMgr = null;
private LookupDiscovery discover = null;
public static void main(String[] args) {
TransAbstractConfigurationServer d =
new TransAbstractConfigurationServer();
Object keepAlive = new Object();
synchronized(keepAlive) {
try {
keepAlive.wait();
} catch (InterruptedException e) {
e.printStackTrace();
System.exit(1);
}
}
}
public TransAbstractConfigurationServer() {
System.out.println("beginning of server's constructor:");
System.out.print("--> installing a security manager...");
System.setSecurityManager(new RMISecurityManager());
System.out.print("ok.\n");
try {
impl = new TransAbstractConfigurationImpl();
System.out.print("--> obtaining an exporter...");
Exporter exporter =
new BasicJeriExporter(TcpServerEndpoint.getInstance(0),
new BasicILFactory());
System.out.print("ok.\n");
System.out.print("--> exporting a proxy for client...");
proxy4Client = (AbstractConfiguration) exporter.export(impl);
System.out.print("ok.\n");
System.out.print("--> obtaining another exporter...");
Exporter anotherExporter =
new BasicJeriExporter(TcpServerEndpoint.getInstance(0),
new BasicILFactory());
System.out.print("ok.\n");
System.out.print("--> exporting a proxy for txn manager...");
proxy4TxnMgr =
(TransactionParticipant) anotherExporter.export(impl);
System.out.print("ok.\n");
System.out.print("--> creating a lookup discovery object...");
discover = new LookupDiscovery(LookupDiscovery.ALL_GROUPS);
System.out.print("ok.\n");
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
System.out.print("--> adding a discovery listener...");
discover.addDiscoveryListener(this);
System.out.print("ok.\n");
System.out.println("end of server's constructor.");
}
public void discovered(DiscoveryEvent evt) {
System.out.println("beggining of 'discovered' method invocation:");
ServiceRegistrar[] proxies2Lus = evt.getRegistrars();
ServiceRegistrar proxy2Lus = proxies2Lus[0];
ServiceItem item = null;
ServiceRegistration registry = null;
try {
System.out.print("--> preparing service proxy for registration...");
item = new ServiceItem(null,proxy4Client,null);
System.out.print("ok.\n");
System.out.print("--> registering service proxy...");
registry = proxy2Lus.register(item,Lease.FOREVER);
System.out.print("ok.\n");
System.out.print("--> creating a lease renewal manager (lrm)...");
LeaseRenewalManager lrm = new LeaseRenewalManager();
System.out.print("ok.\n");
System.out.print("--> setting up that lrm for service proxy...");
lrm.renewUntil(registry.getLease(),Lease.FOREVER,this);
System.out.print("ok.\n");
System.out.print("--> preparing proxy related to txn manager...");
item = new ServiceItem(null,proxy4TxnMgr,null);
System.out.print("ok.\n");
System.out.print("--> registering proxy related to txn manager...");
registry = proxy2Lus.register(item,Lease.FOREVER);
System.out.print("ok.\n");
System.out.print("--> setting up lrm for that proxy...");
lrm.renewUntil(registry.getLease(),Lease.FOREVER,this);
System.out.print("ok.\n");
} catch (RemoteException e) {
e.printStackTrace();
System.exit(1);
}
System.out.println("end of 'discovered' method invocation.");
}
public void discarded(DiscoveryEvent evt) {
System.out.println("there is something wrong...");
}
public void notify(LeaseRenewalEvent evt) {
System.out.println("Lease expired: " + evt.toString());
}
}
} catch (RemoteException e) {
e.printStackTrace();
System.exit(1);
}
System.out.println("end of 'discovered' method invocation.");
}
public void discarded(DiscoveryEvent evt) {
System.out.println("there is something wrong...");
}
public void notify(LeaseRenewalEvent evt) {
System.out.println("Lease expired: " + evt.toString());
}
}
----
* way of starting server:
----
java -Djava.security.policy=policy.all
-Djava.rmi.server.codebase=http://192.168.0.105:8086/
txn.TransAbstractConfigurationServer
----
* way of starting client:
----
java -Djava.security.policy=policy.all
-Djava.rmi.server.codebase=http://192.168.0.103:8087/
client.TransAbstractConfigurationClient
----
* /etc/hosts on xavante:
----
192.168.0.105 xavante # Added by NetworkManager
127.0.0.1 localhost.localdomain localhost
::1 xavante localhost6.localdomain6 localhost6
127.0.1.1 xavante
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
----
* /etc/hosts on jaguar:
----
192.168.0.103 jaguar # Added by NetworkManager
127.0.0.1 localhost.localdomain localhost
::1 jaguar localhost6.localdomain6 localhost6
127.0.1.1 jaguar
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
----
* policy file used by apps:
----
grant {
permission java.security.AllPermission "", "";
};
----
Well, that's all, folks! Kindest regards to all of you!!!
Wagner.
2011/4/21 Gregg Wonderly <[email protected]>:
> Most of the time this happens because you are using the default Linux config
> that has an /etc/host line such as
>
> 127.0.0.1 localhost localhost.localdomain mymachine
>
> Where "mymachine" is the name of your computer.
>
> This causes DNS lookups of the host name to return localhost address instead
> of the address associated with the Ethernet interface.
>
> But as Dan requests, full exception traces and all the specifics will help
> make this more clear.
>
> Gregg
>
> Sent from my iPhone
>
> On Apr 21, 2011, at 3:21 AM, Dan Creswell <[email protected]> wrote:
>
>> ....
>>
>> On 21 April 2011 06:10, helcio silva <[email protected]> wrote:
>>> Hello to everybody.
>>>
>>> I am developing a distributed systems using the transactional
>>> mechanisms provided by River. For simplicity, I've tested all its
>>> componentes in a same machine first, and they worked. However, I am
>>> not having a happy when I distributed them on different machines -
>>> obviously, that's the way they should work...
>>>
>>> When my client try to fetch a proxy for its service, I have the
>>> following message:
>>>
>>> --> obtaining a proxy to service...java.rmi.ConnectException:
>>> connection refused or timed out to
>>> BasicObjectEndpoint[0b410d49-68c0-48dc-8ca1-a823493965d8,TcpEndpoint[127.0.1.1:53632]];
>>> nested exception is:
>>> (and a lot of exceptions are thrown away...)
>>>
>>
>> We could do with seeing those exceptions please - or at least the
>> first few. In particular the exception above doesn't tell me which
>> piece of code is emitting this exception so I cannot make any
>> diagnosis.
>>
>>> My opinion is that the client is trying to connect to its own
>>> machine, because the trace shows the '127.0.1.1' address. Am I
>>> correct? No? So, what is the point? I've used the current IP addresses
>>> when I was making all configuration files - I've not used hostnames on
>>> making those files.
>>
>> Clearly you've missed something. Not uncommon given the typical Jini
>> config, nevertheless we need the exception traces above to help you.
>>
>>>
>>> Another weird message (to me, at least) is provided by reggie, when
>>> it is started up:
>>>
>>> INFO: started reggie: 845b79d8-e188-4f2c-8400-21ce26c89a46, [public],
>>> ConstrainablelLookupLocator[[jini://xavante/], [null]]
>>>
>>> Why the hostname is shown on that message? Why the current
>>> machine's IP address is not shown, instead of its hostname?
>>>
>>
>> I would strongly suspect that is because you haven't specified
>> something appropriate for this Reggie config item:
>>
>>
>> • unicastDiscoveryHost
>> Type: String
>> Default: InetAddress.getLocalHost().getHostName()
>> Description: Specifies the host name for unicast discovery, which
>> is advertised in multicast announcements and (protocol 2) unicast
>> discovery responses. This entry is obtained at service start and
>> restart.
>>
>>> May you provide any glue, fellows? Thanks in advance.
>>>
>>> Wagner.
>>>
>