You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Mario Cartia <ma...@email.it> on 2008/01/28 14:57:33 UTC

RMI problem

Hi all,
i'm trying to connect to a remote repository via RMI.

I start the server using:
Repository repository = new TransientRepository();
ServerAdapterFactory factory = new ServerAdapterFactory();
RemoteRepository remote = factory.getRemoteRepository(repository);
Registry reg = LocateRegistry.createRegistry(1100);

and i'm able to log-in to the remote server using:
ClientRepositoryFactory factory = new ClientRepositoryFactory();
Repository repository = 
factory.getRepository("rmi://160.120.200.101:1100/jackrabbit");
Session s = repository.login();
System.out.println("Logged in: "+s.getUserID());

...but only if server and client runs on the same host.

Running the client from another host i obtain:
----------
Exception in thread "Main Thread" java.rmi.ConnectException: Connection 
refused to host: 127.0.1.1; nested exception is:
	java.net.ConnectException: Connection refused: connect
	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
	at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
	at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
	at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:110)
	at org.apache.jackrabbit.rmi.server.ServerRepository_Stub.login(Unknown 
Source)
	at it.compit.repositori.ComeCazzoVuoi.main(ComeCazzoVuoi.java:49)
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
	at java.net.Socket.connect(Socket.java:519)
	at java.net.Socket.connect(Socket.java:469)
	at java.net.Socket.<init>(Socket.java:366)
	at java.net.Socket.<init>(Socket.java:179)
	at 
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
	at 
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
	... 5 more

why?

--
Mario Cartia
 
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 In REGALO 'All the Good Thing' di NELLY FURTADO
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=6616&d=28-1

Re: RMI problem

Posted by Mario Cartia <ma...@email.it>.
Jukka Zitting ha scritto:
> Hi,
> 
> On Jan 28, 2008 3:57 PM, Mario Cartia <ma...@email.it> wrote:
>> Running the client from another host i obtain:
>> ----------
>> Exception in thread "Main Thread" java.rmi.ConnectException: Connection
>> refused to host: 127.0.1.1; nested exception is:
>> [...]
>> why?
> 
> By default the RMI server binds itself just to a single IP address,
> using a somewhat complex mechanism to decide which that address should
> be. Apparently on your system the RMI layer thinks that it should bind
> itself to the localhost address 127.0.0.1, which is only accessible to
> clients on the same host.
> 
> You can override the IP address the RMI server binds itself to by
> setting the java.rmi.server.hostname system property on the server
> JVM. In your case something like this:
> -Djava.rmi.server.hostmane=160.120.200.101.

Thank for your help. Now it works!

--
Mario Cartia
 
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 Hai bisogno di un prestito? Chiedi a Prometeo qual è l’offerta sul mercato più adatta a te, chiedere non costa nulla e basta un click!
* 
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7494&d=29-1

Re: RMI problem

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Mon, Oct 26, 2009 at 5:04 AM, EJP <es...@verismartsoftware.com> wrote:
> Jukka Zitting wrote:
>> By default the RMI server binds itself just to a single IP address,
>>
> That's not correct.
>
> By default it binds itself to 0.0.0.0, i.e. INADDR_ANY, just like any other
> listening socket does, unless you tell it otherwise by providing an
> RMIServerSocketFactory that uses an explicit bind-address.
>
> The issue here is not the bind address but the hostname embedded in the
> stub, which is controlled by java.rmi.server.hostname and which has to be
> set in the presence of misconfigured DNS or /etc/hosts files or sometimes in
> multi-homed hosts. As discussed in the Sun RMI FAQ item A.1.

You're right, thanks for the clarification!

BR,

Jukka Zitting

Re: RMI problem

Posted by EJP <es...@verismartsoftware.com>.


Jukka Zitting wrote:
> 
> By default the RMI server binds itself just to a single IP address,
> 
That's not correct.

By default it binds itself to 0.0.0.0, i.e. INADDR_ANY, just like any other
listening socket does, unless you tell it otherwise by providing an
RMIServerSocketFactory that uses an explicit bind-address.

The issue here is not the bind address but the hostname embedded in the
stub, which is controlled by java.rmi.server.hostname and which has to be
set in the presence of misconfigured DNS or /etc/hosts files or sometimes in
multi-homed hosts. As discussed in the Sun RMI FAQ item A.1.

NB java.rmi.server.hostname has no effect on the bind-address.

EJP

-- 
View this message in context: http://www.nabble.com/RMI-problem-tp15135858p26054418.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: RMI problem

Posted by "kazim_ssuet@yahoo.com" <ka...@yahoo.com>.
kazim_ssuet@yahoo.com wrote:
> 
> 
> EJP-2 wrote:
>> 
>> 
>> Jukka Zitting wrote:
>>> 
>>> By default the RMI server binds itself just to a single IP address,
>>> 
>> That's not correct.
>> 
>> By default it binds itself to 0.0.0.0, i.e. INADDR_ANY, just like any
>> other listening socket does, unless you tell it otherwise by providing an
>> RMIServerSocketFactory that uses an explicit bind-address.
>> 
>> The issue here is not the bind address but the hostname embedded in the
>> stub, which is controlled by java.rmi.server.hostname and which has to be
>> set in the presence of misconfigured DNS or /etc/hosts files or sometimes
>> in multi-homed hosts. As discussed in the Sun RMI FAQ item A.1.
>> 
>> NB java.rmi.server.hostname has no effect on the bind-address.
>> 
>> EJP
>> 
> 
> Thanks for the hints. I had slightly different issue but the hints helped.
> 
> I can login now (half the battle), but still need couple of explanations.
> 
> Host running JR (Jackrabbit) has two ip addresses, 172.16.1.xxx and
> 172.16.1.yyy
> In remote client machine it was defined as 172.16.1.xxx, while the hosts
> file on JR machine had  172.16.1.yyy for the hostname...I changed the
> entry on remote client and I can login.
> 
> Question 1: Is an IP address picked by a listening port? Shouldn't it
> accept connections on both IP addresses that host has?
> Jukka's post ("By default the RMI server binds itself just to a single IP
> address") probably answers that, but just to clearify, is that IP address
> picked from the hosts file?
> 
> 
> Question 2: Why is port that I define as "org.apache.jackrabbit.rmi.port"
> not being used?
> 
> I found this line in log (RMIConnectorC A   ADMC0026I: The RMI Connector
> is available at port 2812), while "org.apache.jackrabbit.rmi.port" is
> equal to 2800, which I set using following option in websphere console:
> (Application servers > server1 > Process Definition > Java Virtual Machine
> > Custom Properties)
> 
> Is setting the connection port feature not available in 1.6.4? If it is
> not, then how would I define a single port for RMI connections rather than
> using default anonymous port, in case there is a firewall on jackrabbit
> host?
> 
> Does seeing this message in log (RMIConnectorC A   ADMC0026I: The RMI
> Connector is available at port 2812) mean Jackrabbit is using a preset
> single port and not anonymous port for RMI logins? if it is, then where is
> this being set (if not thru org.apache.jackrabbit.rmi.port)?
> 
> Thanks,
> KS.
> 

Sorry, wanted to post on the original thread
(http://jackrabbit.510166.n4.nabble.com/Connection-Refused-on-Windows-2000-Server-OK-on-Windows-XP-td3421380.html).
I got reffered to this thread from the original one and posted here my
mistake.

Thanks,
KS.

--
View this message in context: http://jackrabbit.510166.n4.nabble.com/RMI-problem-tp523318p3429568.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: RMI problem

Posted by "kazim_ssuet@yahoo.com" <ka...@yahoo.com>.
EJP-2 wrote:
> 
> 
> Jukka Zitting wrote:
>> 
>> By default the RMI server binds itself just to a single IP address,
>> 
> That's not correct.
> 
> By default it binds itself to 0.0.0.0, i.e. INADDR_ANY, just like any
> other listening socket does, unless you tell it otherwise by providing an
> RMIServerSocketFactory that uses an explicit bind-address.
> 
> The issue here is not the bind address but the hostname embedded in the
> stub, which is controlled by java.rmi.server.hostname and which has to be
> set in the presence of misconfigured DNS or /etc/hosts files or sometimes
> in multi-homed hosts. As discussed in the Sun RMI FAQ item A.1.
> 
> NB java.rmi.server.hostname has no effect on the bind-address.
> 
> EJP
> 

Thanks for the hints. I had slightly different issue but the hints helped.

I can login now (half the battle), but still need couple of explanations.

Host running JR (Jackrabbit) has two ip addresses, 172.16.1.xxx and
172.16.1.yyy
In remote client machine it was defined as 172.16.1.xxx, while the hosts
file on JR machine had  172.16.1.yyy for the hostname...I changed the entry
on remote client and I can login.

Question 1: Is an IP address picked by a listening port? Shouldn't it accept
connections on both IP addresses that host has?
Jukka's post ("By default the RMI server binds itself just to a single IP
address") probably answers that, but just to clearify, is that IP address
picked from the hosts file?


Question 2: Why is port that I define as "org.apache.jackrabbit.rmi.port"
not being used?

I found this line in log (RMIConnectorC A   ADMC0026I: The RMI Connector is
available at port 2812), while "org.apache.jackrabbit.rmi.port" is equal to
2800, which I set using following option in websphere console:
(Application servers > server1 > Process Definition > Java Virtual Machine >
Custom Properties)

Is setting the connection port feature not available in 1.6.4? If it is not,
then how would I define a single port for RMI connections rather than using
default anonymous port, in case there is a firewall on jackrabbit host?

Does seeing this message in log (RMIConnectorC A   ADMC0026I: The RMI
Connector is available at port 2812) mean Jackrabbit is using a preset
single port and not anonymous port for RMI logins? if it is, then where is
this being set (if not thru org.apache.jackrabbit.rmi.port)?

Thanks,
KS.

--
View this message in context: http://jackrabbit.510166.n4.nabble.com/RMI-problem-tp523318p3429133.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: RMI problem

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Jan 28, 2008 3:57 PM, Mario Cartia <ma...@email.it> wrote:
> Running the client from another host i obtain:
> ----------
> Exception in thread "Main Thread" java.rmi.ConnectException: Connection
> refused to host: 127.0.1.1; nested exception is:
> [...]
> why?

By default the RMI server binds itself just to a single IP address,
using a somewhat complex mechanism to decide which that address should
be. Apparently on your system the RMI layer thinks that it should bind
itself to the localhost address 127.0.0.1, which is only accessible to
clients on the same host.

You can override the IP address the RMI server binds itself to by
setting the java.rmi.server.hostname system property on the server
JVM. In your case something like this:
-Djava.rmi.server.hostmane=160.120.200.101.

BR,

Jukka Zitting