Swing Client - EJB2 lookup over HTTP in JBoss 5.1 - jboss

I have a swing client which connects to my ejb2 application deployed in JBoss 5.1. There is a particular requirement from Customer to make it available on internet.
The deployment architecture is as follows,
swing_client --> extranet_ip |firewall | --> iis7_machine --> jboss5.1_machine.
jndi properties in client is as follows
Context.PROVIDER_URL=http://extranet_ip:9180/invoker/JNDIFactory
Context.INITIAL_CONTEXT_FACTORY=org.jboss.naming.HttpNamingContextFactory
This configuration works fine when the client is inside intranet. But it does not work in internet (extranet).
When I tried initially I got the error 'Connection refused'
After seeing some posts in various forums, I changed the file server\deploy\http-invoker.sar\META-INF\jboss-service.xml, to reflect the extranet_ip in invokerURL.
Aftet this I am getting the following error.
org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection for InvokerLocator [socket://10.200.1.193:4546/?dataType=invocation&enableTcpNoDelay=true&marshaller=org.jboss.invocation.unified.marshall.InvocationMarshaller&unmarshaller=org.jboss.invocation.unified.marshall.InvocationUnMarshaller]
Where 10.200.1.193 is the intranet IP address of JBoss Server machine.
I tried changing the trasport parameter in remoting-jboss-beans.xml to http, but at that time client is not working in both intranet and extranet.
Please anybody suggest a way forward for this issue. Or is there any other way to implement RMI over Http in JBoss?
Update: As a solution, I had to change my deployment architecture as follows.
swing_client --> extranet_ip |firewall | --> jboss5.1_machine
where the JBoss Application Server will be directly exposed through firewall. Then update clientConnectAddress in the remoting-jboss-beans.xml to the extranet IP. Also open the ports 8080 & 4446 in the firewall for this address.
This way the swing client is working if I use the jnid properties as follows.
Context.PROVIDER_URL : http://extranet_ip:8080/invoker/JNDIFactory
Context.INITIAL_CONTEXT_FACTORY : org.jboss.naming.HttpNamingContextFactory
But still looking for a solution where there is no need to open any non-standard ports and no need to expose the Application Server directly.

After a long struggle I found a solution for my issue. The solution was to change EJB container's invoker type to http in standardjboss.xml. When the invoker is http, it will use the settings in http-invoker.sar for remote binding.

Related

Play Framework as reverse proxy with ScalaWS

I am trying to document a server and replicate its setup done by another person. Server is running Play Framework which also acts as a reverse proxy to MediaWiki running on Apache on the same server on a port that is not open externally on the server.
The Play Framework routes requests to the Media Wiki Server using ScalaWS. When I check the request it creates a request by using the server domain with the Apache port and the media wiki file.
In the real server it is working fine but in the test deployment it fails to reach mediawiki. It works if in the test deployment I open the Apache port externally.
So Somehow the request to the local server running internally on the machine needs to be accessed without routing the request externally. How can this be done? If anyone can give some quick tips or things I can check or even explain how this may be working, that would really help save me some time.
The /etc/hosts file had the wrong domain defined. Fixing that fixed the problem.

Using web proxy with Java 8 JAX-RS RESTEasy clients

I can't seem to get JAX-RS clients to use a web proxy on Java 8. I'm using RESTEasy 3.0.10.Final, and running from inside Eclipse 4.4.2 on Windows 7 Professional 64-bit.
I set up a FreeProxy server on localhost running at 192.168.1.123:3128. I turn logs on and telnet to 192.168.1.123 3128 and issue a manual GET. The request shows up in the logs.
I then fire up my Java application, setting http.proxyHost=192.168.1.123 and http.proxyPort=3128 in the system properties. (I've even tried it using -D when starting the JVM.) (Note that I wouldn't expect the localhost problem to come into play, as I'm connecting to an actual IP address, not to localhost.)
I create a JAX-RS client using ClientBuilder.newBuilder().build() and perform a GET to a resource. Nothing shows up in the FreeProxy logs.
What do I have to do in order to get JAX-RS clients to use a proxy?
The ResteasyClientBuilder provides a method to define the defaultProxy:
ResteasyClient client = new ResteasyClientBuilder().defaultProxy("localhost", 8080, "http").build();
It seems to be possible to make RESTeasy use Java's proxy properties (e.g. -Dhttp.proxyHost) by using a different engine instead of HttpClient. java.net.HttpURLConnection supports proxy properties out of the box:
ResteasyClient client = new ResteasyClientBuilder().httpEngine(new URLConnectionEngine()).build();
For RESTEasy 4, here is what I've done for that:
ResteasyClient client = ((ResteasyClientBuilder) ClientBuilder.newBuilder())
.defaultProxy(proxyHost, proxyPort)
.build();
return client
.target(ENDPOINT_URL)
.proxy(EndpointResource.class);

gethostbyname not working for external server

I am writing an application with C++ to connect to my server.
I am using gethostbyname(). It is working fine when I give host name as 'localhost'. but if i try any other site like google.com, it fails.
Can anyone please tell me what could be going wrong.
I can access those websites through browser. Note: I have proxy set up in my browser.
Is thr proxy causing issue with gethostbyname()? if yes, how can I mention proxy in my C++ code?
Based on what you describe in your question, it appears that your machine is on a corporate network that is firewalled off the Internet, all access to the web is via a web proxy, and that your network does not have Internet DNS resolution.
Even if you managed to succeed in resolving an IP address, you will not be able to make an outbound connection, unless your firewall offers a Socks proxy, or an equivalent.
If your intent is to write a client that accesses web sites via HTTP, you will need to use your corporate HTTP proxy to do that. Contact your system administrator for more information.

How to debug Json between Local IIS Website and Local

I'm really struggling to know what the problem is here...
I have 2 websites configured in IIS...
**PH.Website** (STANDARD MVC PROJECT)
**PH.Api** (MVC WEB API PRIOJECT)
When you hit the PH.Website it uses a WebClient class in one of the controllers to download data from the PH.Api. However fiddler only sees traffic going to the PH.Website not the PH.Api.
After reading around on the internet I apparently have to do some configuration of the Syste.Net in the Web Api Project. So I added...
<system.net>
<defaultProxy>
<proxy
usesystemdefault="False"
bypassonlocal="True"
proxyaddress="http://PH.Api"
/>
</defaultProxy>
</system.net>
But still no luck. I know the request is happening I just cant see it.
Whats even more confusing is when I configure Fiddler to use Port 80 its says it cannot listen on that port. But hang on if it cant listen on 80 then how the hell can it see traffic on the Http port:80 anyway?
P.s. I really need to be able to run multiple sites locally so. I hate running sites under Localhost or 127.0.0.1 seems so silly when you can create seperate sites for everything in IIS and know exactly where everything maps....
Let's back up.
Fiddler's a proxy server; it sees all of the traffic that is sent to it. Generally speaking (unless you're using it as a Reverse Proxy) you never want to configure Fiddler to run on port 80; instead leave it up at port 8888 where it runs by default. You instead configure your client to proxy its traffic through Fiddler.
Now, what "reading around on the Internet" did you do that caused you to modify your machine.config or web.config file (you didn't mention which you edited)?
If your goal is to watch traffic with Fiddler, you need to point the ASP.NET proxy settings at Fiddler, not at whatever "PH.api" is (e.g. use "127.0.0.1:8888" and set bypassOnLocal to false). The further complexity arises in that System.NET bypasses the proxy for any request to "localhost" or "127.0.0.1", so if you're using those addresses for your target, you should change them to "localhost.fiddler" temporarily while debugging.

GWT dev mode not accepting requests forwarded through router

Our application uses the PayPal api, in order to test it PayPal needs to be able to post data to a serlvet on our servers. This is no problem in production however when running in GWT-Dev mode I cannot seem to get GWT to work through my home router. GWT is running on port 8888 and I have added the needed firewall rules to get this to work.
Does GWT somehow stop requests from working from outside the local area network? I tried -bindAddress 192.167.x.x but it did not work.
For security reasons the jetty server used in gwt dev mode only binds to localhost.
If you want to bind it to all intefaces use the parameter -bindAddress 0.0.0.0
To make sure the servlets are reachable try to connect from a different host on your network (e.g. with Telnet).