You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by COURTAULT Francois <Fr...@gemalto.com> on 2017/11/24 14:26:27 UTC

RE: : Re: : Re: Injecting WebserviceContext returns null

Hello Romain,

I have found another workaround which seems to be more portable as it works for TomEE and Wildfly as expected.
I updated the Webservice POJO to become also a stateless EJB.

Having performed this update and deploy it in Glassfish 4.1.2, I had a runtime issue:
org.jboss.weld.exceptions.IllegalArgumentException: WELD-001405: Cannot inject [BackedAnnotatedField] @Inject @Intercepted private com.gemalto.jaxws.LoggingInterceptor.intercepted in a class which isnt a bean
Strange because Wildfly is using WELD as well and it works.

BTW, I have subscribed to metro@javaee.groups.io but when I tried to send an email I got:
A communication failure occurred during the delivery of this message. Please try to resend the message later. If the problem continues, contact your helpdesk.
The following organization rejected your message: lb01.groups.io.

Anything I can do to make the sending to this mailing-list work ? Have you any advice or tricks ?

Best Regards.

-----Original Message-----
From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
Sent: vendredi 24 novembre 2017 10:46
To: users@tomee.apache.org
Subject: [++SPAM++]: Re: : Re: Injecting WebserviceContext returns null

2017-11-24 10:36 GMT+01:00 COURTAULT Francois <Fr...@gemalto.com>:
> Hello Romain,
>
> I have tested my sample application on Glassfish 4.1.2 and on Wildfly 10.1.0 and I get the same behavior.
>
> But, I have found a workaround on TomEE 7.0.4.
>
> Using the @Logged annotation, instead of having:
> @Resource
> private WebServiceContext wsc;
>
> I updated with this:
> private WebServiceContext wsc;
>
> @Resource
> public void setServiceContext(WebServiceContext wsc) {
>    this.wsc = wsc;
> }
>
> This workaround works for TomEE 7.0.4 but if I tried this solution on Glassfish 4.1.2, I can't deploy my application. The error message I get is:
> Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1
> counts of IllegalAnnotationExceptions javax.xml.ws.WebServiceContext is an interface, and JAXB can't handle interfaces.

This is funny it takes it as a jaxb class but setting the jaxb access to NONE on the class should be a workaround

>
> Using Wildfly 10.1.0, I was able to deploy my application but at runtime I got the following exception:
> Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to
> construct component instance ...
> Caused by: java.lang.reflect.InvocationTargetException
> ...
> Caused by: java.lang.NullPointerException
>         at
> com.mycompany.jaxws.LoggingInterceptor.logMethod(LoggingInterceptor.ja
> va:32)
>
> The LoggingInterceptor looks like this:
> @Inject
> @Intercepted
> private Bean<?> intercepted;
> ....
> line 32 Logged loggedAnnotation =
> intercepted.getBeanClass().getAnnotation(Logged.class);
>
> So definitively, there is an issue with resource injection and CDI interceptor because I can't find a portable solution except if I use standard interceptor instead of CDI interceptor but, with this solution, we lose the facility to use annotation for interceptor.

Did you try the lookup? I don't fully recall the jndi name but the resource should be accessible through a jndi lookup in the invocation context.

>
> How can I provide some feedback to Java EE spec members about this issue ?


fear we are in a migration state but entry point would be https://javaee.github.io/metro-jax-ws/

>
> Best Regards.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> Sent: jeudi 23 novembre 2017 16:30
> To: users@tomee.apache.org
> Subject: [++SPAM++]: Re: Injecting WebserviceContext returns null
>
> 2017-11-23 16:25 GMT+01:00 COURTAULT Francois <Fr...@gemalto.com>:
>> Romain,
>>
>> My interceptor is linked to an annotation and is declared in the beans.xml  in order to work so I guess it is a cdi interceptor and, according to what you have said, a new proxy is created and so the injection is not done on the right proxy, right ?
>> But, in this case,  is it a bug ?
>
> Hmm, point is the jaxws runtime has no real other good way to do the interception. A workaround can be to have a jaws @vetoed pojo webservice and inject your cdi bean to delegate the processing to it.
>
>>
>> The other solution is to use @Interceptor or @Interceptors annotations but we lose the beauty of using an annotation for interceptor, right ?
>
> Would do the same I think.
>
>>
>> Best Regards.
>>
>> -----Original Message-----
>> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
>> Sent: jeudi 23 novembre 2017 15:57
>> To: users@tomee.apache.org
>> Subject: Re: Injecting WebserviceContext returns null
>>
>> annotation = cdi interceptor? if so it leads to a proxy and the
>> injection happens on the wrong instance I think
>>
>> Romain Manni-Bucau
>> @rmannibucau |  Blog | Old Blog | Github | LinkedIn
>>
>>
>> 2017-11-23 15:50 GMT+01:00 COURTAULT Francois <Fr...@gemalto.com>:
>>> Hello Romain,
>>>
>>> I think I have found the issue.
>>> In fact, we used a custom annotation for a logging interceptor which targets METHOD and TYPE.
>>>
>>> If we remove this annotation  on our WS endpoint (eg TYPE target) , then the injection is resolved.
>>>
>>> Do you know why we have this side effect  ? Is it a bug ?
>>> I have a  test case if you want.
>>>
>>> Best Regards.
>>>
>>> -----Original Message-----
>>> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
>>> Sent: jeudi 23 novembre 2017 14:25
>>> To: users@tomee.apache.org
>>> Subject: Re: Injecting WebserviceContext returns null
>>>
>>> Looks close to
>>> https://github.com/apache/tomee/blob/master/server/openejb-cxf/src/t
>>> e s
>>> t/java/org/apache/openejb/server/cxf/PojoWebServiceContextTest.java
>>> , what can be the difference?
>>>
>>> Romain Manni-Bucau
>>> @rmannibucau |  Blog | Old Blog | Github | LinkedIn
>>>
>>>
>>> 2017-11-23 13:49 GMT+01:00 COURTAULT Francois <Fr...@gemalto.com>:
>>>> Hello,
>>>>
>>>> No it's not an EJB webservice, just a POJO webservice annotated with @WebService(name = "MyManager", targetNamespace = "http://xxx.yyy.test..com/", serviceName = "MyManager", wsdlLocation =  "wsdl/MyManager.wsdl") like in the sample of my first email.
>>>> It looks quite similar to the sample provided in the JAX-WS 2.3 specification (maintenance release 5), page 82, §5.3 (javax.xml.ws.WebServiceContext)  except that the annotation, in our development,  uses  attributes like name, ...
>>>>
>>>> Best Regards.
>>>>
>>>> -----Original Message-----
>>>> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
>>>> Sent: jeudi 23 novembre 2017 13:34
>>>> To: users@tomee.apache.org
>>>> Subject: Re: Injecting WebserviceContext returns null
>>>>
>>>> Hi François,
>>>>
>>>> did you test with an EJB webservice?
>>>>
>>>> Romain Manni-Bucau
>>>> @rmannibucau |  Blog | Old Blog | Github | LinkedIn
>>>>
>>>>
>>>> 2017-11-23 12:11 GMT+01:00 COURTAULT Francois <Fr...@gemalto.com>:
>>>>> Hello,
>>>>>
>>>>> I have the following :
>>>>>
>>>>> @WebService(name = "MyManager", targetNamespace =
>>>>> "http://xxx.yyy.test..com/", serviceName = "MyManager",
>>>>> wsdlLocation =
>>>>> "wsdl/MyManager.wsdl") public class MyManagerService implements
>>>>> MyManager {
>>>>>
>>>>>     @Resource
>>>>>     WebServiceContext webServiceContext; ....
>>>>> }
>>>>>
>>>>> And the webServiceContet is always null ! Any clue ?
>>>>>
>>>>> Best Regards.
>>>>> ________________________________
>>>>> This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
>>>>> E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
>>>>> Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
>>>> ________________________________
>>>>  This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
>>>> E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
>>>> Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
>>> ________________________________
>>>  This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
>>> E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
>>> Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
>> ________________________________
>>  This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
>> E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
>> Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
> ________________________________
>  This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
________________________________
 This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.

Re: : Re: : Re: Injecting WebserviceContext returns null

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2017-11-24 15:26 GMT+01:00 COURTAULT Francois <Fr...@gemalto.com>:
> Hello Romain,
>
> I have found another workaround which seems to be more portable as it works for TomEE and Wildfly as expected.
> I updated the Webservice POJO to become also a stateless EJB.

also? so you deploy it twice potentially with different settings? EJB
integration should be more reliable yes since more mainstream and spec
are more up to date with CDI.

>
> Having performed this update and deploy it in Glassfish 4.1.2, I had a runtime issue:
> org.jboss.weld.exceptions.IllegalArgumentException: WELD-001405: Cannot inject [BackedAnnotatedField] @Inject @Intercepted private com.gemalto.jaxws.LoggingInterceptor.intercepted in a class which isnt a bean
> Strange because Wildfly is using WELD as well and it works.
>

yes but versions are likely different and the integration is not the
same for sure.

> BTW, I have subscribed to metro@javaee.groups.io but when I tried to send an email I got:
> A communication failure occurred during the delivery of this message. Please try to resend the message later. If the problem continues, contact your helpdesk.
> The following organization rejected your message: lb01.groups.io.
>
> Anything I can do to make the sending to this mailing-list work ? Have you any advice or tricks ?

Not sure to be honest, JAX-WS is not the highest priority specs so not
really sure what is the current state :s

>
> Best Regards.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> Sent: vendredi 24 novembre 2017 10:46
> To: users@tomee.apache.org
> Subject: [++SPAM++]: Re: : Re: Injecting WebserviceContext returns null
>
> 2017-11-24 10:36 GMT+01:00 COURTAULT Francois <Fr...@gemalto.com>:
>> Hello Romain,
>>
>> I have tested my sample application on Glassfish 4.1.2 and on Wildfly 10.1.0 and I get the same behavior.
>>
>> But, I have found a workaround on TomEE 7.0.4.
>>
>> Using the @Logged annotation, instead of having:
>> @Resource
>> private WebServiceContext wsc;
>>
>> I updated with this:
>> private WebServiceContext wsc;
>>
>> @Resource
>> public void setServiceContext(WebServiceContext wsc) {
>>    this.wsc = wsc;
>> }
>>
>> This workaround works for TomEE 7.0.4 but if I tried this solution on Glassfish 4.1.2, I can't deploy my application. The error message I get is:
>> Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1
>> counts of IllegalAnnotationExceptions javax.xml.ws.WebServiceContext is an interface, and JAXB can't handle interfaces.
>
> This is funny it takes it as a jaxb class but setting the jaxb access to NONE on the class should be a workaround
>
>>
>> Using Wildfly 10.1.0, I was able to deploy my application but at runtime I got the following exception:
>> Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to
>> construct component instance ...
>> Caused by: java.lang.reflect.InvocationTargetException
>> ...
>> Caused by: java.lang.NullPointerException
>>         at
>> com.mycompany.jaxws.LoggingInterceptor.logMethod(LoggingInterceptor.ja
>> va:32)
>>
>> The LoggingInterceptor looks like this:
>> @Inject
>> @Intercepted
>> private Bean<?> intercepted;
>> ....
>> line 32 Logged loggedAnnotation =
>> intercepted.getBeanClass().getAnnotation(Logged.class);
>>
>> So definitively, there is an issue with resource injection and CDI interceptor because I can't find a portable solution except if I use standard interceptor instead of CDI interceptor but, with this solution, we lose the facility to use annotation for interceptor.
>
> Did you try the lookup? I don't fully recall the jndi name but the resource should be accessible through a jndi lookup in the invocation context.
>
>>
>> How can I provide some feedback to Java EE spec members about this issue ?
>
>
> fear we are in a migration state but entry point would be https://javaee.github.io/metro-jax-ws/
>
>>
>> Best Regards.
>>
>> -----Original Message-----
>> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
>> Sent: jeudi 23 novembre 2017 16:30
>> To: users@tomee.apache.org
>> Subject: [++SPAM++]: Re: Injecting WebserviceContext returns null
>>
>> 2017-11-23 16:25 GMT+01:00 COURTAULT Francois <Fr...@gemalto.com>:
>>> Romain,
>>>
>>> My interceptor is linked to an annotation and is declared in the beans.xml  in order to work so I guess it is a cdi interceptor and, according to what you have said, a new proxy is created and so the injection is not done on the right proxy, right ?
>>> But, in this case,  is it a bug ?
>>
>> Hmm, point is the jaxws runtime has no real other good way to do the interception. A workaround can be to have a jaws @vetoed pojo webservice and inject your cdi bean to delegate the processing to it.
>>
>>>
>>> The other solution is to use @Interceptor or @Interceptors annotations but we lose the beauty of using an annotation for interceptor, right ?
>>
>> Would do the same I think.
>>
>>>
>>> Best Regards.
>>>
>>> -----Original Message-----
>>> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
>>> Sent: jeudi 23 novembre 2017 15:57
>>> To: users@tomee.apache.org
>>> Subject: Re: Injecting WebserviceContext returns null
>>>
>>> annotation = cdi interceptor? if so it leads to a proxy and the
>>> injection happens on the wrong instance I think
>>>
>>> Romain Manni-Bucau
>>> @rmannibucau |  Blog | Old Blog | Github | LinkedIn
>>>
>>>
>>> 2017-11-23 15:50 GMT+01:00 COURTAULT Francois <Fr...@gemalto.com>:
>>>> Hello Romain,
>>>>
>>>> I think I have found the issue.
>>>> In fact, we used a custom annotation for a logging interceptor which targets METHOD and TYPE.
>>>>
>>>> If we remove this annotation  on our WS endpoint (eg TYPE target) , then the injection is resolved.
>>>>
>>>> Do you know why we have this side effect  ? Is it a bug ?
>>>> I have a  test case if you want.
>>>>
>>>> Best Regards.
>>>>
>>>> -----Original Message-----
>>>> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
>>>> Sent: jeudi 23 novembre 2017 14:25
>>>> To: users@tomee.apache.org
>>>> Subject: Re: Injecting WebserviceContext returns null
>>>>
>>>> Looks close to
>>>> https://github.com/apache/tomee/blob/master/server/openejb-cxf/src/t
>>>> e s
>>>> t/java/org/apache/openejb/server/cxf/PojoWebServiceContextTest.java
>>>> , what can be the difference?
>>>>
>>>> Romain Manni-Bucau
>>>> @rmannibucau |  Blog | Old Blog | Github | LinkedIn
>>>>
>>>>
>>>> 2017-11-23 13:49 GMT+01:00 COURTAULT Francois <Fr...@gemalto.com>:
>>>>> Hello,
>>>>>
>>>>> No it's not an EJB webservice, just a POJO webservice annotated with @WebService(name = "MyManager", targetNamespace = "http://xxx.yyy.test..com/", serviceName = "MyManager", wsdlLocation =  "wsdl/MyManager.wsdl") like in the sample of my first email.
>>>>> It looks quite similar to the sample provided in the JAX-WS 2.3 specification (maintenance release 5), page 82, §5.3 (javax.xml.ws.WebServiceContext)  except that the annotation, in our development,  uses  attributes like name, ...
>>>>>
>>>>> Best Regards.
>>>>>
>>>>> -----Original Message-----
>>>>> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
>>>>> Sent: jeudi 23 novembre 2017 13:34
>>>>> To: users@tomee.apache.org
>>>>> Subject: Re: Injecting WebserviceContext returns null
>>>>>
>>>>> Hi François,
>>>>>
>>>>> did you test with an EJB webservice?
>>>>>
>>>>> Romain Manni-Bucau
>>>>> @rmannibucau |  Blog | Old Blog | Github | LinkedIn
>>>>>
>>>>>
>>>>> 2017-11-23 12:11 GMT+01:00 COURTAULT Francois <Fr...@gemalto.com>:
>>>>>> Hello,
>>>>>>
>>>>>> I have the following :
>>>>>>
>>>>>> @WebService(name = "MyManager", targetNamespace =
>>>>>> "http://xxx.yyy.test..com/", serviceName = "MyManager",
>>>>>> wsdlLocation =
>>>>>> "wsdl/MyManager.wsdl") public class MyManagerService implements
>>>>>> MyManager {
>>>>>>
>>>>>>     @Resource
>>>>>>     WebServiceContext webServiceContext; ....
>>>>>> }
>>>>>>
>>>>>> And the webServiceContet is always null ! Any clue ?
>>>>>>
>>>>>> Best Regards.
>>>>>> ________________________________
>>>>>> This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
>>>>>> E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
>>>>>> Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
>>>>> ________________________________
>>>>>  This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
>>>>> E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
>>>>> Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
>>>> ________________________________
>>>>  This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
>>>> E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
>>>> Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
>>> ________________________________
>>>  This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
>>> E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
>>> Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
>> ________________________________
>>  This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
>> E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
>> Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
> ________________________________
>  This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.