An unexpected status was returned: Communication Error (1001) - sun.security.validator.ValidatorExce

2010-11-01 Thread gato
Hi to every body, I'm trying to implement a client to get resources over https 
in my localhost.

My localhost web server is configured to ask authentication, and it server one 
resource in this path "https://localhost/resources/resource1.xml";.

Without restlet, and using httpcomponents-client-4.0.3 , the way to do it, in 
other words, work with untrusted certificates is by set up a dummy SSLFactory 
and a dummy TrustManager in my client application, that allows me to get 
resources from https resource in my localhost.

In restlet i have been doing some tests, and I'm able to get the resource from 
http protocol, my code is the next:

import java.io.IOException;

import org.restlet.Client;
import org.restlet.data.ChallengeResponse;
import org.restlet.data.ChallengeScheme;
import org.restlet.data.Method;
import org.restlet.data.Protocol;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.data.Status;

public class FirstResourceClientMain {

public static void main(String[] args) throws IOException {

 // Outputting the content of a Web page  
Request request = new Request(Method.GET, 
"http://localhost/resources/resource1.xml";);  

ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC;  
ChallengeResponse authentication = new ChallengeResponse(scheme,  
"dechalar", "dechalar"); 

request.setChallengeResponse(authentication);  

Client client = new Client(Protocol.HTTP);  
Response response = client.handle(request); 

if (response.getStatus().isSuccess()) {  
 // Output the response entity on the JVM console  
 response.getEntity().write(System.out);  
 } else if (response.getStatus()  
 .equals(Status.CLIENT_ERROR_UNAUTHORIZED)) {  
 // Unauthorized access  
 System.out  
 .println("Access authorized by the server, " +  
 "check your credentials");  
 } else {  
 // Unexpected status  
 System.out.println("An unexpected status was returned: "  
 + response.getStatus());  
 } 

  
}
}

and it works fine!. but when i change to 
"https://localhost/resources/resource1.xml";, note "https"
and 
Client client = new Client(Protocol.HTTPS); 
note "Protocol.HTTPS"

the next message is thrown:

An unexpected status was returned: Communication Error (1001) - 
sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to find 
valid certification path to requested target 

So i suppose that the problem is the trust manager, and that there must a way 
to work with untrusted certificates, but i can't found an example or 
doumentation about this issue.

So please, if anybody know the way to work it, i will appreciate your answers

thanks

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2677857

clientssl.java
Description: Binary data


Non-blocking remove/reset of Memoizer

2010-11-01 Thread Nader Aeinehchi
Hello everyone

In advance, please accept my appologies if this post is in the wrong forum!

I wonder how remove/reset operations can be added Memoizer pattern of Brian
Goetz and Tim Peierls?  The main question is how to add these operations using a
non-blocking algorithm for high contention?

Any help is highly appreciated.

Thanks.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2677792


RE: [GWT] "The method getAnonymousLogger() is undefined for the type Logger"

2010-11-01 Thread Thierry Boileau
Hello Olivier,

the port is available in the trunk (2.1 release) and the 2.0 branch. It will be 
part of 2.0.2 release (coming soon), and next 2.1M1.

Best regards,
Thierry Boileau

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2677805


GWT/Restlet/GXT

2010-11-01 Thread webpost
My team is evaluating technologies for out new GUI.
However, I am struggling at how to connect Restlets with GXT. I saw this 
posting by jlouvel and would love to know if the code or the tutorial/article 
existed. 

http://restlet.tigris.org/issues/show_bug.cgi?id=1094

Consider providing REST bridges for GXT models such as implementation of the 
DataProxy, the DataReader, etc.

http://www.extjs.com/deploy/gxtdocs/
 
Consider whether a GXT extension would be useful or simply some 
tutorial/article.

I am used to using things like JAXB or Castor to convert between XML and Java 
objects. I see nothing in GXT or Restlets that helps with creating XML. There 
is a bit of support for Reading, but not Writing. Am I missing something?

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2676844


Can't make two container talk with success

2010-11-01 Thread Daniele Dellafiore
Hi.

I lost all the morning trying to figure out a nice setup for my app..
still can't make it work, so I ask for some help.

I have two different war, one is a restlet server deployed as a
servlet, the other is the web frontent, made with wicket.
If I run both the wars in jetty embedded in maven with mvn jetty:run,
they starts on two different ports and can talk together succesfully.

But in my  final production setup with tomcat 6 running the server on
8080 and jetty 6 running the web client, on 9090, both answer and
works properly till I make a POST from the client to the server, and I
receive a "IllegalArgumentException: argument type mismatch" as shown
in trace below.

This beats me, cause in two jetty, same machine, different instances
and port it works. And the error is not saying enough.

Before leaving you to the exception I want to add this question: does
seems reasonable to you this kind of architecure? Basically I want to
build the client on the REST API I build for the server. So in the
frontent, with wicket, I inject a restlet client and not the services
that are only in the domain of the server.
This seems clear to me but maybe there is a draw back.

If I try to make both client and server run on the same jetty/tomcat
as separate war, they can't communicate, I receive a
Communication Error (1001) - Connection refused

I did not take further investigations cause the two-container setup is
fine for me, maybe you can tell more about that, seems like a security
issue here.

Thanks for help.
Here is the exception.

29-Oct-2010 11:45:21 org.restlet.resource.UniformResource doCatch
WARNING: Exception or error caught in resource
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:453)
at org.restlet.resource.ServerResource.post(ServerResource.java:1095)
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:506)
at 
org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:563)
at 
org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:299)
at org.restlet.resource.ServerResource.handle(ServerResource.java:821)
at org.restlet.resource.Finder.handle(Finder.java:513)
at org.restlet.routing.Filter.doHandle(Filter.java:156)
at org.restlet.routing.Filter.handle(Filter.java:203)
at org.restlet.routing.Router.doHandle(Router.java:495)
at org.restlet.routing.Router.handle(Router.java:735)
at org.restlet.routing.Filter.doHandle(Filter.java:156)
at org.restlet.routing.Filter.handle(Filter.java:203)
at org.restlet.routing.Filter.doHandle(Filter.java:156)
at org.restlet.routing.Filter.handle(Filter.java:203)
at org.restlet.routing.Filter.doHandle(Filter.java:156)
at 
org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:154)
at org.restlet.routing.Filter.handle(Filter.java:203)
at org.restlet.routing.Filter.doHandle(Filter.java:156)
at org.restlet.routing.Filter.handle(Filter.java:203)
at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
at 
org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:72)
at org.restlet.Application.handle(Application.java:386)
at org.restlet.routing.Filter.doHandle(Filter.java:156)
at org.restlet.routing.Filter.handle(Filter.java:203)
at org.restlet.routing.Router.doHandle(Router.java:495)
at org.restlet.routing.Router.handle(Router.java:735)
at org.restlet.routing.Filter.doHandle(Filter.java:156)
at org.restlet.routing.Filter.handle(Filter.java:203)
at org.restlet.routing.Router.doHandle(Router.java:495)
at org.restlet.routing.Router.handle(Router.java:735)
at org.restlet.routing.Filter.doHandle(Filter.java:156)
at org.restlet.routing.Filter.handle(Filter.java:203)
at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
at org.restlet.Component.handle(Component.java:387)
at org.restlet.Server.handle(Server.java:488)
at org.restlet.engine.ServerHelper.handle(ServerHelper.java:71)
at 
org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:150)
at 
org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1037)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicat

RE: Restlet client code does not work in Restlet Server (ServerResource) service.

2010-11-01 Thread webpost
Hi

I tried some more by using standard URLConnection inside the same block like...

-
URL yahoo = new URL("http://www.yahoo.com";);
URLConnection yc = yahoo.openConnection();

BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;

while ((inputLine = in.readLine()) != null)
logger.log(Level.INFO , "" + inputLine);
in.close(); 
--

And it work perfectly. Now, that sound like the problem somewhere in 
ClientResource class.

On the other note, I wrote some test program using cross origin technique from 
semantic though at http://kodemaniak.de/?p=62 

It work perfectly in 2.0rc4, but when I upgraded to 2.0.1, it just stop 
working. Look like 2.0.1 add some security restriction that won't allow cross 
origin by setting response option any more?

--Patrick

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2677130


Re: Can't make two container talk with success

2010-11-01 Thread Daniele Dellafiore
Mmmm, I solved this putting all deps in the server war, while before
some of them were in tomcat lib folder.

I can't say what was the exact problem but given the very strange
nature of the exception, I tried this move and worked.
Now I can't say what were the different classes loaded but seem safer
keeping everything in the war for now.


On Fri, Oct 29, 2010 at 7:25 PM, ilde...@gmail.com  wrote:
> I got one message with only quoted text, something wrong happened.
>
> Anyway further details, before the runtime on VPS was sun java 6 while
> I was building the wars with openjdk 6
> Now I compile both with java sun 6, but if different version.
>
> VPS
> java version "1.6.0_13"
> Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
> Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)
>
> BULDING MACHINE
> java version "1.6.0_22"
> Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
> Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)
>
> both installed on ubuntu via apt-get
>
> On Fri, Oct 29, 2010 at 6:30 PM, Jerome Louvel
>  wrote:
>> -Message d'origine-
>> De : Daniele Dellafiore [mailto:ilde...@gmail.com]
>> Envoyé : vendredi 29 octobre 2010 13:52
>> À : discuss@restlet.tigris.org
>> Objet : Can't make two container talk with success
>>
>> Hi.
>>
>> I lost all the morning trying to figure out a nice setup for my app..
>> still can't make it work, so I ask for some help.
>>
>> I have two different war, one is a restlet server deployed as a servlet, the
>> other is the web frontent, made with wicket.
>> If I run both the wars in jetty embedded in maven with mvn jetty:run, they
>> starts on two different ports and can talk together succesfully.
>>
>> But in my  final production setup with tomcat 6 running the server on
>> 8080 and jetty 6 running the web client, on 9090, both answer and works
>> properly till I make a POST from the client to the server, and I receive a
>> "IllegalArgumentException: argument type mismatch" as shown in trace below.
>>
>> This beats me, cause in two jetty, same machine, different instances and
>> port it works. And the error is not saying enough.
>>
>> Before leaving you to the exception I want to add this question: does seems
>> reasonable to you this kind of architecure? Basically I want to build the
>> client on the REST API I build for the server. So in the frontent, with
>> wicket, I inject a restlet client and not the services that are only in the
>> domain of the server.
>> This seems clear to me but maybe there is a draw back.
>>
>> If I try to make both client and server run on the same jetty/tomcat as
>> separate war, they can't communicate, I receive a Communication Error (1001)
>> - Connection refused
>>
>> I did not take further investigations cause the two-container setup is fine
>> for me, maybe you can tell more about that, seems like a security issue
>> here.
>>
>> Thanks for help.
>> Here is the exception.
>>
>> 29-Oct-2010 11:45:21 org.restlet.resource.UniformResource doCatch
>> WARNING: Exception or error caught in resource
>> java.lang.IllegalArgumentException: argument type mismatch
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
>> )
>>        at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
>> .java:25)
>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>        at
>> org.restlet.resource.ServerResource.doHandle(ServerResource.java:453)
>>        at
>> org.restlet.resource.ServerResource.post(ServerResource.java:1095)
>>        at
>> org.restlet.resource.ServerResource.doHandle(ServerResource.java:506)
>>        at
>> org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:5
>> 63)
>>        at
>> org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:
>> 299)
>>        at
>> org.restlet.resource.ServerResource.handle(ServerResource.java:821)
>>        at org.restlet.resource.Finder.handle(Finder.java:513)
>>        at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>        at org.restlet.routing.Filter.handle(Filter.java:203)
>>        at org.restlet.routing.Router.doHandle(Router.java:495)
>>        at org.restlet.routing.Router.handle(Router.java:735)
>>        at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>        at org.restlet.routing.Filter.handle(Filter.java:203)
>>        at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>        at org.restlet.routing.Filter.handle(Filter.java:203)
>>        at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>        at
>> org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:154)
>>        at org.restlet.routing.Filter.handle(Filter.java:203)
>>        at org.restlet.routing.Filter.doHandle(Filter.java:156)
>>        at org.restlet.routing.Filter.handle(Filter.java:203)
>>        at org.restlet.engine.ChainHelper.handle(ChainHelper.java:

RE: A few questions about restlet.

2010-11-01 Thread Thierry Boileau
Hello,

>1) http://localhost:888​8/code/isvalid/{code​Number} in this uri i would like 
>to check in my back if {codenumber} is a valid code

What do you mean by "valid"? Does it represent an existing code? or does it 
represent a correct value?

>2) http://localhost:888​8/code/create in this uri, the back will create a new 
>code
When I see action is the uris, I'm worrying. Do you want to create new code by 
sending GET requests?

Does a "code" resource (such as "/codes/{code}") could have a sense?

Best regards,
Thierry Boileau

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2677703


RE: Trying to use restlet client from inside restlet server code

2010-11-01 Thread Thierry Boileau
Hello Patrick,

when used inside a Component, a ClientResource will use the client connectors 
registered by the Component, exactly as hosted applications share the server 
connectors registered by the component [1] and [2]. 
Thus, you simply need to add the following line of code:
component.getClients().add(Protocol.HTTP);

By default, the internal client and server connectors are used, but you can use 
one of the others (see [2]).

Best regards,
Thierry Boileau

[1] http://wiki.restlet.org/docs_2.0/378-restlet.html
[2] http://wiki.restlet.org/docs_2.0/37-restlet.html

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2677701


RE: Re: how to get String with space inside

2010-11-01 Thread Thierry Boileau
Hello Nicho, Fabian,

you can also update the characteristic of the "routing variable" as follow:

TemplateRoute route = router.attach("/{cit​yParameters}", 
ResourcesSearchResource.class);
Variable v = new Variable();
v.setDecodingOnParse(true);
route.getTemplate().getVariables().put("cityPa​rameters", v);


best regards,
Thierry Boileau

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2677698