Problem with Url redirection

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with Url redirection

Murilo Foltran
Hi,

I'm using restlet with Mule (www.mulesource.org).

We have a system with 3 layer. A web layer (using Joomla), ESB layer (using Mule+Restlet) and Services layer (using Apache + PHP).

Joomla makes a request through ESB layer to Services layer.

So... I need receive this request, send this to Services and return to Joomla. My mappings is alright and working.

So... We put a Basic Authorization on requests to Joomla access the Services layer through the ESB layer, and my problems started.

I create to classes. A class extends Application and another class extends Resource.

1. public class EsbApplication extends Application {

2.    private static Properties properties = null;

3.    private static Logger logger = Logger.getLogger(EsbApplication.class
            .getName());

4.    @Override
5.    public Restlet createRoot() {
6.        Router router = new Router(getContext());
7.        router.attachDefault(MainResource.class);
8.        return router;
9.    }
10.}

11.public class MainResource extends Resource {
   
12.    @SuppressWarnings("unchecked")
13.    public MainResource(Context context, Request request, Response response) {
14.        super(context, request, response);
15.        getVariants().add(new Variant(MediaType.TEXT_XML));
16.    }
   
17.    @Override
18.    public Representation getRepresentation(Variant variant) {
19.        String url = EsbApplication.getProperty("services.url") + getRequest().getResourceRef();
20.        // Prepare the request
21.        Request request = new Request(Method.GET, url);

22.        // Handle it using an HTTP client connector
23.        Client client = new Client(Protocol.HTTPS);
24.        Response response = client.handle(request);
       
25.        return response.getEntity();
26.    }
27.}

So I receive a request with basic authorization on Restlet application. But on the line 24 I debug the response object and on status has Unauthorized (401). But when I return (line 25) it send a 200 Ok to the Joomla.

I'm sure I'm doing mistakes. But I'm not know where. I didn't know if this is the better approach to this structure.

I read the tutorial and I think I need mix the 10 and 11 parts to do it.

So... Can someone help me? Or send me some links to clarify my doubts.

Thanks in advance.

Murilo
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Url redirection

Thierry Boileau
Hello Murilo,

I wonder if you can use the Redirector Restlet instead in "dispatcher"
mode =>
http://www.restlet.org/documentation/1.1/api/org/restlet/Redirector.html
You may need to override the "redirectDispatcher" method.

best regards,
Thierry Boileau


> Hi,
>
> I'm using restlet with Mule (www.mulesource.org
> <http://www.mulesource.org>).
>
> We have a system with 3 layer. A web layer (using Joomla), ESB layer
> (using Mule+Restlet) and Services layer (using Apache + PHP).
>
> Joomla makes a request through ESB layer to Services layer.
>
> So... I need receive this request, send this to Services and return to
> Joomla. My mappings is alright and working.
>
> So... We put a Basic Authorization on requests to Joomla access the
> Services layer through the ESB layer, and my problems started.
>
> I create to classes. A class extends Application and another class
> extends Resource.
>
> 1. public class EsbApplication extends Application {
>
> 2.    private static Properties properties = null;
>
> 3.    private static Logger logger = Logger.getLogger(EsbApplication.class
>             .getName());
>
> 4.    @Override
> 5.    public Restlet createRoot() {
> 6.        Router router = new Router(getContext());
> 7.        router.attachDefault(MainResource.class);
> 8.        return router;
> 9.    }
> 10.}
>
> 11.public class MainResource extends Resource {
>    
> 12.    @SuppressWarnings("unchecked")
> 13.    public MainResource(Context context, Request request, Response
> response) {
> 14.        super(context, request, response);
> 15.        getVariants().add(new Variant(MediaType.TEXT_XML));
> 16.    }
>    
> 17.    @Override
> 18.    public Representation getRepresentation(Variant variant) {
> 19.        String url = EsbApplication.getProperty("services.url") +
> getRequest().getResourceRef();
> 20.        // Prepare the request
> 21.        Request request = new Request(Method.GET, url);
>
> 22.        // Handle it using an HTTP client connector
> 23.        Client client = new Client(Protocol.HTTPS);
> 24.        Response response = client.handle(request);
>        
> 25.        return response.getEntity();
> 26.    }
> 27.}
>
> So I receive a request with basic authorization on Restlet
> application. But on the line 24 I debug the response object and on
> status has Unauthorized (401). But when I return (line 25) it send a
> 200 Ok to the Joomla.
>
> I'm sure I'm doing mistakes. But I'm not know where. I didn't know if
> this is the better approach to this structure.
>
> I read the tutorial and I think I need mix the 10 and 11 parts to do it.
>
> So... Can someone help me? Or send me some links to clarify my doubts.
>
> Thanks in advance.
>
> Murilo
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Url redirection

Murilo Foltran
Thanks a lot Thierry!

I'll start on this right now!

Cheers

Murilo

On Fri, Oct 31, 2008 at 10:18 AM, Thierry Boileau <[hidden email]> wrote:
Hello Murilo,

I wonder if you can use the Redirector Restlet instead in "dispatcher" mode => http://www.restlet.org/documentation/1.1/api/org/restlet/Redirector.html
You may need to override the "redirectDispatcher" method.

best regards,
Thierry Boileau


Hi,

I'm using restlet with Mule (www.mulesource.org <http://www.mulesource.org>).


We have a system with 3 layer. A web layer (using Joomla), ESB layer (using Mule+Restlet) and Services layer (using Apache + PHP).

Joomla makes a request through ESB layer to Services layer.

So... I need receive this request, send this to Services and return to Joomla. My mappings is alright and working.

So... We put a Basic Authorization on requests to Joomla access the Services layer through the ESB layer, and my problems started.

I create to classes. A class extends Application and another class extends Resource.

1. public class EsbApplication extends Application {

2.    private static Properties properties = null;

3.    private static Logger logger = Logger.getLogger(EsbApplication.class
           .getName());

4.    @Override
5.    public Restlet createRoot() {
6.        Router router = new Router(getContext());
7.        router.attachDefault(MainResource.class);
8.        return router;
9.    }
10.}

11.public class MainResource extends Resource {
  12.    @SuppressWarnings("unchecked")
13.    public MainResource(Context context, Request request, Response response) {
14.        super(context, request, response);
15.        getVariants().add(new Variant(MediaType.TEXT_XML));
16.    }
  17.    @Override
18.    public Representation getRepresentation(Variant variant) {
19.        String url = EsbApplication.getProperty("services.url") + getRequest().getResourceRef();
20.        // Prepare the request
21.        Request request = new Request(Method.GET, url);

22.        // Handle it using an HTTP client connector
23.        Client client = new Client(Protocol.HTTPS);
24.        Response response = client.handle(request);
      25.        return response.getEntity();
26.    }
27.}

So I receive a request with basic authorization on Restlet application. But on the line 24 I debug the response object and on status has Unauthorized (401). But when I return (line 25) it send a 200 Ok to the Joomla.

I'm sure I'm doing mistakes. But I'm not know where. I didn't know if this is the better approach to this structure.

I read the tutorial and I think I need mix the 10 and 11 parts to do it.

So... Can someone help me? Or send me some links to clarify my doubts.

Thanks in advance.

Murilo

Reply | Threaded
Open this post in threaded view
|

Re: Problem with Url redirection

Murilo Foltran
Hi,

I create a simple Redirector from the tutorial's Part10 and works.

But I'm not understand how I can make this.

I have a request like this: http://localhost:8182/services/users

And I want to redirect to this: https://services.dev/services/users.

I just want change the host and maintain the payload and the headers.

Is it possible? I read the javadoc of redirector but I didn't understand how I do this.

I tried to modify the part10 example without success.

Do someone have some idea?

Thanks in advance,

Murilo


On Fri, Oct 31, 2008 at 10:21 AM, Murilo Foltran <[hidden email]> wrote:
Thanks a lot Thierry!

I'll start on this right now!

Cheers

Murilo


On Fri, Oct 31, 2008 at 10:18 AM, Thierry Boileau <[hidden email]> wrote:
Hello Murilo,

I wonder if you can use the Redirector Restlet instead in "dispatcher" mode => http://www.restlet.org/documentation/1.1/api/org/restlet/Redirector.html
You may need to override the "redirectDispatcher" method.

best regards,
Thierry Boileau


Hi,

I'm using restlet with Mule (www.mulesource.org <http://www.mulesource.org>).


We have a system with 3 layer. A web layer (using Joomla), ESB layer (using Mule+Restlet) and Services layer (using Apache + PHP).

Joomla makes a request through ESB layer to Services layer.

So... I need receive this request, send this to Services and return to Joomla. My mappings is alright and working.

So... We put a Basic Authorization on requests to Joomla access the Services layer through the ESB layer, and my problems started.

I create to classes. A class extends Application and another class extends Resource.

1. public class EsbApplication extends Application {

2.    private static Properties properties = null;

3.    private static Logger logger = Logger.getLogger(EsbApplication.class
           .getName());

4.    @Override
5.    public Restlet createRoot() {
6.        Router router = new Router(getContext());
7.        router.attachDefault(MainResource.class);
8.        return router;
9.    }
10.}

11.public class MainResource extends Resource {
  12.    @SuppressWarnings("unchecked")
13.    public MainResource(Context context, Request request, Response response) {
14.        super(context, request, response);
15.        getVariants().add(new Variant(MediaType.TEXT_XML));
16.    }
  17.    @Override
18.    public Representation getRepresentation(Variant variant) {
19.        String url = EsbApplication.getProperty("services.url") + getRequest().getResourceRef();
20.        // Prepare the request
21.        Request request = new Request(Method.GET, url);

22.        // Handle it using an HTTP client connector
23.        Client client = new Client(Protocol.HTTPS);
24.        Response response = client.handle(request);
      25.        return response.getEntity();
26.    }
27.}

So I receive a request with basic authorization on Restlet application. But on the line 24 I debug the response object and on status has Unauthorized (401). But when I return (line 25) it send a 200 Ok to the Joomla.

I'm sure I'm doing mistakes. But I'm not know where. I didn't know if this is the better approach to this structure.

I read the tutorial and I think I need mix the 10 and 11 parts to do it.

So... Can someone help me? Or send me some links to clarify my doubts.

Thanks in advance.

Murilo


Reply | Threaded
Open this post in threaded view
|

Re: Problem with Url redirection

Thierry Boileau
Hello Murilo,

Here is a sample code where http://localhost:8182/blabla/blibli are redirected to 
https://services.dev/blabla/blibli :

***************************
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getClients().add(Protocol.HTTP);

component.getDefaultHost()
   .attachDefault(
     new Redirector(component.getContext(), "
https://services.dev/{rr}", Redirector.MODE_DISPATCHER)
    );
component.start();
***************************

This sample code is based on a predefined variable called "rr" which contains the "remaining part" of the request's resource reference relatively to the "root reference".
That is to say: in the sample code above, the redirector is directly attached to http://localhost:8182/, thus the remaining part is "/blabla/blibli".
If your redirectory is hosted inside an Application attached to "
http://localhost:8182/blabla", thus the remaining part is "/blibli".

I notice that the tutorial does not explain the usage of such variables...

NB:
for a complete list of supported predefined variables:
http://localhost:8182/documentation/1.1/api/org/restlet/util/Resolver.html#createResolver(org.restlet.data.Request,%20org.restlet.data.Response)


I hope it will help you.

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com

Hi,

I create a simple Redirector from the tutorial's Part10 and works.

But I'm not understand how I can make this.

I have a request like this: http://localhost:8182/services/users

And I want to redirect to this: https://services.dev/services/users.

I just want change the host and maintain the payload and the headers.

Is it possible? I read the javadoc of redirector but I didn't understand how I do this.

I tried to modify the part10 example without success.

Do someone have some idea?

Thanks in advance,

Murilo


On Fri, Oct 31, 2008 at 10:21 AM, Murilo Foltran <[hidden email]> wrote:
Thanks a lot Thierry!

I'll start on this right now!

Cheers

Murilo


On Fri, Oct 31, 2008 at 10:18 AM, Thierry Boileau <[hidden email]> wrote:
Hello Murilo,

I wonder if you can use the Redirector Restlet instead in "dispatcher" mode => http://www.restlet.org/documentation/1.1/api/org/restlet/Redirector.html
You may need to override the "redirectDispatcher" method.

best regards,
Thierry Boileau


Hi,

I'm using restlet with Mule (www.mulesource.org <http://www.mulesource.org>).


We have a system with 3 layer. A web layer (using Joomla), ESB layer (using Mule+Restlet) and Services layer (using Apache + PHP).

Joomla makes a request through ESB layer to Services layer.

So... I need receive this request, send this to Services and return to Joomla. My mappings is alright and working.

So... We put a Basic Authorization on requests to Joomla access the Services layer through the ESB layer, and my problems started.

I create to classes. A class extends Application and another class extends Resource.

1. public class EsbApplication extends Application {

2.    private static Properties properties = null;

3.    private static Logger logger = Logger.getLogger(EsbApplication.class
           .getName());

4.    @Override
5.    public Restlet createRoot() {
6.        Router router = new Router(getContext());
7.        router.attachDefault(MainResource.class);
8.        return router;
9.    }
10.}

11.public class MainResource extends Resource {
  12.    @SuppressWarnings("unchecked")
13.    public MainResource(Context context, Request request, Response response) {
14.        super(context, request, response);
15.        getVariants().add(new Variant(MediaType.TEXT_XML));
16.    }
  17.    @Override
18.    public Representation getRepresentation(Variant variant) {
19.        String url = EsbApplication.getProperty("services.url") + getRequest().getResourceRef();
20.        // Prepare the request
21.        Request request = new Request(Method.GET, url);

22.        // Handle it using an HTTP client connector
23.        Client client = new Client(Protocol.HTTPS);
24.        Response response = client.handle(request);
      25.        return response.getEntity();
26.    }
27.}

So I receive a request with basic authorization on Restlet application. But on the line 24 I debug the response object and on status has Unauthorized (401). But when I return (line 25) it send a 200 Ok to the Joomla.

I'm sure I'm doing mistakes. But I'm not know where. I didn't know if this is the better approach to this structure.

I read the tutorial and I think I need mix the 10 and 11 parts to do it.

So... Can someone help me? Or send me some links to clarify my doubts.

Thanks in advance.

Murilo
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Url redirection

Murilo Foltran
Thanks Again Thierry

I'll try this and post the result.

Cheers,

Murilo

On Mon, Nov 3, 2008 at 4:43 PM, Thierry Boileau <[hidden email]> wrote:
Hello Murilo,

Here is a sample code where http://localhost:8182/blabla/blibli are redirected to 
https://services.dev/blabla/blibli :

***************************
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getClients().add(Protocol.HTTP);

component.getDefaultHost()
   .attachDefault(
     new Redirector(component.getContext(), "
https://services.dev/{rr}", Redirector.MODE_DISPATCHER)
    );
component.start();
***************************

This sample code is based on a predefined variable called "rr" which contains the "remaining part" of the request's resource reference relatively to the "root reference".
That is to say: in the sample code above, the redirector is directly attached to http://localhost:8182/, thus the remaining part is "/blabla/blibli".
If your redirectory is hosted inside an Application attached to "
http://localhost:8182/blabla", thus the remaining part is "/blibli".

I notice that the tutorial does not explain the usage of such variables...

NB:
for a complete list of supported predefined variables:
http://localhost:8182/documentation/1.1/api/org/restlet/util/Resolver.html#createResolver(org.restlet.data.Request,%20org.restlet.data.Response)


I hope it will help you.

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com

Hi,

I create a simple Redirector from the tutorial's Part10 and works.

But I'm not understand how I can make this.

I have a request like this: http://localhost:8182/services/users

And I want to redirect to this: https://services.dev/services/users.

I just want change the host and maintain the payload and the headers.

Is it possible? I read the javadoc of redirector but I didn't understand how I do this.

I tried to modify the part10 example without success.

Do someone have some idea?

Thanks in advance,

Murilo


On Fri, Oct 31, 2008 at 10:21 AM, Murilo Foltran <[hidden email]> wrote:
Thanks a lot Thierry!

I'll start on this right now!

Cheers

Murilo


On Fri, Oct 31, 2008 at 10:18 AM, Thierry Boileau <[hidden email]> wrote:
Hello Murilo,

I wonder if you can use the Redirector Restlet instead in "dispatcher" mode => http://www.restlet.org/documentation/1.1/api/org/restlet/Redirector.html
You may need to override the "redirectDispatcher" method.

best regards,
Thierry Boileau


Hi,

I'm using restlet with Mule (www.mulesource.org <http://www.mulesource.org>).


We have a system with 3 layer. A web layer (using Joomla), ESB layer (using Mule+Restlet) and Services layer (using Apache + PHP).

Joomla makes a request through ESB layer to Services layer.

So... I need receive this request, send this to Services and return to Joomla. My mappings is alright and working.

So... We put a Basic Authorization on requests to Joomla access the Services layer through the ESB layer, and my problems started.

I create to classes. A class extends Application and another class extends Resource.

1. public class EsbApplication extends Application {

2.    private static Properties properties = null;

3.    private static Logger logger = Logger.getLogger(EsbApplication.class
           .getName());

4.    @Override
5.    public Restlet createRoot() {
6.        Router router = new Router(getContext());
7.        router.attachDefault(MainResource.class);
8.        return router;
9.    }
10.}

11.public class MainResource extends Resource {
  12.    @SuppressWarnings("unchecked")
13.    public MainResource(Context context, Request request, Response response) {
14.        super(context, request, response);
15.        getVariants().add(new Variant(MediaType.TEXT_XML));
16.    }
  17.    @Override
18.    public Representation getRepresentation(Variant variant) {
19.        String url = EsbApplication.getProperty("services.url") + getRequest().getResourceRef();
20.        // Prepare the request
21.        Request request = new Request(Method.GET, url);

22.        // Handle it using an HTTP client connector
23.        Client client = new Client(Protocol.HTTPS);
24.        Response response = client.handle(request);
      25.        return response.getEntity();
26.    }
27.}

So I receive a request with basic authorization on Restlet application. But on the line 24 I debug the response object and on status has Unauthorized (401). But when I return (line 25) it send a 200 Ok to the Joomla.

I'm sure I'm doing mistakes. But I'm not know where. I didn't know if this is the better approach to this structure.

I read the tutorial and I think I need mix the 10 and 11 parts to do it.

So... Can someone help me? Or send me some links to clarify my doubts.

Thanks in advance.

Murilo

Reply | Threaded
Open this post in threaded view
|

Re: Problem with Url redirection

Tim Peierls
In reply to this post by Thierry Boileau
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Url redirection

Thierry Boileau
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Url redirection

Murilo Foltran
No problems I understood the right address.

So.... I got the successful redirection.

I use this class.

public class Test {
    public static void main(String[] args) throws Exception {
        // Create a component
        Component component = new Component();
        component.getServers().add(Protocol.HTTP, 8182);
        component.getClients().add(Protocol.HTTP);

        component.getDefaultHost()
                .attachDefault(
                        new Redirector(component.getContext(),
                                "http://services.dev{rr}",
                                Redirector.MODE_DISPATCHER));
        component.start();
    }
}

I had to modify one thing, I have to use "http://services.dev{rr}" without the '/' before '{rr}' because it was redirecting with two '/',
like this: http://services.dev//services/users.

Now, I'm trying integrate this application with Mule, but I think I'll need change this code because mule expect classes extending org,restlet.Application.

I'll try modify the standalone class to extend Application and after this integrate with mule.

Thanks by the help,

Murilo


Reply | Threaded
Open this post in threaded view
|

Re: Problem with Url redirection

Murilo Foltran
Hi,

After I got the redirection class working I tried to modify to work on mule (www.mulesource.org)

On my my example I just create a class and that's it.

But mule needs a class which extends org.restlet.Application, and my problems started again.

This is my class:

public class EsbApplication extends Application {
    @Override
    public Restlet createRoot() {
            
        Router router = new Router(context);
        router.attach(new Redirector(context, "https://services.dev{rr}",
                Redirector.MODE_DISPATCHER));
       
        return router;
    }
}

When I do the request I received this exception.

0-Nov-2008 17:51:57 org.restlet.Redirector handle
INFO: Redirecting via client connector to: https://services.dev/services/users
10-Nov-2008 17:51:57 com.noelios.restlet.StatusFilter getStatus
SEVERE: Unhandled exception or error intercepted
java.lang.NullPointerException
    at org.restlet.Redirector.redirectDispatcher(Redirector.java:244)
    at org.restlet.Redirector.handle(Redirector.java:217)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Router.handle(Router.java:504)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
    at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
    at org.restlet.Application.handle(Application.java:341)
    at org.restlet.Uniform.handle(Uniform.java:108)
    at org.mule.transport.restlet.RestletComponent$RestletCallable.onCall(RestletComponent.java:44)

So.. I looked the Redirector's source on the line 244 and the line is...

->  getContext().getClientDispatcher().handle(request, response);

So... I tried to create a context with this lines before create the redirector, but without success.

Context context = new Context();
Context.setCurrent(context);

I think it was a mule's problem, but I need to solve this to continue my implementation.

Thanks in advance,

Murilo

java.lang.NullPointerException
    at org.restlet.Redirector.redirectDispatcher(Redirector.java:244)
    at org.restlet.Redirector.handle(Redirector.java:217)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Router.handle(Router.java:504)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
    at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
    at org.restlet.Application.handle(Application.java:341)
    at org.restlet.Uniform.handle(Uniform.java:108)
    at org.mule.transport.restlet.RestletComponent$RestletCallable.onCall(RestletComponent.java:44)
    at org.mule.model.resolvers.CallableEntryPointResolver.invoke(CallableEntryPointResolver.java:52)
    at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:50)
    at org.mule.component.DefaultLifecycleAdapter.invoke(DefaultLifecycleAdapter.java:197)
    at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:83)
    at org.mule.component.AbstractJavaComponent.doInvoke(AbstractJavaComponent.java:74)
    at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:125)
    at org.mule.component.AbstractComponent.invoke(AbstractComponent.java:153)
    at org.mule.service.AbstractService.invokeComponent(AbstractService.java:932)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:229)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:505)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:220)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:180)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:365)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:253)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:176)
    at org.mule.transport.vm.VMMessageReceiver.onCall(VMMessageReceiver.java:107)
    at org.mule.transport.vm.VMMessageDispatcher$2.doInTransaction(VMMessageDispatcher.java:125)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.transport.vm.VMMessageDispatcher.doSend(VMMessageDispatcher.java:128)
    at org.mule.transport.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:168)
    at org.mule.transport.AbstractConnector.send(AbstractConnector.java:1910)
    at org.mule.endpoint.DefaultOutboundEndpoint.send(DefaultOutboundEndpoint.java:77)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:327)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:213)
    at org.mule.routing.outbound.AbstractOutboundRouter$2.doInTransaction(AbstractOutboundRouter.java:149)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.routing.outbound.AbstractOutboundRouter.send(AbstractOutboundRouter.java:156)
    at org.mule.routing.outbound.FilteringOutboundRouter.route(FilteringOutboundRouter.java:68)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection$1.doInTransaction(DefaultOutboundRouterCollection.java:64)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:45)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection.route(DefaultOutboundRouterCollection.java:69)
    at org.mule.service.AbstractService.sendToOutboundRouter(AbstractService.java:902)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:230)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:505)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:220)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:180)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:365)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:253)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:194)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.doRequest(HttpMessageReceiver.java:272)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.processRequest(HttpMessageReceiver.java:230)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:190)
    at org.mule.work.WorkerContext.run(WorkerContext.java:310)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
    at java.lang.Thread.run(Thread.java:619)




On Tue, Nov 4, 2008 at 8:56 AM, Murilo Foltran <[hidden email]> wrote:
No problems I understood the right address.

So.... I got the successful redirection.

I use this class.

public class Test {
    public static void main(String[] args) throws Exception {
        // Create a component

        Component component = new Component();
        component.getServers().add(Protocol.HTTP, 8182);
        component.getClients().add(Protocol.HTTP);

        component.getDefaultHost()
                .attachDefault(
                        new Redirector(component.getContext(),
                                "http://services.dev{rr}",

                                Redirector.MODE_DISPATCHER));
        component.start();
    }
}

I had to modify one thing, I have to use "http://services.dev{rr}" without the '/' before '{rr}' because it was redirecting with two '/',
like this: http://services.dev//services/users.

Now, I'm trying integrate this application with Mule, but I think I'll need change this code because mule expect classes extending org,restlet.Application.

I'll try modify the standalone class to extend Application and after this integrate with mule.

Thanks by the help,

Murilo

Reply | Threaded
Open this post in threaded view
|

Re: Problem with Url redirection

Thierry Boileau
Hello Murilo,

could you tell us what is the variable called "context"? A call to "getContext()" should be sufficient since it represents the context of the application.
Could you tell us how the EsbApplication is used? In a Component?

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com

Hi,

After I got the redirection class working I tried to modify to work on mule (www.mulesource.org)

On my my example I just create a class and that's it.

But mule needs a class which extends org.restlet.Application, and my problems started again.

This is my class:

public class EsbApplication extends Application {
    @Override
    public Restlet createRoot() {
            
        Router router = new Router(context);
        router.attach(new Redirector(context, "https://services.dev{rr}",
                Redirector.MODE_DISPATCHER));
       
        return router;
    }
}

When I do the request I received this exception.

0-Nov-2008 17:51:57 org.restlet.Redirector handle
INFO: Redirecting via client connector to: https://services.dev/services/users
10-Nov-2008 17:51:57 com.noelios.restlet.StatusFilter getStatus
SEVERE: Unhandled exception or error intercepted
java.lang.NullPointerException
    at org.restlet.Redirector.redirectDispatcher(Redirector.java:244)
    at org.restlet.Redirector.handle(Redirector.java:217)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Router.handle(Router.java:504)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
    at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
    at org.restlet.Application.handle(Application.java:341)
    at org.restlet.Uniform.handle(Uniform.java:108)
    at org.mule.transport.restlet.RestletComponent$RestletCallable.onCall(RestletComponent.java:44)

So.. I looked the Redirector's source on the line 244 and the line is...

->  getContext().getClientDispatcher().handle(request, response);

So... I tried to create a context with this lines before create the redirector, but without success.

Context context = new Context();
Context.setCurrent(context);

I think it was a mule's problem, but I need to solve this to continue my implementation.

Thanks in advance,

Murilo

java.lang.NullPointerException
    at org.restlet.Redirector.redirectDispatcher(Redirector.java:244)
    at org.restlet.Redirector.handle(Redirector.java:217)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Router.handle(Router.java:504)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
    at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
    at org.restlet.Application.handle(Application.java:341)
    at org.restlet.Uniform.handle(Uniform.java:108)
    at org.mule.transport.restlet.RestletComponent$RestletCallable.onCall(RestletComponent.java:44)
    at org.mule.model.resolvers.CallableEntryPointResolver.invoke(CallableEntryPointResolver.java:52)
    at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:50)
    at org.mule.component.DefaultLifecycleAdapter.invoke(DefaultLifecycleAdapter.java:197)
    at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:83)
    at org.mule.component.AbstractJavaComponent.doInvoke(AbstractJavaComponent.java:74)
    at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:125)
    at org.mule.component.AbstractComponent.invoke(AbstractComponent.java:153)
    at org.mule.service.AbstractService.invokeComponent(AbstractService.java:932)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:229)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:505)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:220)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:180)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:365)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:253)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:176)
    at org.mule.transport.vm.VMMessageReceiver.onCall(VMMessageReceiver.java:107)
    at org.mule.transport.vm.VMMessageDispatcher$2.doInTransaction(VMMessageDispatcher.java:125)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.transport.vm.VMMessageDispatcher.doSend(VMMessageDispatcher.java:128)
    at org.mule.transport.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:168)
    at org.mule.transport.AbstractConnector.send(AbstractConnector.java:1910)
    at org.mule.endpoint.DefaultOutboundEndpoint.send(DefaultOutboundEndpoint.java:77)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:327)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:213)
    at org.mule.routing.outbound.AbstractOutboundRouter$2.doInTransaction(AbstractOutboundRouter.java:149)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.routing.outbound.AbstractOutboundRouter.send(AbstractOutboundRouter.java:156)
    at org.mule.routing.outbound.FilteringOutboundRouter.route(FilteringOutboundRouter.java:68)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection$1.doInTransaction(DefaultOutboundRouterCollection.java:64)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:45)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection.route(DefaultOutboundRouterCollection.java:69)
    at org.mule.service.AbstractService.sendToOutboundRouter(AbstractService.java:902)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:230)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:505)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:220)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:180)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:365)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:253)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:194)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.doRequest(HttpMessageReceiver.java:272)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.processRequest(HttpMessageReceiver.java:230)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:190)
    at org.mule.work.WorkerContext.run(WorkerContext.java:310)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
    at java.lang.Thread.run(Thread.java:619)




On Tue, Nov 4, 2008 at 8:56 AM, Murilo Foltran <[hidden email]> wrote:
No problems I understood the right address.

So.... I got the successful redirection.

I use this class.

public class Test {
    public static void main(String[] args) throws Exception {
        // Create a component

        Component component = new Component();
        component.getServers().add(Protocol.HTTP, 8182);
        component.getClients().add(Protocol.HTTP);

        component.getDefaultHost()
                .attachDefault(
                        new Redirector(component.getContext(),
                                "http://services.dev{rr}",

                                Redirector.MODE_DISPATCHER));
        component.start();
    }
}

I had to modify one thing, I have to use "http://services.dev{rr}" without the '/' before '{rr}' because it was redirecting with two '/',
like this: http://services.dev//services/users.

Now, I'm trying integrate this application with Mule, but I think I'll need change this code because mule expect classes extending org,restlet.Application.

I'll try modify the standalone class to extend Application and after this integrate with mule.

Thanks by the help,

Murilo
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Url redirection

Murilo Foltran
Hello,

Sorry, I sent that email without read it before. I was working on that class and I forgot to undo my changes.

The right code is this:

public class EsbApplication extends Application {
    @Override
    public Restlet createRoot() {
        Router router = new Router(this.getContext());
        router.attach(new Redirector(this.getContext(), "https://services.dev{rr}",
                Redirector.MODE_DISPATCHER));
       
        return router;
    }
}

And I got the same exception that I sent before.

The EsbApplication is used inside of mule. You can see the user's guide of this component here:

 http://mule.mulesource.org/display/RESTLET/User%27s+Guide

It was very simple. You just need create a class which extends org.restlet.Application and implement the createRoot method.

We can't use that application with redirection working because it don't extends Application.

When it call the getContext it returns null. Because this I tried to create a new context variable.

Thanks in advance,

Murilo

On Tue, Nov 11, 2008 at 5:43 AM, Thierry Boileau <[hidden email]> wrote:
Hello Murilo,

could you tell us what is the variable called "context"? A call to "getContext()" should be sufficient since it represents the context of the application.
Could you tell us how the EsbApplication is used? In a Component?

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com

Hi,


After I got the redirection class working I tried to modify to work on mule (www.mulesource.org)

On my my example I just create a class and that's it.

But mule needs a class which extends org.restlet.Application, and my problems started again.

This is my class:

public class EsbApplication extends Application {
    @Override
    public Restlet createRoot() {
            
        Router router = new Router(context);
        router.attach(new Redirector(context, "https://services.dev{rr}",
                Redirector.MODE_DISPATCHER));
       
        return router;
    }
}

When I do the request I received this exception.

0-Nov-2008 17:51:57 org.restlet.Redirector handle
INFO: Redirecting via client connector to: https://services.dev/services/users
10-Nov-2008 17:51:57 com.noelios.restlet.StatusFilter getStatus
SEVERE: Unhandled exception or error intercepted
java.lang.NullPointerException
    at org.restlet.Redirector.redirectDispatcher(Redirector.java:244)
    at org.restlet.Redirector.handle(Redirector.java:217)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Router.handle(Router.java:504)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
    at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
    at org.restlet.Application.handle(Application.java:341)
    at org.restlet.Uniform.handle(Uniform.java:108)
    at org.mule.transport.restlet.RestletComponent$RestletCallable.onCall(RestletComponent.java:44)

So.. I looked the Redirector's source on the line 244 and the line is...

->  getContext().getClientDispatcher().handle(request, response);

So... I tried to create a context with this lines before create the redirector, but without success.

Context context = new Context();
Context.setCurrent(context);

I think it was a mule's problem, but I need to solve this to continue my implementation.

Thanks in advance,

Murilo

java.lang.NullPointerException
    at org.restlet.Redirector.redirectDispatcher(Redirector.java:244)
    at org.restlet.Redirector.handle(Redirector.java:217)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Router.handle(Router.java:504)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
    at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
    at org.restlet.Application.handle(Application.java:341)
    at org.restlet.Uniform.handle(Uniform.java:108)
    at org.mule.transport.restlet.RestletComponent$RestletCallable.onCall(RestletComponent.java:44)
    at org.mule.model.resolvers.CallableEntryPointResolver.invoke(CallableEntryPointResolver.java:52)
    at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:50)
    at org.mule.component.DefaultLifecycleAdapter.invoke(DefaultLifecycleAdapter.java:197)
    at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:83)
    at org.mule.component.AbstractJavaComponent.doInvoke(AbstractJavaComponent.java:74)
    at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:125)
    at org.mule.component.AbstractComponent.invoke(AbstractComponent.java:153)
    at org.mule.service.AbstractService.invokeComponent(AbstractService.java:932)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:229)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:505)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:220)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:180)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:365)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:253)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:176)
    at org.mule.transport.vm.VMMessageReceiver.onCall(VMMessageReceiver.java:107)
    at org.mule.transport.vm.VMMessageDispatcher$2.doInTransaction(VMMessageDispatcher.java:125)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.transport.vm.VMMessageDispatcher.doSend(VMMessageDispatcher.java:128)
    at org.mule.transport.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:168)
    at org.mule.transport.AbstractConnector.send(AbstractConnector.java:1910)
    at org.mule.endpoint.DefaultOutboundEndpoint.send(DefaultOutboundEndpoint.java:77)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:327)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:213)
    at org.mule.routing.outbound.AbstractOutboundRouter$2.doInTransaction(AbstractOutboundRouter.java:149)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.routing.outbound.AbstractOutboundRouter.send(AbstractOutboundRouter.java:156)
    at org.mule.routing.outbound.FilteringOutboundRouter.route(FilteringOutboundRouter.java:68)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection$1.doInTransaction(DefaultOutboundRouterCollection.java:64)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:45)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection.route(DefaultOutboundRouterCollection.java:69)
    at org.mule.service.AbstractService.sendToOutboundRouter(AbstractService.java:902)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:230)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:505)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:220)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:180)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:365)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:253)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:194)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.doRequest(HttpMessageReceiver.java:272)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.processRequest(HttpMessageReceiver.java:230)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:190)
    at org.mule.work.WorkerContext.run(WorkerContext.java:310)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
    at java.lang.Thread.run(Thread.java:619)




On Tue, Nov 4, 2008 at 8:56 AM, Murilo Foltran <[hidden email]> wrote:
No problems I understood the right address.

So.... I got the successful redirection.

I use this class.

public class Test {
    public static void main(String[] args) throws Exception {
        // Create a component

        Component component = new Component();
        component.getServers().add(Protocol.HTTP, 8182);
        component.getClients().add(Protocol.HTTP);

        component.getDefaultHost()
                .attachDefault(
                        new Redirector(component.getContext(),
                                "http://services.dev{rr}",

                                Redirector.MODE_DISPATCHER));
        component.start();
    }
}

I had to modify one thing, I have to use "http://services.dev{rr}" without the '/' before '{rr}' because it was redirecting with two '/',
like this: http://services.dev//services/users.

Now, I'm trying integrate this application with Mule, but I think I'll need change this code because mule expect classes extending org,restlet.Application.

I'll try modify the standalone class to extend Application and after this integrate with mule.

Thanks by the help,

Murilo



Reply | Threaded
Open this post in threaded view
|

RE: Problem with Url redirection

jlouvel
Administrator
Hi Murilo,
 
Mule is using Restlet 1.0 which requires you to provide a constructor with a parameter in order to pass the parent content to your application. In Restlet 1.1, this isn't required anymore.
 
public class EsbApplication extends Application {
 
    public EsbApplication(Context parentContext){
        super(parentContext);
    }

    @Override
    public Restlet createRoot() {
        Router router = new Router(this.getContext());
        router.attach(new Redirector(this.getContext(), "
https://services.dev{rr}",
                Redirector.MODE_DISPATCHER));
       
        return router;
    }
}
 
Note that in order to be able to dispatch client calls, the Redirector will attemp to use the context's dispatcher and ultimately a registered client connector. Mule provides its own client connector, adapting to Mule's connectors probably. Therefore, you will probably need to add something like that before running your EsbApplication:
 
    import com.noelios.restlet.Engine;
    import org.mule.transport.restlet.client.MuleClientHelper;

    Engine engine = new Engine(false);
    engine.getRegisteredClients().add(new MuleClientHelper());
    Engine.setInstance(engine);
 
Let us know if it works better, otherwise we'll look more closely. I've just installed Mule and their RESTpack to get a better understanding of how their integration works.
 
Best regards,
Jérôme Louvel
--
Restlet ~ Founder and Lead developer ~
http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


De : Murilo Foltran [mailto:[hidden email]]
Envoyé : mardi 11 novembre 2008 13:03
À : [hidden email]
Objet : Re: Problem with Url redirection

Hello,

Sorry, I sent that email without read it before. I was working on that class and I forgot to undo my changes.

The right code is this:

public class EsbApplication extends Application {
    @Override
    public Restlet createRoot() {
        Router router = new Router(this.getContext());
        router.attach(new Redirector(this.getContext(), "https://services.dev{rr}",
                Redirector.MODE_DISPATCHER));
       
        return router;
    }
}

And I got the same exception that I sent before.

The EsbApplication is used inside of mule. You can see the user's guide of this component here:

 http://mule.mulesource.org/display/RESTLET/User%27s+Guide

It was very simple. You just need create a class which extends org.restlet.Application and implement the createRoot method.

We can't use that application with redirection working because it don't extends Application.

When it call the getContext it returns null. Because this I tried to create a new context variable.

Thanks in advance,

Murilo

On Tue, Nov 11, 2008 at 5:43 AM, Thierry Boileau <[hidden email]> wrote:
Hello Murilo,

could you tell us what is the variable called "context"? A call to "getContext()" should be sufficient since it represents the context of the application.
Could you tell us how the EsbApplication is used? In a Component?

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com

Hi,


After I got the redirection class working I tried to modify to work on mule (www.mulesource.org)

On my my example I just create a class and that's it.

But mule needs a class which extends org.restlet.Application, and my problems started again.

This is my class:

public class EsbApplication extends Application {
    @Override
    public Restlet createRoot() {
            
        Router router = new Router(context);
        router.attach(new Redirector(context, "https://services.dev{rr}",
                Redirector.MODE_DISPATCHER));
       
        return router;
    }
}

When I do the request I received this exception.

0-Nov-2008 17:51:57 org.restlet.Redirector handle
INFO: Redirecting via client connector to: https://services.dev/services/users
10-Nov-2008 17:51:57 com.noelios.restlet.StatusFilter getStatus
SEVERE: Unhandled exception or error intercepted
java.lang.NullPointerException
    at org.restlet.Redirector.redirectDispatcher(Redirector.java:244)
    at org.restlet.Redirector.handle(Redirector.java:217)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Router.handle(Router.java:504)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
    at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
    at org.restlet.Application.handle(Application.java:341)
    at org.restlet.Uniform.handle(Uniform.java:108)
    at org.mule.transport.restlet.RestletComponent$RestletCallable.onCall(RestletComponent.java:44)

So.. I looked the Redirector's source on the line 244 and the line is...

->  getContext().getClientDispatcher().handle(request, response);

So... I tried to create a context with this lines before create the redirector, but without success.

Context context = new Context();
Context.setCurrent(context);

I think it was a mule's problem, but I need to solve this to continue my implementation.

Thanks in advance,

Murilo

java.lang.NullPointerException
    at org.restlet.Redirector.redirectDispatcher(Redirector.java:244)
    at org.restlet.Redirector.handle(Redirector.java:217)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Router.handle(Router.java:504)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
    at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
    at org.restlet.Application.handle(Application.java:341)
    at org.restlet.Uniform.handle(Uniform.java:108)
    at org.mule.transport.restlet.RestletComponent$RestletCallable.onCall(RestletComponent.java:44)
    at org.mule.model.resolvers.CallableEntryPointResolver.invoke(CallableEntryPointResolver.java:52)
    at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:50)
    at org.mule.component.DefaultLifecycleAdapter.invoke(DefaultLifecycleAdapter.java:197)
    at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:83)
    at org.mule.component.AbstractJavaComponent.doInvoke(AbstractJavaComponent.java:74)
    at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:125)
    at org.mule.component.AbstractComponent.invoke(AbstractComponent.java:153)
    at org.mule.service.AbstractService.invokeComponent(AbstractService.java:932)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:229)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:505)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:220)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:180)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:365)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:253)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:176)
    at org.mule.transport.vm.VMMessageReceiver.onCall(VMMessageReceiver.java:107)
    at org.mule.transport.vm.VMMessageDispatcher$2.doInTransaction(VMMessageDispatcher.java:125)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.transport.vm.VMMessageDispatcher.doSend(VMMessageDispatcher.java:128)
    at org.mule.transport.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:168)
    at org.mule.transport.AbstractConnector.send(AbstractConnector.java:1910)
    at org.mule.endpoint.DefaultOutboundEndpoint.send(DefaultOutboundEndpoint.java:77)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:327)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:213)
    at org.mule.routing.outbound.AbstractOutboundRouter$2.doInTransaction(AbstractOutboundRouter.java:149)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.routing.outbound.AbstractOutboundRouter.send(AbstractOutboundRouter.java:156)
    at org.mule.routing.outbound.FilteringOutboundRouter.route(FilteringOutboundRouter.java:68)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection$1.doInTransaction(DefaultOutboundRouterCollection.java:64)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:45)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection.route(DefaultOutboundRouterCollection.java:69)
    at org.mule.service.AbstractService.sendToOutboundRouter(AbstractService.java:902)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:230)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:505)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:220)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:180)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:365)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:253)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:194)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.doRequest(HttpMessageReceiver.java:272)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.processRequest(HttpMessageReceiver.java:230)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:190)
    at org.mule.work.WorkerContext.run(WorkerContext.java:310)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
    at java.lang.Thread.run(Thread.java:619)




On Tue, Nov 4, 2008 at 8:56 AM, Murilo Foltran <[hidden email]> wrote:
No problems I understood the right address.

So.... I got the successful redirection.

I use this class.

public class Test {
    public static void main(String[] args) throws Exception {
        // Create a component

        Component component = new Component();
        component.getServers().add(Protocol.HTTP, 8182);
        component.getClients().add(Protocol.HTTP);

        component.getDefaultHost()
                .attachDefault(
                        new Redirector(component.getContext(),
                                "http://services.dev{rr}",

                                Redirector.MODE_DISPATCHER));
        component.start();
    }
}

I had to modify one thing, I have to use "http://services.dev{rr}" without the '/' before '{rr}' because it was redirecting with two '/',
like this: http://services.dev//services/users.

Now, I'm trying integrate this application with Mule, but I think I'll need change this code because mule expect classes extending org,restlet.Application.

I'll try modify the standalone class to extend Application and after this integrate with mule.

Thanks by the help,

Murilo



Reply | Threaded
Open this post in threaded view
|

Re: Problem with Url redirection

Murilo Foltran
Hi Jérôme,

I sent an email to mule's users list asking when the update to 1.1.1 is avaiable. But nobody answer... So I tried to update by myself.

But I'll try it with 1.0 and I'll send an email with the results.

Thanks

Murilo


On Tue, Nov 11, 2008 at 11:14 AM, Jerome Louvel <[hidden email]> wrote:
Hi Murilo,
 
Mule is using Restlet 1.0 which requires you to provide a constructor with a parameter in order to pass the parent content to your application. In Restlet 1.1, this isn't required anymore.
 
public class EsbApplication extends Application {
 
    public EsbApplication(Context parentContext){
        super(parentContext);
    }

    @Override
    public Restlet createRoot() {
        Router router = new Router(this.getContext());
        router.attach(new Redirector(this.getContext(), "
https://services.dev{rr}",
                Redirector.MODE_DISPATCHER));
       
        return router;
    }
}
 
Note that in order to be able to dispatch client calls, the Redirector will attemp to use the context's dispatcher and ultimately a registered client connector. Mule provides its own client connector, adapting to Mule's connectors probably. Therefore, you will probably need to add something like that before running your EsbApplication:
 
    import com.noelios.restlet.Engine;
    import org.mule.transport.restlet.client.MuleClientHelper;

    Engine engine = new Engine(false);
    engine.getRegisteredClients().add(new MuleClientHelper());
    Engine.setInstance(engine);
 
Let us know if it works better, otherwise we'll look more closely. I've just installed Mule and their RESTpack to get a better understanding of how their integration works.
 
Best regards,
Jérôme Louvel
--
Restlet ~ Founder and Lead developer ~
http://www.restlet.org

Noelios Technologies ~ Co-founder ~ http://www.noelios.com


De : Murilo Foltran [mailto:[hidden email]]
Envoyé : mardi 11 novembre 2008 13:03
À : [hidden email]
Objet : Re: Problem with Url redirection

Hello,

Sorry, I sent that email without read it before. I was working on that class and I forgot to undo my changes.

The right code is this:

public class EsbApplication extends Application {
    @Override
    public Restlet createRoot() {
        Router router = new Router(this.getContext());
        router.attach(new Redirector(this.getContext(), "https://services.dev{rr}",
                Redirector.MODE_DISPATCHER));
       
        return router;
    }
}

And I got the same exception that I sent before.

The EsbApplication is used inside of mule. You can see the user's guide of this component here:

 http://mule.mulesource.org/display/RESTLET/User%27s+Guide

It was very simple. You just need create a class which extends org.restlet.Application and implement the createRoot method.

We can't use that application with redirection working because it don't extends Application.

When it call the getContext it returns null. Because this I tried to create a new context variable.

Thanks in advance,

Murilo

On Tue, Nov 11, 2008 at 5:43 AM, Thierry Boileau <[hidden email]> wrote:
Hello Murilo,

could you tell us what is the variable called "context"? A call to "getContext()" should be sufficient since it represents the context of the application.
Could you tell us how the EsbApplication is used? In a Component?

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com

Hi,


After I got the redirection class working I tried to modify to work on mule (www.mulesource.org)

On my my example I just create a class and that's it.

But mule needs a class which extends org.restlet.Application, and my problems started again.

This is my class:

public class EsbApplication extends Application {
    @Override
    public Restlet createRoot() {
            
        Router router = new Router(context);
        router.attach(new Redirector(context, "https://services.dev{rr}",
                Redirector.MODE_DISPATCHER));
       
        return router;
    }
}

When I do the request I received this exception.

0-Nov-2008 17:51:57 org.restlet.Redirector handle
INFO: Redirecting via client connector to: https://services.dev/services/users
10-Nov-2008 17:51:57 com.noelios.restlet.StatusFilter getStatus
SEVERE: Unhandled exception or error intercepted
java.lang.NullPointerException
    at org.restlet.Redirector.redirectDispatcher(Redirector.java:244)
    at org.restlet.Redirector.handle(Redirector.java:217)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Router.handle(Router.java:504)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
    at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
    at org.restlet.Application.handle(Application.java:341)
    at org.restlet.Uniform.handle(Uniform.java:108)
    at org.mule.transport.restlet.RestletComponent$RestletCallable.onCall(RestletComponent.java:44)

So.. I looked the Redirector's source on the line 244 and the line is...

->  getContext().getClientDispatcher().handle(request, response);

So... I tried to create a context with this lines before create the redirector, but without success.

Context context = new Context();
Context.setCurrent(context);

I think it was a mule's problem, but I need to solve this to continue my implementation.

Thanks in advance,

Murilo

java.lang.NullPointerException
    at org.restlet.Redirector.redirectDispatcher(Redirector.java:244)
    at org.restlet.Redirector.handle(Redirector.java:217)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Router.handle(Router.java:504)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
    at org.restlet.Filter.handle(Filter.java:195)
    at org.restlet.Filter.doHandle(Filter.java:150)
    at org.restlet.Filter.handle(Filter.java:195)
    at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
    at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
    at org.restlet.Application.handle(Application.java:341)
    at org.restlet.Uniform.handle(Uniform.java:108)
    at org.mule.transport.restlet.RestletComponent$RestletCallable.onCall(RestletComponent.java:44)
    at org.mule.model.resolvers.CallableEntryPointResolver.invoke(CallableEntryPointResolver.java:52)
    at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:50)
    at org.mule.component.DefaultLifecycleAdapter.invoke(DefaultLifecycleAdapter.java:197)
    at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:83)
    at org.mule.component.AbstractJavaComponent.doInvoke(AbstractJavaComponent.java:74)
    at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:125)
    at org.mule.component.AbstractComponent.invoke(AbstractComponent.java:153)
    at org.mule.service.AbstractService.invokeComponent(AbstractService.java:932)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:229)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:505)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:220)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:180)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:365)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:253)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:176)
    at org.mule.transport.vm.VMMessageReceiver.onCall(VMMessageReceiver.java:107)
    at org.mule.transport.vm.VMMessageDispatcher$2.doInTransaction(VMMessageDispatcher.java:125)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.transport.vm.VMMessageDispatcher.doSend(VMMessageDispatcher.java:128)
    at org.mule.transport.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:168)
    at org.mule.transport.AbstractConnector.send(AbstractConnector.java:1910)
    at org.mule.endpoint.DefaultOutboundEndpoint.send(DefaultOutboundEndpoint.java:77)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:327)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:213)
    at org.mule.routing.outbound.AbstractOutboundRouter$2.doInTransaction(AbstractOutboundRouter.java:149)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:99)
    at org.mule.routing.outbound.AbstractOutboundRouter.send(AbstractOutboundRouter.java:156)
    at org.mule.routing.outbound.FilteringOutboundRouter.route(FilteringOutboundRouter.java:68)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection$1.doInTransaction(DefaultOutboundRouterCollection.java:64)
    at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:45)
    at org.mule.routing.outbound.DefaultOutboundRouterCollection.route(DefaultOutboundRouterCollection.java:69)
    at org.mule.service.AbstractService.sendToOutboundRouter(AbstractService.java:902)
    at org.mule.model.seda.SedaService.doSend(SedaService.java:230)
    at org.mule.service.AbstractService.sendEvent(AbstractService.java:505)
    at org.mule.DefaultMuleSession.sendEvent(DefaultMuleSession.java:354)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.send(DefaultInboundRouterCollection.java:220)
    at org.mule.routing.inbound.DefaultInboundRouterCollection.route(DefaultInboundRouterCollection.java:180)
    at org.mule.transport.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:365)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:253)
    at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:194)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.doRequest(HttpMessageReceiver.java:272)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.processRequest(HttpMessageReceiver.java:230)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:190)
    at org.mule.work.WorkerContext.run(WorkerContext.java:310)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
    at java.lang.Thread.run(Thread.java:619)




On Tue, Nov 4, 2008 at 8:56 AM, Murilo Foltran <[hidden email]> wrote:
No problems I understood the right address.

So.... I got the successful redirection.

I use this class.

public class Test {
    public static void main(String[] args) throws Exception {
        // Create a component

        Component component = new Component();
        component.getServers().add(Protocol.HTTP, 8182);
        component.getClients().add(Protocol.HTTP);

        component.getDefaultHost()
                .attachDefault(
                        new Redirector(component.getContext(),
                                "http://services.dev{rr}",

                                Redirector.MODE_DISPATCHER));
        component.start();
    }
}

I had to modify one thing, I have to use "http://services.dev{rr}" without the '/' before '{rr}' because it was redirecting with two '/',
like this: http://services.dev//services/users.

Now, I'm trying integrate this application with Mule, but I think I'll need change this code because mule expect classes extending org,restlet.Application.

I'll try modify the standalone class to extend Application and after this integrate with mule.

Thanks by the help,

Murilo