Java Troubleshooting: Application running inside Glassfish, unable to call a webservice
Flash Forward: 3 days already trying to troubleshooting the java code for “PrivilegedActionException” Exception , it turns out it is one parameter in Glassfish that needs to be properly adjusted.
Lets go back from the beginning: 3 days ago I was writing a JEE enterprise applciation , simply a webpage that retrieves data from a DB2 database and then based on a user’s choice it call a webservice for some of the records in the result-set.
I followed GlassFish-Developer’s-guide to call an WS-RPC webservice. the server providing this WS-RPC is somewhere located inside our enterprise network.
Now one thing you need to consider: WS-RPC is outdated, but still some old applications use it, even on the internet!
Now back to our story: after developing the code to call an WS-RPC using the above guide, I get this strange behaviour:
1) When calling the WS through TCPMON – located in the localhost- which then re-routes the data to the ws-server inside our organization network, everything goes fine, and the expected result is retrieved.
2) When attempting to call the ws-server directly, I get this error message:
com.sun.xml.messaging.saaj.SOAPExceptionImpl: java.security.PrivilegedActionException: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Bad response: (503Service Unavailable ....
3) troubleshooting this further, showed that if I insert the wrong server-name, I get the same error. (hmmm. somehow the server is unreachable).
4) When building a parallel test application on the same server that calls the Internet-NOAA-RPC-Service , everything works fine.
from 1,2,3 : I thought thet maybe Glassfish needs some-kind of security settings to allow Glassfish to call the outside world.
But on the 3rd day of troubleshooting, I tried number 4, which proved that the problem is not about calling the outside world of Glassfish.
I googled “Glassfish proxy” and found I could change the settings by manipulating domain1.xml with the following lines:
<java-config ...
...
<jvm-options>-Dhttp.proxyHost=<<proxy_server_name>></jvm-options>
<jvm-options>-Dhttp.proxyPort=<<8080>></jvm-options>
<jvm-options>-Dhttp.nonProxyHosts=localhost|127.0.0.1|<<|*.mycorprotehost.net|*.xyz.net|*.zxy.net>></jvm-options>
...
</java-config>
If you misconfigure that list of servers/domains, the application (GlassFish) will reach proxy server to locate myEnterpriseServer.com (which is not the server you actually want- and does not exist on the internet).
Please comment, if you find this information useful .
By trim, January 12, 2012 @ 16:03
This is really good and I faced same issue in weblogic server.could you please give me the right solution for this
By asmaklad, January 13, 2012 @ 08:22
The right solution is by properly adjusting the Proxy settings inside GlassFish in domain1.xml :
…