Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

java.rmi.ConnectException: Connection refused to host...

Status
Not open for further replies.

Themuppeteer

Programmer
Apr 4, 2001
449
0
0
BE
Hello Guys,

I have an application that connects to my JBOSS 3.2.2 application server.
It all runs fine local, but when I run it from another computer, my client can not connect.
My application is a Jar file.

I removed 2 files from the meta-inf directory SUN_MICR.RSA and SUN_MICR.SF. This had to be done because otherwise I got security exceptions.

I think my ISP blocks all ports under the 2000, so I think that might be the problem. I already tried to change ports in jboss-service.xml file. I changed the rmi port and listen port to something bigger, here is the sample...:

----------------------- jboss-service.xml -----------------
<mbean code="org.jboss.naming.NamingService"
name="jboss:service=Naming">
<!-- The listening port for the bootstrap JNP service. Set this to -1
to run the NamingService without the JNP invoker listening port.
-->
<attribute name="Port">9099</attribute>
<!-- The bootstrap JNP server bind address. This also sets the default
RMI service bind address. Empty == all addresses
-->
<attribute name="BindAddress">${jboss.bind.address}</attribute>
<!-- The port of the RMI naming service, 0 == anonymous -->
<attribute name="RmiPort">9098</attribute>
<!-- The RMI service bind address. Empty == all addresses
-->
<attribute name="RmiBindAddress">${jboss.bind.address}</attribute>
</mbean>

----------------------------------------------------------

and I connect in my client (and also in my application server, when beans are talking to each other)

-------------------- MyClient code: getInitialcontext ----
private Context getInitialContext(String ip,String port) throws NamingException
{
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:eek:rg.jnp.interfaces");
environment.put(Context.PROVIDER_URL,ip+":"+port);
return new InitialContext(environment);
}
---------------------------------------------------------

I used to place jnp:// before the ip, but I read on a site that I should not do that when working over the internet.. don't know if its true, but anyway my exception changd by removing it (from CommunicationException to ConnectionException).
it goes wrong when I try to create the home interface of one to one of my beans = when I use the ctx for the first time...


Here is the exception...

java.rmi.ConnectException: Connection refused to host: (my ip address); nested exception is:
java.net.ConnectException: Connection timed out: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185
)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:101)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Sour
ce)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvo
kerProxy.java:135)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.jav
a:96)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.
java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:4
5)
at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:173)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
at $Proxy0.create(Unknown Source)
at MoehahaClient.Login.jButtonConnect_actionPerformed(Login.java:168)
at MoehahaClient.Login_jButtonConnect_actionAdapter.actionPerformed(Logi
n.java:276)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
67)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1820)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:258)
at java.awt.Component.processMouseEvent(Component.java:5021)
at java.awt.Component.processEvent(Component.java:4818)
at java.awt.Container.processEvent(Container.java:1525)
at java.awt.Component.dispatchEventImpl(Component.java:3526)
at java.awt.Container.dispatchEventImpl(Container.java:1582)
at java.awt.Component.dispatchEvent(Component.java:3367)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3359
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3074)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3004)
at java.awt.Container.dispatchEventImpl(Container.java:1568)
at java.awt.Window.dispatchEventImpl(Window.java:1581)
at java.awt.Component.dispatchEvent(Component.java:3367)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:191)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:295)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:161)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148)
at java.net.Socket.connect(Socket.java:425)
at java.net.Socket.connect(Socket.java:375)
at java.net.Socket.<init>(Socket.java:290)
at java.net.Socket.<init>(Socket.java:118)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
SocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
SocketFactory.java:122)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:562)
... 36 more



Can anyone help me please ?
Any hints, thoughts are highly appreciated.



Greetz,
img


NOSPAM_themuppeteer@hotmail.com (for mails, remove the NOSPAM_)

&quot;Those who say they understand chess, understand nothing&quot;

-- Robert HUBNER
 
Could it perhaps be rmi policy file related ?

Greetz,
img


NOSPAM_themuppeteer@hotmail.com (for mails, remove the NOSPAM_)

&quot;Those who say they understand chess, understand nothing&quot;

-- Robert HUBNER
 
I'm not really sure, but I would guess it is not permissions errors because this line :

Caused by: java.net.ConnectException: Connection timed out: connect

does not indicate a permission exception. It is more like a network/hardware problem, like can't resolve the server name througn DNS, or the rmiregistry / listener is not running on the expected port (try typing "netstat" to see what ports are doing what).
 
thnx for your reply sedj!

Might it perhaps be the fact that I removed the jnp:// in my getInitialContext in
environment.put(Context.PROVIDER_URL,ip+":"+port);
?
When I had put
environment.put(Context.PROVIDER_URL,"jnp://"+ip+":"+port);

I used to get another exception. It was a communication exception then..

at home, I meanwhile also added user and password to my initialcontext 'environment' var, cause I thought it might have been that but no luck.

But because the first exception is a connection refused exception, a colleague of mine just told me that I might have to add a rmi.policy file to allow users to connect to my ports but he wasn't very experienced on that either.
(I can only experiment this evening when I'm home but I'd like to get as much information as possible before I get home..)

What do you think? And do you know perhaps where I should add such a rmi.policy file ? (in my application server? in the client? both? and if so, in wich directory?)

Best regards,
themuppeteer





Greetz,
img


NOSPAM_themuppeteer@hotmail.com (for mails, remove the NOSPAM_)

&quot;Those who say they understand chess, understand nothing&quot;

-- Robert HUBNER
 
Ok, I found why I got this error...it was something really stupid.
I forgot to do the remoteportableobject.narrow thing...
I still doesn't work, due to another error but I'm a step closer now...
thnx anyway!

Greetz,
img


NOSPAM_themuppeteer@hotmail.com (for mails, remove the NOSPAM_)

&quot;Those who say they understand chess, understand nothing&quot;

-- Robert HUBNER
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top