Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connecting to URL on the web from ejb

 
sanpra sing
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the j2ee developers guide there is an example to get the contents(html) of a URL on the web.
This worked fine for me when the web server provided by the j2ee servers was accessed as local host. Later in the example the way to access a URL beyond a fire wall (i.e. proxy) is shown as follows.
1. Exit the Application Deployment Tool.
2. Stop the J2EE server.
3. In the bin/j2ee script, add the following options to the PROPS environment variable:

-Dhttp.proxyPort=<port> -Dhttp.proxyHost=<host>
The <port> is the proxy's port number and <host> is the name of your proxy host.
4. In the lib/security/Server.policy file, edit the following line:

permission java.net.SocketPermission "*:0-65535", "connect";
Modify the line so that it appears as follows::
permission java.net.SocketPermission "*", "connect";
5. Start the J2EE server.
6. Start the Application Deployment Tool.
Item 3 is a bit confusing to me and this is how I set it in j2ee.bat.
set PROPS=-Dhttp.proxyPort=8080 -Dhttp.proxyHost=10.2.240.54

Now when I run the client program having declared the URL to connect to as "http://www.google.com" the following exception is thrown.
==================================================
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.RemoteException: Unknown Exception/Error thrown by EJB method.;
nested exception is:
javax.ejb.EJBException: www.google.com
java.rmi.RemoteException: Unknown Exception/Error thrown by EJB method.; nested
exception is:
javax.ejb.EJBException: www.google.com
javax.ejb.EJBException: www.google.com
=================================================
Why is this happening? How can I get this to work?
(Mind you my proxy requires authentication. Could this be the problem)
Thanks.
 
sanpra sing
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
knock knock?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic