You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by ZhongGuan <gu...@gmail.com> on 2013/04/02 08:42:52 UTC

JAX-RS with CDI interceptor IN Tomee

I try to add a CDI interceptor on JAX-RS EndPoint, but it does not work.
I deploy it in glassfish, and it is OK.

I have tried to add org.apache.openejb.default.system.interceptors =
xxx.xx.XxxInterceptor
in system.proterties. It does not work.

so what should I do?

Thanks.



--
View this message in context: http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: JAX-RS with CDI interceptor IN Tomee

Posted by ZhongGuan <gu...@gmail.com>.
"you see the method is not the same (because of the generic usage) so the 
interceptor can't match the child (not the same signature) "

you mean, when startup, tomee will cache the Annotation and the method
signature Mapping?
so, at runtime the method(parameter is implement) is not same as that one?














--
View this message in context: http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661913.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: JAX-RS with CDI interceptor IN Tomee

Posted by ZhongGuan <gu...@gmail.com>.
Thanks,
And I also find a way to deal with this case.
I can change the Bound Type as same as interface in abstractImpl class.
So, the signature is same. and interceptor works..

Thank you very much.



--
View this message in context: http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661953.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: JAX-RS with CDI interceptor IN Tomee

Posted by Romain Manni-Bucau <rm...@gmail.com>.
yes, the issue is you pass through the interface so the interface doesn't
have the interceptor binding

i mailed OWB list asking if we should support it providing a patch, waiting
for some answers....

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/4/3 ZhongGuan <gu...@gmail.com>

> "Well pby fix it in OWB if not already done on trunk "
> Where can I see some infors?
>
> I want to ask a little bit more about method  signature capararison in
> interceptor.
> I test many cases,
> If the type of injected field is Interface, the inteceptor does not work.
> But if I change the type of injected field to AbstractImpl or Impl.
> the inteceptor is OK.
>
> In my opinion.
> There is a method signature capararison in CDI interceptor,
> one is the annotated method. the other is the called method.
>
> When I use interface for the Type of injected field, the called method is
> in
> the interface.
> and CDI will compare the method signature between this method and the
> method
> in AbstractImpl(in my case).
> because of the generic. so they are not same.
>
> And if the Type of the injected field is AbstractImpl or Impl.
> the method that the bean called is from AbstractImpl, so the two method
> signatures are same.
> So the Intecetor works.
>
> my understanding is right?
>
>
>
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661947.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: JAX-RS with CDI interceptor IN Tomee

Posted by ZhongGuan <gu...@gmail.com>.
"Well pby fix it in OWB if not already done on trunk "
Where can I see some infors?

I want to ask a little bit more about method  signature capararison in
interceptor.
I test many cases, 
If the type of injected field is Interface, the inteceptor does not work.
But if I change the type of injected field to AbstractImpl or Impl.
the inteceptor is OK.

In my opinion.
There is a method signature capararison in CDI interceptor,
one is the annotated method. the other is the called method.

When I use interface for the Type of injected field, the called method is in
the interface.
and CDI will compare the method signature between this method and the method
in AbstractImpl(in my case).
because of the generic. so they are not same.

And if the Type of the injected field is AbstractImpl or Impl. 
the method that the bean called is from AbstractImpl, so the two method
signatures are same.
So the Intecetor works.

my understanding is right?







--
View this message in context: http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661947.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: JAX-RS with CDI interceptor IN Tomee

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Well pby fix it in OWB if not already done on trunk but tomee cant use OWB
trunk (we use a maintainance branch)
Le 2 avr. 2013 20:49, "ZhongGuan" <gu...@gmail.com> a écrit :

> umm..
> I am going to consider it , maybe re-desgin my source.
> thanks a lot.
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661928.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: JAX-RS with CDI interceptor IN Tomee

Posted by ZhongGuan <gu...@gmail.com>.
umm..
I am going to consider it , maybe re-desgin my source.
thanks a lot.



--
View this message in context: http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661928.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: JAX-RS with CDI interceptor IN Tomee

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Use a single signature?
Le 2 avr. 2013 19:13, "ZhongGuan" <gu...@gmail.com> a écrit :

> Thanks for the advice.
> I can put the that annotation to the Class.
> And add other services to deal with the method with other interceptors.
>
> any other suggestion?
>
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661920.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: JAX-RS with CDI interceptor IN Tomee

Posted by ZhongGuan <gu...@gmail.com>.
Thanks for the advice.
I can put the that annotation to the Class.
And add other services to deal with the method with other interceptors.

any other suggestion?





--
View this message in context: http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661920.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: JAX-RS with CDI interceptor IN Tomee

Posted by Romain Manni-Bucau <rm...@gmail.com>.
not exactly, OpenWebBeans cache the info but basically here it compares

<T> T foo(Bar bar) between your abstract class and your impl. because of
<T> the child and the parent doesn't return the same class so both method
are not equal.

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/4/2 ZhongGuan <gu...@gmail.com>

> PS: your jaxb issue is fixed on trunk
> https://issues.apache.org/jira/browse/TOMEE-881
>
> that's great , Thank you.
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661914.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: JAX-RS with CDI interceptor IN Tomee

Posted by ZhongGuan <gu...@gmail.com>.
PS: your jaxb issue is fixed on trunk 
https://issues.apache.org/jira/browse/TOMEE-881

that's great , Thank you.



--
View this message in context: http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661914.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: JAX-RS with CDI interceptor IN Tomee

Posted by Romain Manni-Bucau <rm...@gmail.com>.
PS: your jaxb issue is fixed on trunk
https://issues.apache.org/jira/browse/TOMEE-881

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/4/2 Romain Manni-Bucau <rm...@gmail.com>

> in your sample there is no beans.xml. once added one with your interceptor
> you see the method is not the same (because of the generic usage) so the
> interceptor can't match the child (not the same signature)
>
> a simple workaround is to @logged on the class and not on the method.
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/4/2 ZhongGuan <gu...@gmail.com>
>
>> Another question
>>
>> In the JAXBContextResolver.java I have uploaded,
>> I try to use jaxbContext = JAXBContext.newInstance("prototype.dto");
>> to create JaxbContext.
>>
>> in Tomee 1.5 that is OK,
>> but in 1.6, it throws exception.
>>
>> there is no ObjectFactory.class or jaxb.index in "prototype.dto",
>> but I do have a jaxb.index file in that folder and in classpath.
>>
>> thanks.
>>
>>
>>
>> --
>> View this message in context:
>> http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661901.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>
>

Re: JAX-RS with CDI interceptor IN Tomee

Posted by Romain Manni-Bucau <rm...@gmail.com>.
in your sample there is no beans.xml. once added one with your interceptor
you see the method is not the same (because of the generic usage) so the
interceptor can't match the child (not the same signature)

a simple workaround is to @logged on the class and not on the method.

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/4/2 ZhongGuan <gu...@gmail.com>

> Another question
>
> In the JAXBContextResolver.java I have uploaded,
> I try to use jaxbContext = JAXBContext.newInstance("prototype.dto");
> to create JaxbContext.
>
> in Tomee 1.5 that is OK,
> but in 1.6, it throws exception.
>
> there is no ObjectFactory.class or jaxb.index in "prototype.dto",
> but I do have a jaxb.index file in that folder and in classpath.
>
> thanks.
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661901.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: JAX-RS with CDI interceptor IN Tomee

Posted by ZhongGuan <gu...@gmail.com>.
Another question

In the JAXBContextResolver.java I have uploaded,
I try to use jaxbContext = JAXBContext.newInstance("prototype.dto");
to create JaxbContext.

in Tomee 1.5 that is OK,
but in 1.6, it throws exception.

there is no ObjectFactory.class or jaxb.index in "prototype.dto",
but I do have a jaxb.index file in that folder and in classpath.

thanks.



--
View this message in context: http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661901.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: JAX-RS with CDI interceptor IN Tomee

Posted by ZhongGuan <gu...@gmail.com>.
WebProtoType2.zip
<http://openejb.979440.n4.nabble.com/file/n4661900/WebProtoType2.zip>  

Hi,
I test again,
Yes, in a regular case , it works .
but when I  change the endpoint service into Generic Class. 
the interceptor does not work.
I can not describe it clearly.
so I have uploaded the java source. 

if you want to run this case.
the content of request is like this
<customer>
    <id>1</id>
    <age xsi:nil="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
    <name>test1</name>
</customer>

thanks for help.






--
View this message in context: http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885p4661900.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: JAX-RS with CDI interceptor IN Tomee

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

just tested on trunk and it works, maybe give it a try with the last
version (1.6.0-SNAPSHOT for instance)

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/4/2 ZhongGuan <gu...@gmail.com>

> I try to add a CDI interceptor on JAX-RS EndPoint, but it does not work.
> I deploy it in glassfish, and it is OK.
>
> I have tried to add org.apache.openejb.default.system.interceptors =
> xxx.xx.XxxInterceptor
> in system.proterties. It does not work.
>
> so what should I do?
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/JAX-RS-with-CDI-interceptor-IN-Tomee-tp4661885.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>