Nightly compiler can't see Java constructors for (apache) DefaultHttpClient

View: New views
4 Messages — Rating Filter:   Alert me  

Nightly compiler can't see Java constructors for (apache) DefaultHttpClient

by Tim Azzopardi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm using Eclipse 3.5.1 Java edition with the nightly Scala plugin.

I have also tried this with the latest command line scala-2.8.0.r19100-b20091015023313 scalac

This is new code, so I don't know if it has ever worked in Scala.
I'm trying to use the latest stable binary version (4.0) of the Apache HTTP client

import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;

object HttpClientTest {
  def main(args : Array[String]) : Unit = {  
    var client1 = new DefaultHttpClient;
    var client2 = new DefaultHttpClient();
    var client3 = new DefaultHttpClient(null);
    var client4 = new DefaultHttpClient(null,null);
  }
}

On each of the four lines var client..., I have an error "org.apache.http.impl.client.DefaultHttpClient does not have a constructor"

The java version compiles fine
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;

public class HttpClientTestJava {
        public static void main(String[] args) {
                HttpClient httpclient1 = new DefaultHttpClient();
                HttpClient httpclient2 = new DefaultHttpClient(null);
                HttpClient httpclient3 = new DefaultHttpClient(null,null);
        }
}

Is this related to http://lampsvn.epfl.ch/trac/scala/ticket/735 ?




Re: Nightly compiler can't see Java constructors for (apache) DefaultHttpClient

by Tim Azzopardi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Get the same problem in scala 2.7.6!

Looks like it might be related to the ThreadSafe annotation on the super class AbstractHttpClient not being found.


Re: Nightly compiler can't see Java constructors for (apache) DefaultHttpClient

by Tim Azzopardi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Tim Azzopardi wrote:
error "org.apache.http.impl.client.DefaultHttpClient does not have a constructor"
Adding the jcip-annotations.jar from http://www.jcip.net/ fixed the problem. For some reason the Apache HttpClient download including dependencies does not include this jar.

The error message in the eclipse plugin is not friendly but running the compiler on the command line shows the underlying error:
E.g. under scalac 2.7.3:
error while loading DefaultHttpClient, class file 'httpclient-4.0.jar(org/apache/http/impl/client/DefaultHttpClient.class)' is broken
(class net.jcip.annotations.ThreadSafe not found.)

Re: [scala-tools] Re: Nightly compiler can't see Java constructors for (apache) DefaultHttpClient

by Ismael Juma :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 2009-10-15 at 15:12 -0700, Tim Azzopardi wrote:
> For some reason the Apache HttpClient download including dependencies does
> not include this jar.

I think they fixed this in a more recent release by removing the
annotations from the source code. As I understand, they hadn't realised
that the annotations were retained at runtime.

Best,
Ismael