With Guice/Jersey, we've always had to inject a proxy/delegate class that
contains all our AOP annotated methods.  As Stephan said, Jersey resource
classes are already created/instrumented and Guice then no longer has the
opportunity to wrap it with its AOP functionality.


On Thu, Nov 21, 2013 at 1:52 AM, Stephan Classen <[email protected]> wrote:

> The @Transactional annotation uses aop method interception (see
> JpaLocalTxnInterceptor).
> This means the annotation works only when all of the following is true:
>   - The concrete instance was created by Guice and not by anybody else
> (other framework or calling new)
>   - the annotated method is not private
>   - the annotated method is not final
>   - the annotated method is not static
>
> In your case I would suspect that maybe the instance was created by Jersey
> (and Jersey then passes the instance to Guice for member injection) and not
> by Guice itself.
>
> If this doesn't help you may need to post some code or reduce the problem
> to a minimal setup for further exploration.
>
> regards
> Stephan
>
>
>
>
> On 11/21/2013 12:35 AM, Armin Bahramshahry wrote:
>
>> Hi,
>>
>> I've setup Guice with Jersey, and the PersistFilter. Trying to use
>> @Transactional annotation, and it seems to be working if the object is
>> binded in the Singleton scope, or Request scope (from within the servlet
>> module binding); however, objects that are just binded with the basic
>> binding (none) they seem to have problem with @Transactional.
>>
>> Getting the EntityManager seem to work fine, etc, but nothing gets
>> committed.
>>
>> Simply moving the binding of the object from the AbstractModule to
>> ServletModule makes the @Transactional to work as expected. The
>> @Transactional seem to also work for all objects that are marked as
>> Singleton.
>>
>> Was wondering if this is an intended behavior or not, and if not, what
>> could be causing this?
>>
>> Regards,
>> Armin
>> --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/google-guice.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-guice.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to