Announcement Announcement Module
Collapse
No announcement yet.
RestTemplate and org.apache.http.auth.Credentials runtime issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • RestTemplate and org.apache.http.auth.Credentials runtime issue

    I've added code to implement a RestTemplate Client to my Spring MVC project (Eclipse, Maven, Spring 3.1.0.RELEASE). Everything builds and when I launch to Tomcat7, I get the output below. Is it possibly a Spring artifact I'm missing in the pom.xml? I've got spring-webmvc (excluding commons-logging), spring-oxm, spring-secutiy-web, spring-security-config, spring-tx, spring-aop, spring-orm, spring-test.

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean
    .
    .
    nested exception is java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials

    Caused by: java.lang.ClassNotFoundException: org.apache.http.auth.Credentials
    at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1676)
    at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1521)
    ... 39 more

    When I create RestTemplate I simply set up the http client with Basic Auth credentials.
    final DefaultHttpClient httpclient = new DefaultHttpClient();
    httpclient.getCredentialsProvider().setCredentials (
    new AuthScope(targetHost.getHostName(), targetHost.getPort(),
    AuthScope.ANY_REALM),
    new UsernamePasswordCredentials(this.username, this.password));

  • #2
    Problem solved, I had the scope set to test in my pom.xml for the httpclient and httpcore dependcies.

    Comment

    Working...
    X