SOLUTION: Applet Accessing TCP located on another server but same machine

<[email protected]> Tue, 9 May 2006 02:03:45 -0400
Newsgroups gmane.comp.java.openjms.user
Message-ID <09E0CDFDDA417041A7761FD6C9906305035459@apatlittmail07.ittl.gtri.org>
This took me a loooonnngggggg time, to follow all the advice given on
this topic and implement the advice, but it works!

 

In openjms.xml, use the internalHost attribute in TcpConfiguration:

<TcpConfiguration port="3035" jndiPort="3035" adminPort="9090"
bindAll="true" internalHost="localhost" />

 

From the documentation,
http://openjms.sourceforge.net/config/reference.html#TcpConfiguration:

internalHost

This is only applicable when the OpenJMS server is behind a NAT
firewall. It becomes the internal address the server is known by and the
host address in ServerConfiguration
<http://openjms.sourceforge.net/config/reference.html#ServerConfiguratio
n#ServerConfiguration>  is the external address. Clients will attempt to
connect to host first. If that fails, they will try to connect to
internalHost. 

 

In applet code, use following settings:

Hashtable properties = new Hashtable();

properties.put(Context.INITIAL_CONTEXT_FACTORY,

                "org.exolab.jms.jndi.InitialContextFactory");

properties.put(Context.PROVIDER_URL, "tcp://localhost:3035/");

 

Ms. Akilah McIntyre, 404-407-6859

(Like Akeelah and the Bee <http://www.akeelahandthebee.com/> )

Research Scientist I, ITTL
Georgia Tech Research Institute

 

"Our biggest fear is not that we are inadequate. Our deepest fear is
that we are powerful beyond measure. It is our light, not our darkness,
that most frightens us. We ask ourselves, who am I to be brilliant, or
gorgeous or talented or fabulous? Actually, who are you not to be?"

-- by Marianne Williamson

________________________________

From: openjms-user-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
[mailto:openjms-user-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of Tim
Anderson
Sent: Thursday, May 04, 2006 7:28 PM
To: [email protected]
Subject: RE: [openjms-user] Applet Accessing RMI or TCP located on
another server

 

The URL you are using to connect to the server doesn't match that
indicated by the exception.

 

By default, the tcp connector listens on port 3035.

The rmi connector listens on port 1099.

 

To connect using tcp:

    properties.put(Context.PROVIDER_URL, "tcp://localhost:3035/");

 

To connect using rmi:

    properties.put(Context.PROVIDER_URL, "rmi://localhost:1099/");

 

The configuration in openjms.xml for tcp:

<TcpConfiguration port="3035"/>

The configuration in openjms.xml for rmi:

<RmiConfiguration registryPort="1099"/>

 

-Tim

 

	
________________________________


	From: openjms-user-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
[mailto:openjms-user-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of
[email protected]
	Sent: Thursday, 4 May 2006 1:35 AM
	To: [email protected]
	Subject: [openjms-user] Applet Accessing RMI or TCP located on
another server

	I know there have many discussions about trying to get around
the firewall so the client can connect to the server.  However, I'm
still confused.

	 

	I created an applet that accesses the openJMS server with these
followings properties:

	Hashtable properties = new Hashtable();

	properties.put(Context.INITIAL_CONTEXT_FACTORY,

	                "org.exolab.jms.jndi.InitialContextFactory");

	properties.put(Context.PROVIDER_URL, "tcp://localhost:3035/");

	....

	// create the JNDI initial context.

	context = new InitialContext(properties);

	 

	Now, the applet works if I open it from computer,
C:\java\jms\new_openJMS\web\anew\4newhtml.html.

	However, when I run this page from my webserver at,
http://localhost:8084/new_openJMS/anew/4newhtml.html, I get the
following error:

	 

	javax.naming.CommunicationException: Failed to get registry
service for URL: tcp://localhost:1035/ [Root exception is
java.rmi.ConnectIOException: Failed to create connection; nested
exception is: 

	org.exolab.jms.net.connector.ConnectException: Failed to connect
to localhost:1035]

	 

	I changed my URL to rmi://localhost:3035.  Again, the local copy
of the applet is able to connect to openJMS but the applet that is ran
from my web server doesn't work.

	 

	Here's my full stack trace:

	 

	basic: Registered modality listener

	liveconnect: Invoking JS method: document

	liveconnect: Invoking JS method: URL

	basic: Referencing classloader:
sun.plugin.ClassLoaderInfo@1321f5, refcount=1

	basic: Added progress listener:
sun.plugin.util.GrayBoxPainter@15c2843

	basic: Loading applet ...

	basic: Initializing applet ...

	basic: Starting applet ...

	network: Connecting
http://localhost:8084/new_openJMS/anew/jndi.properties with proxy=DIRECT

	network: Connecting
http://localhost:8084/new_openJMS/anew/commons-logging.properties with
proxy=DIRECT

	network: Connecting
http://localhost:8084/new_openJMS/anew/META-INF/services/org.apache.comm
ons.logging.LogFactory with proxy=DIRECT

	network: Connecting
http://localhost:8084/new_openJMS/anew/log4j.xml with proxy=DIRECT

	network: Connecting
http://localhost:8084/new_openJMS/anew/log4j.xml with proxy=DIRECT

	network: Connecting
http://localhost:8084/new_openJMS/anew/org/apache/log4j/PatternLayoutBea
nInfo.class with proxy=DIRECT

	network: Connecting
http://localhost:8084/new_openJMS/anew/org/apache/log4j/PatternLayoutBea
nInfo.class with proxy=DIRECT

	network: Connecting
http://localhost:8084/new_openJMS/anew/org/apache/log4j/LayoutBeanInfo.c
lass with proxy=DIRECT

	network: Connecting
http://localhost:8084/new_openJMS/anew/org/apache/log4j/LayoutBeanInfo.c
lass with proxy=DIRECT

	network: Connecting socket://localhost:1035 with proxy=DIRECT

	javax.naming.CommunicationException: Failed to get registry
service for URL: tcp://localhost:1035/ [Root exception is
java.rmi.ConnectIOException: Failed to create connection; nested
exception is: 

	      org.exolab.jms.net.connector.ConnectException: Failed to
connect to localhost:1035]

	      at
org.exolab.jms.jndi.InitialContextFactory.getInitialContext(InitialConte
xtFactory.java:146)

	      at
javax.naming.spi.NamingManager.getInitialContext(Unknown Source)

	      at javax.naming.InitialContext.getDefaultInitCtx(Unknown
Source)

	      at javax.naming.InitialContext.init(Unknown Source)

	      at javax.naming.InitialContext.<init>(Unknown Source)

	      at Example_AWT.Send_n_Browse(Example_AWT.java:108)

	      at Example_AWT.btnOK_actionPerformed(Example_AWT.java:84)

	      at Example_AWT$1.actionPerformed(Example_AWT.java:64)

	      at javax.swing.AbstractButton.fireActionPerformed(Unknown
Source)

	      at
javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)

	      at
javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

	      at javax.swing.DefaultButtonModel.setPressed(Unknown
Source)

	      at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)

	      at java.awt.Component.processMouseEvent(Unknown Source)

	      at javax.swing.JComponent.processMouseEvent(Unknown
Source)

	      at java.awt.Component.processEvent(Unknown Source)

	      at java.awt.Container.processEvent(Unknown Source)

	      at java.awt.Component.dispatchEventImpl(Unknown Source)

	      at java.awt.Container.dispatchEventImpl(Unknown Source)

	      at java.awt.Component.dispatchEvent(Unknown Source)

	      at
java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

	      at
java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

	      at java.awt.LightweightDispatcher.dispatchEvent(Unknown
Source)

	      at java.awt.Container.dispatchEventImpl(Unknown Source)

	      at java.awt.Component.dispatchEvent(Unknown Source)

	      at java.awt.EventQueue.dispatchEvent(Unknown Source)

	      at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

	      at
java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

	      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

	      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

	      at java.awt.EventDispatchThread.run(Unknown Source)

	Caused by: java.rmi.ConnectIOException: Failed to create
connection; nested exception is: 

	      org.exolab.jms.net.connector.ConnectException: Failed to
connect to localhost:1035

	      at
org.exolab.jms.net.orb.Locator.getProxy(Locator.java:137)

	      at
org.exolab.jms.net.orb.Locator.getRegistry(Locator.java:103)

	      at
org.exolab.jms.net.orb.DefaultORB.getRegistry(DefaultORB.java:267)

	      at
org.exolab.jms.client.net.SharedORB.getRegistry(SharedORB.java:121)

	      at
org.exolab.jms.jndi.InitialContextFactory.getInitialContext(InitialConte
xtFactory.java:144)

	      ... 30 more

	Caused by: org.exolab.jms.net.connector.ConnectException: Failed
to connect to localhost:1035

	      at
org.exolab.jms.net.socket.SocketManagedConnection.createSocketProtected(
SocketManagedConnection.java:266)

	      at
org.exolab.jms.net.socket.SocketManagedConnection.createSocket(SocketMan
agedConnection.java:182)

	      at
org.exolab.jms.net.socket.SocketManagedConnection.<init>(SocketManagedCo
nnection.java:114)

	      at
org.exolab.jms.net.tcp.TCPManagedConnection.<init>(TCPManagedConnection.
java:75)

	      at
org.exolab.jms.net.tcp.TCPManagedConnectionFactory.createManagedConnecti
on(TCPManagedConnectionFactory.java:98)

	      at
org.exolab.jms.net.connector.DefaultConnectionPool.createManagedConnecti
on(DefaultConnectionPool.java:221)

	      at
org.exolab.jms.net.connector.AbstractConnectionManager.allocateConnectio
n(AbstractConnectionManager.java:140)

	      at
org.exolab.jms.net.connector.AbstractConnectionFactory.getConnection(Abs
tractConnectionFactory.java:167)

	      at
org.exolab.jms.net.connector.AbstractConnectionManager.getConnection(Abs
tractConnectionManager.java:208)

	      at
org.exolab.jms.net.orb.Locator.getProxy(Locator.java:131)

	      ... 34 more

	network: Connecting socket://10.50.14.221:1099 with proxy=DIRECT

	 

	I know the solution may involve signing the applet, but I don't
know how to do that.  Thanks, any help is appreciated.

	 

	 

	Ms. Akilah McIntyre