RE: 304 responses cause WARN logging

2010-06-10 Thread Eric Hough
http://restlet.tigris.org/issues/show_bug.cgi?id=1122

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


RE: Spring + Restlet 1.2-SNAPSHOT, NullPointerException

2009-04-21 Thread Eric Hough
Thanks to Kevin and Jerome's help, I was able to get a working Spring 
configuration. It still uses the deprecated Resource class, but it works for 
now and that's good
enough for my needs. In case anyone is following this thread, here are the 
details:


applicationContext.xml:


http://www.springframework.org/schema/beans";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:aop="http://www.springframework.org/schema/aop";
xmlns:tx="http://www.springframework.org/schema/tx";
xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd";>



















UniqResource.java:

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) */
@Override
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);
}

/** @see org.restlet.resource.Resource#init(org.restlet.Context, 
org.restlet.data.Request, org.restlet.data.Response) */
@Override
public void init(Context context, Request request, Response response) {
super.init(context, request, response);
getVariants().add(new Variant(MediaType.TEXT_PLAIN));  
}
}

And finally, UniqSpringBeanRouter.java:

public class UniqSpringBeanRouter extends SpringBeanRouter {

/** @see 
org.restlet.ext.spring.SpringBeanRouter#createFinder(org.springframework.beans.factory.BeanFactory,
 java.lang.String) */
protected Finder createFinder(BeanFactory beanFactory, String beanName) {
SpringBeanFinder springBeanFinder = new SpringBeanFinder(beanFactory, 
beanName);
springBeanFinder.setTargetClass(UniqResource.class);
return springBeanFinder;
}
}

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


RE: Spring + Restlet 1.2-SNAPSHOT, NullPointerException

2009-04-08 Thread Eric Hough
Thanks for the resources, Jerome. I'll take a look and see what I can learn 
from them!

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


Spring + Restlet 1.2-SNAPSHOT, NullPointerException

2009-04-04 Thread Eric Hough
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:


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";>




















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=1535043