PlanetJava
Custom Search

java-restlet-devel
[Top] [All Lists]

RE: No target class was defined for this finder ...

Subject: RE: No target class was defined for this finder ...
Date: Mon, 14 Sep 2009 21:07:18 -0700 (PDT)
I'm using org.restlet.ext.spriâng 2.0-M3 and I'm seeing the same problem.
To solve "No target class was defined for this finder ..." I had to add an 
additional property "targetClass" in my spring config and add a factory bean to 
instantiate a Class:
<entry key="/realEstate">
  <bean class="org.restlet.ext.spring.SpringFinder">
    <lookup-method name="createResource" bean="realEstateResource" />
    <property name="targetClass" ref="realEstateResourceClass"></property>
  </bean>
</entry>
<bean id="realEstateResource" class="com.company.RealEstateResource"
    scope="prototype">
  <property name="configuration" ref="freemarkerConfiguration" />
</bean>
<bean id="realEstateResourceClass" factory-bean="realEstateResource" 
factory-method="getClass"/>
This should make your problem go away since it will instantiate the Resource 
correctly. But it's still not using Spring context so read on.
I've seen that the SpringFinder is not retrieving the bean "realEstateResource" 
from the spring context but rather instantiating "targetClass" using 
newInstance() and of course not enjoying any of the dependencies injection.
The reason why it's not working is because I'm extending ServerResource instead 
of Resource. Now, the new ServerResource does not extend Handler so it will be 
false in org.restlet.resource.Finder line 450:
if (Handler.class.isAssignableFrom((Class<? extends Handler>) 
getTargetClass())) {
which in turn calls "find(request, response)" instead of "findTarget(request, 
response)". The consequence is that the lookup-method we declared above 
(createResource) is never called.
I think I can contribute a fix for this.
Regards,
Cheng
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458&dsMessageId=2394856
msgmiddle
<Prev in Thread] Current Thread [Next in Thread>
Current Sitemap | © 2012 planetjava | Contact | Privacy Policy