• Post Reply Bookmark Topic Watch Topic
  • New Topic

sun.net.www.http.httpclient

 
P Wang
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone know where I can find documentation or reference or sample code for how to use sun.net.www.http.httpclient? Seems most of the HttpClient information on the web refers to the Apache Commons HttpClient. Thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jakarta Commons HttpClient is much to be preferred over the Sun internal classes - they're well documented, feature-rich, source is available, API is not liable to change, etc. Why would you want to use the Sun classes?
 
P Wang
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

What we are trying to do is calling a java class from Coldfusion 5. Our server is Windows 2003. In Coldfusion, we'll need to specify the JVM so our java class can run. Unfortunately when JVM is started, the SUN httpclient library is loaded first. When we use Apache Commons HttpClient class, we got class cast exceptions.

We have limited control over the server set up and there is no Java web server installed on the machine. So we can not install it as a web application but as a standalone class. The library (commons-httpclient.jar) apparently is conflicting with the JVM runtime library (most likely rt.jar). We tested our own library and also tried other classes within commons-httpclient.jar, they all work fine. But when we use a class with the same name as those in the rt.jar, cast exception occurs.

We are stuck with Coldfusion 5 and Coldfusion MX 6 and later should have no problem. We tried some test code using SUN httpclient, it seems compatible with the JVM on our server. But I am having a hard time finding documentation on SUN httpclient.

What are my options. Any suggestions?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds odd, since both libraries use different packages. The fact that they share the same name names should be irrelevant.
 
P Wang
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very odd indeed. At first we thought there is another apache httpclient loaded first. But if we get rid of out apachie common Jar file we added, we got class not defined error. Adding the apache Jar file gives us class casting error. We tried different version of JDK (1.2, 1.3, 1.4, 1.5), same error.

It's not a standard web server set up. Coldfusion calls stand alone Java class in a file directory, and the library is loaded separately by the JVM via the class path. There is no direct link between the library and the class file.

In newer version of Coldfusion, the class and jar files can be put under WEB-INF/classes and WEB-INT/lib directory, the server will know where to look for the libray. But unfortunately we are stuck with Coldfusion 5.

Thanks for the reply.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you load the class using a different class loader with the codebase containing only the jakarta commons library.
 
P Wang
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will try on the development server. But I doubt I can do the same thing on production server which is controlled by another company.
 
P Wang
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
org.apache.commons.httpclient.HttpClient client1 = null;
client1 = new org.apache.commons.httpclient.HttpClient();

The second line will bomb out with the following error message:

Unhandled System exception ! java.lang.ClassCastException: java.lang.NoClassDefFoundError. Java exception occurred in call to method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!