Hi Jerome,

There is a bug specifically with the SpringFinder class.  The parent Finder
was refactored such that it now checks to see that the "targetClass"
property is an instance of Handler.  Previous versions of the class did not
depend on targetClass to be non-null.

Since the SpringFinder only deals with the createResource() method, the
targetClass property is always null.

Eric, as a temporary workaround, you can create your own SpringFinder class
that overrides getTargetClass() to always return Resource.class.  Or you can
set the targetClass property on all your SpringFinder instances.

Kevin

On Tue, Apr 7, 2009 at 1:35 PM, Jerome Louvel <jerome.lou...@noelios.com>wrote:

>  Hi Eric,
>
> Here is a sample configuration attached. You can check the source code
> here:
>
> http://restlet.tigris.org/source/browse/restlet/trunk/modules/org.restlet.test/src/org/restlet/test/ext/spring/
>
>  Best regards,
> Jerome Louvel
> --
> Restlet ~ Founder and Lead developer ~ http://www.restlet.org
> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
>
>
>  ------------------------------
> *De :* Eric Hough [mailto:k2e...@gmail.com]
> *Envoyé :* vendredi 3 avril 2009 21:32
> *À :* discuss@restlet.tigris.org
> *Objet :* Spring + Restlet 1.2-SNAPSHOT, NullPointerException
>
> I've been having trouble getting Spring to play nice with Restlet (I'm
> experienced with Spring, a newbie with Restlet, so please bear with me!).
> Using Spring 2.5.6 and Restlet 1.2-SNAPSHOT.
>
> I want to define a resource called "uniq" and map /uniq to my UniqResource
> bean (extends Resource). Simple, yeah? When I browse to
> http://localhost:8182/uniq, I get the following stack trace:
>
> Apr 3, 2009 10:54:19 AM org.restlet.engine.StatusFilter getStatus
> SEVERE: Unhandled exception or error intercepted
> java.lang.NullPointerException
> at java.lang.Class.isAssignableFrom(Native Method)
> at org.restlet.resource.Finder.handle(Finder.java:391)
> at org.restlet.routing.Filter.doHandle(Filter.java:156)
> at org.restlet.routing.Filter.handle(Filter.java:201)
> at org.restlet.routing.Router.handle(Router.java:520)
> at org.restlet.routing.Filter.doHandle(Filter.java:156)
> at org.restlet.routing.Filter.handle(Filter.java:201)
> at org.restlet.routing.Router.handle(Router.java:520)
> at org.restlet.routing.Filter.doHandle(Filter.java:156)
> at org.restlet.routing.Filter.handle(Filter.java:201)
> at org.restlet.routing.Router.handle(Router.java:520)
> at org.restlet.routing.Filter.doHandle(Filter.java:156)
> at org.restlet.engine.StatusFilter.doHandle(StatusFilter.java:153)
> at org.restlet.routing.Filter.handle(Filter.java:201)
> at org.restlet.routing.Filter.doHandle(Filter.java:156)
> at org.restlet.routing.Filter.handle(Filter.java:201)
> at org.restlet.engine.ChainHelper.handle(ChainHelper.java:126)
> at org.restlet.Component.handle(Component.java:724)
> at org.restlet.Server.handle(Server.java:355)
> at org.restlet.engine.ServerHelper.handle(ServerHelper.java:71)
> at
> org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:149)
> at
> org.restlet.engine.http.StreamServerHelper$ConnectionHandler.run(StreamServerHelper.java:89)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
> at java.util.concurrent.FutureTask.run(FutureTask.java:138)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:619)
> Apr 3, 2009 10:54:19 AM org.restlet.engine.LogFilter afterHandle
> INFO: 2009-04-03 10:54:19 127.0.0.1 - - 8182 GET /uniq - 500 365 - 39
> http://localhost:8182 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8)
> Gecko/2009032711 Ubuntu/8.10 (intrepid) Firefox/3.0.8 -
>
>
> Here's my applicationContext.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd";>
>
> <bean id="springComponent" class="org.restlet.ext.spring.SpringComponent"
> init-method="start" destroy-method="stop">
> <property name="server">
> <bean class="org.restlet.ext.spring.SpringServer">
> <constructor-arg value="http" />
> <constructor-arg value="8182" />
> </bean>
> </property>
> <property name="defaultTarget" ref="springRouter" />
> </bean>
>
> <bean id="springRouter" class="org.restlet.ext.spring.SpringBeanRouter" />
>
> <bean name="/uniq" autowire="byName" id="uniqResource"
> class="org.example.uniq.rest.UniqResource" scope="prototype">
> <property name="nextUniqDao" ref="nextUniqDao" />
> </bean>
>
> </beans>
>
>
> And UniqResource.java:
>
> package org.example.uniq.rest;
>
> import java.io.StringReader;
>
> import org.example.uniq.dao.NextUniqDao;
>
> import org.restlet.data.MediaType;
> import org.restlet.data.Status;
> import org.restlet.representation.ReaderRepresentation;
> import org.restlet.representation.Representation;
> import org.restlet.representation.Variant;
> import org.restlet.resource.Resource;
> import org.restlet.resource.ResourceException;
>
> public class UniqResource extends Resource {
>
> private NextUniqDao nextUniqDao;
>
> public final void setNextUniqDao(NextUniqDao nextUniqDao) {
> this.nextUniqDao = nextUniqDao;
> }
>
> /** @see
> org.restlet.resource.Resource#represent(org.restlet.representation.Variant)
> */
> public Representation represent(Variant variant) throws ResourceException {
> Long next = this.nextUniqDao.pop();
> this.getResponse().setStatus(Status.SUCCESS_OK);
> return new ReaderRepresentation(new StringReader(next.toString()),
> MediaType.TEXT_PLAIN);
> }
>
> }
>
> Clearly I'm missing something basic, but I can't figure it out. Any help
> would be greatly appreciated!
>

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

Reply via email to