|
From: Paulo S. <pau...@gm...> - 2008-08-21 17:49:53
|
Hi Bill,
Not really...
I'll send you a complete test project so that you can take a look.
In this example, what happens is this:
Calling
http://localhost:8080/SpringTest/fabiopqp
or
http://localhost:8080/SpringTest/fabiopqp-json
The result sometimes prints the injected field as null, and sometimes prints
it correctly. The state of correct changes between deploys, so if it works
once, it will probably work always until a redeploy (which means you might
have to redeploy a few times until you get the error)
In these two cases, a spring injected field is used directly.
A third test is the one at the URL:
http://localhost:8080/SpringTest/locating/test
Which uses an injected field in the return statement and thus is used as a
subresource. In this case, the code seems to always work.
[]s,
On Wed, Aug 20, 2008 at 3:41 PM, Bill Burke <bb...@re...> wrote:
> You can test against SVN version. Trunk should build.
>
> BTW, again, I was able to get this to work against beta 5. Were u?
>
> Paulo Siqueira wrote:
>
>> Hello,
>>
>> When will we have a "beta 6" realease, with the recent big commit? I'm
>> hoping to test it to see if anything regarding this problem changes... Or
>> should we just test it against the CVS version?
>>
>> []s,
>>
>> On Mon, Aug 11, 2008 at 11:03 AM, Paulo Siqueira <
>> pau...@gm... <mailto:pau...@gm...>> wrote:
>>
>> 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...
>> <mailto: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...>
>> <mailto: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...>
>> <mailto: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...>
>> <mailto: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>
>> <http://ymail.com> ou @rocketmail.com <http://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=/>
>> <
>> 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...>
>> <mailto: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=/>
>> <
>> 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...>
>> <mailto: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=/
>> <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
>>
>>
>>
>>
>> -- 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
|