|
From: Paulo S. <pau...@gm...> - 2008-08-11 14:03:20
|
I'm having trouble making the problem easy to reproduce... it happens
sometimes, but not always.
One thing I noted that is different in your tests from ours is that you
don't have a method answering a URL directly (without sub-resources) and
using a spring injected bean, which is our case. I changed our local test to
use a sub-resource and the problem seemed to vanished, although I cannot be
100% sure yet.
I could not make your environment run here, but I'll write down what I think
could be a test case for my scenario, that could be inserted in the
SmokeTest.
This is the new block test:
GetMethod method = new GetMethod("
http://localhost:8080/spring-integration-test/direct/direct-call");
int status = client.executeMethod(method);
Assert.assertEquals(HttpResponseCodes.SC_OK, status);
Assert.assertEquals("DIRECT OK", method.getResponseBodyAsString());
method.releaseConnection();
To implement this, we could use the following bean:
@Path("/direct")
@Service("direct")
public class DirectBean {
@GET
@Path("direct-call")
public String directCall() {
return directSpring.getDirectResult();
}
@Resource(name="directSpring")
private DirectSpring directSpring;
}
and the spring bean:
@Service("directSpring")
public class DirectSpring {
public String getDirectResult() {
return "DIRECT OK";
}
}
does this make sense? Does it make the problem easier to understand?
PS.: If this really reproduces our problem, you may have to run the test
some times before the error appears, since it works sometimes.
[]s,
On Fri, Aug 8, 2008 at 7:20 PM, Bill Burke <bb...@re...> wrote:
> I cannot reproduce this problem. Do you have resteasy's scanning turned
> on? That would screw things up.
>
> (I sent you the code I tested with. If you didn't get it ping me
> privately).
>
> Paulo Siqueira wrote:
>
>> Sorry, I forgot to check the mailing list address in the CC...
>>
>> ---------- Forwarded message ----------
>> From: *Paulo Siqueira* <pau...@gm... <mailto:
>> pau...@gm...>>
>> Date: Fri, Aug 8, 2008 at 3:12 PM
>> Subject: Re: [Resteasy-developers] Problem with Spring and RestEasy
>> integration
>> To: Bill Burke <bb...@re... <mailto:bb...@re...>>
>>
>>
>> Hi Bill,
>>
>> We don't want an instance per request. It doesn't matter at moment
>> actually. The problem is that it isn't working even with everything
>> singleton (which is the default scope in singleton). Do we have to do
>> anything special to flag the RESTful beans as singleton?
>>
>> The main problem is the a dependency of the RESTful bean is not being
>> injected sometimes, although the bean itself is always there, thus giving us
>> NullPointers. In the example Fabio sent it would be the field "Seci" that
>> would end up being null.
>>
>> []s,
>>
>>
>> On Fri, Aug 8, 2008 at 12:16 PM, Bill Burke <bb...@re... <mailto:
>> bb...@re...>> wrote:
>>
>> So you want a instance per request model?
>>
>> I'm not that familiar with spring and the RestEasy code expects a
>> singleton model.
>>
>> I'll try out your code and see if I can figure things out.
>>
>> Fábio Serra wrote:
>> > Hi,
>> >
>> > We have a problem integrating RestEasy and Spring. It seems like
>> when
>> > two users access the same resource at the same time, the
>> > SpringContextLoaderListener is not injecting after the first
>> instance.
>> > After that all the resource instances aren't injected by Spring
>> causing
>> > NullPointerException at the spring injected objects.
>> >
>> > My web.xml is the same as the examples of this integration.
>> >
>> > Here is my resource class:
>> > @Service("locating")
>> > @Path("/")
>> > public class LocatingResource {
>> > public LocatingResource() {
>> > System.out.println("Instanciando....");
>> > }
>> >
>> > @GET
>> > @Path("locating")
>> > public String getLocating() {
>> > System.out.println("Class: "+ this);
>> > System.out.println("LOCATING...("+getSpringTest()+")");
>> > return getSeci().toString();
>> > }
>> >
>> > @Resource
>> > private Seci seci;
>> > public void setSeci( Seci seci ) {
>> > System.out.println("Classe1: " +this);
>> > System.out.println("SACI2: "+ seci);
>> > this.seci = seci;
>> > }
>> > public Seci getSeci() {
>> > return this.seci;
>> > }
>> > }
>> >
>> > My ApplicationContext.xml :
>> > <beans xmlns="http://www.springframework.org/schema/beans"
>> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> > xmlns:context="
>> http://www.springframework.org/schema/context"
>> > default-autowire="byName"
>> > xsi:schemaLocation="http://www.springframework.org/schema/beans
>> >
>> > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>> >
>> http://www.springframework.org/schema/context
>> >
>> >
>> http://www.springframework.org/schema/context/spring-context-2.5.xsd"
>> >
>> > >
>> > <context:annotation-config/>
>> > <context:spring-configured/>
>> > <context:component-scan base-package="padauan"
>> > annotation-config="true"/>
>> > </bean>
>> >
>> >
>> > Thanks,
>> >
>> > Fabio Serra
>> >
>> >
>>
>> ------------------------------------------------------------------------
>> > Novos endereços, o Yahoo! que você conhece. Crie um email novo
>> >
>> <
>> http://br.rd.yahoo.com/mail/taglines/mail/*http://br.new.mail.yahoo.com/addresses
>> >
>> > com a sua cara @ymail.com <http://ymail.com> ou @rocketmail.com
>> <http://rocketmail.com>.
>> >
>> >
>> >
>>
>> ------------------------------------------------------------------------
>> >
>> >
>>
>> -------------------------------------------------------------------------
>> > This SF.Net email is sponsored by the Moblin Your Move
>> Developer's challenge
>> > Build the coolest Linux based applications with Moblin SDK & win
>> great prizes
>> > Grand prize is a trip for two to an Open Source event anywhere in
>> the world
>> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> <http://moblin-contest.org/redirect.php?banner_id=100&url=/>
>> >
>> >
>> >
>>
>> ------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > Resteasy-developers mailing list
>> > Res...@li...
>> <mailto:Res...@li...>
>> > https://lists.sourceforge.net/lists/listinfo/resteasy-developers
>>
>> --
>> Bill Burke
>> JBoss, a division of Red Hat
>> http://bill.burkecentral.com
>>
>>
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge
>> Build the coolest Linux based applications with Moblin SDK & win
>> great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in
>> the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> <http://moblin-contest.org/redirect.php?banner_id=100&url=/>
>> _______________________________________________
>> Resteasy-developers mailing list
>> Res...@li...
>> <mailto:Res...@li...>
>> https://lists.sourceforge.net/lists/listinfo/resteasy-developers
>>
>>
>>
>>
>> --
>> Paulo R C Siqueira
>> SCJP / SCWCD
>> http://www.ipti.org.br
>> Contato: (11) 8149-5046
>>
>>
>>
>> --
>> Paulo R C Siqueira
>> SCJP / SCWCD
>> http://www.ipti.org.br
>> Contato: (11) 8149-5046
>>
>>
>> ------------------------------------------------------------------------
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge
>> Build the coolest Linux based applications with Moblin SDK & win great
>> prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the
>> world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Resteasy-developers mailing list
>> Res...@li...
>> https://lists.sourceforge.net/lists/listinfo/resteasy-developers
>>
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
>
--
Paulo R C Siqueira
SCJP / SCWCD
http://www.ipti.org.br
Contato: (11) 8149-5046
|