1

I'm training about the combo Restlet/Spring but there are some things i still don't understand... I hope you can help me. In fact, i'm trying to the use Inject dependancies systeme of Spring with Restlet (Like in this tutorial : http://restlet.com/technical-resources/restlet-framework/guide/2.3/introduction/getting-started/maven-spring). So I tried to do it myself but that didn't work. My code returns this exception :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'basecampComponent' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'basecampAppliction' while setting bean property 'defaultTarget'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'basecampAppliction' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'root' of bean class[com.mycompany.restlet.basecamp.application.BaseCampApplication]: Bean property 'root' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

So i was looking for the file "ApplicationContext.xml" and this is his content :

<bean id="basecampComponent" class="org.restlet.ext.spring.SpringComponent">
  <property name="defaultTarget" ref="basecampAppliction" />
</bean>
<bean id="basecampAppliction">class="com.mycompany.restlet.basecamp.application.BaseCampApplication">
  <property name="root" ref="router" />
</bean>
<!--  Define the router -->
<bean name="router" class="org.restlet.ext.spring.SpringBeanRouter" />

Someone has an idea where could I look for a way to debug this ?

By the way, i'm in Java 1.8.0_60.

Thanks for all your helps. Benjamin

ParkerHalo
  • 4,341
  • 9
  • 29
  • 51
bconotte
  • 23
  • 3
  • please put up `com.mycompany.restlet.basecamp.application.BaseCampApplication` in your question or more precisely the setter for **root** variable – Vihar Nov 19 '15 at 11:18
  • `package com.mycompany.restlet.basecamp.application; import org.restlet.Application; import org.restlet.ext.spring.SpringBeanRouter; public class BaseCampApplication extends Application { }` This is the basic code. A friend told me try to add this code inside : `private SpringBeanRouter root; public void setRoot(SpringBeanRouter route){ this.root=route; } public SpringBeanRouter getRoot(){ return this.root; } ` I tried but that didn't work too. – bconotte Nov 19 '15 at 12:58
  • Sorry for this presentation. I'm a newbie about Posting on stackoverflow. – bconotte Nov 19 '15 at 13:28

2 Answers2

1

After looking for some informations over the web, i've a hypothesis how I solved this.

On this link (Spring & Restlet : 100% XML configuration?), he's binding the router with the property "inboundroot" of Application. So I think there's a minimal changed (not noticed in the tutorial). In fact, i tried the project proposed in the archive (doesn't work) and the way you code yourself the tutorial. This is again two solutions.

The final solution consists so by changing the name of the property to "inboundroot" to "root".

"Never trusts the tuto"

Thanks for the time you took to help me.

Community
  • 1
  • 1
bconotte
  • 23
  • 3
0

I think that there is no root attribute in the Application class. You should add one in your BaseCampApplication class and use it to configure your application (see createInboundRoot method), as described below:

public class BaseCampApplication extends Application {
    private Restlet root;

    public Restlet createInboundRoot() {
        return root;
    }

    public void setRoot(Restlet root) {
        this.root = root;
    }
}

Hope it helps you, Thierry

Thierry Templier
  • 198,364
  • 44
  • 396
  • 360
  • Thanks Thierry. In fact, it seems there is a property named "inboundroot" in the class Application. You bind this property when you call the method "createInboundRoot()". By the way, I found the solution of my problem on your answer on this site. (http://stackoverflow.com/questions/28287377/spring-restlet-100-xml-configuration). You're my savior ! – bconotte Nov 19 '15 at 16:02