Robin Wieruch
Robin Wieruch

Reputation: 15898

Restlet - Connection Problems - 406 Not Acceptable - Plain Text

couldnt find somewhere else advice.

I am writing a Restlet JSE Client for a Jersey(!) Restful Service. I already wrote a Jersey client for that and it is working, so the jersey service is alright. Now I get problems in writing a restlet client:

My Service root adress is:

 http://localhost:8080/com-project-core/rest, so I call:

 ClientResource = service = new ClientResource("http://localhost:8080/com-project-core/rest");

My Basic Auth Credentiels are admin and xxx, so I call:

 service.setChallengeResponse(ChallengeScheme.HTTP_BASIC, "admin", "xxx");

Now the problems:

 ClientResource service = new ClientResource("http://localhost:8080/com-project-core/rest/ping");

calls up my service. After that I try

 String myString = service.get(String.class);
 System.out.println(myString);

I get a:

 08.07.2012 17:41:48 org.restlet.engine.http.connector.HttpClientHelper start
 INFO: Starting the default HTTP client

in my output. Not more! The Junit Test says:

 Not Acceptable (406) - Not Acceptable 

So he can find the resource but cannot produce @Produces("text/plain") ??

So when I remove @Produces("text/plain") on server side it works!!

For the resourcey my server side looks like this:

    @Path("/ping")
    @RolesAllowed({"admin", "user"})
    public class ConnectedResourceBean implements ConnectedResourceIF {

        @GET
        @Produces("text/plain")
        public String getPingMessage() throws NamingException {             

        return "Hello World";
       }
 }

For my pom in set this dependencies:

<dependency>
    <groupId>org.restlet.jse</groupId>
    <artifactId>org.restlet</artifactId>
    <version>${restlet.version}</version>
</dependency>

<dependency>
    <groupId>org.restlet.jse</groupId>
    <artifactId>org.restlet.ext.xstream</artifactId>
    <version>${restlet.version}</version>
</dependency>

As I said, its working with my jersey client.

Upvotes: 0

Views: 799

Answers (1)

Robin Wieruch
Robin Wieruch

Reputation: 15898

No way: Restlet had problems with

 @Produces("text/plain")

on jersey server side. Can someone explain me that fact?

Edit:

Made it work with

 <properties>
     <restlet.version>2.1-M3</restlet.version>
 </properties>

Upvotes: 1

Related Questions