CDI Principal injection: object is not an instance of declaring class

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

CDI Principal injection: object is not an instance of declaring class

makkus
Hi Folks,

in TomEE 8.0.0 there seems to be something wrong with the Principal
injection: The follwoing code works fine in M2:

package leaktest;

import java.security.Principal;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;

@Named
@RequestScoped
public class PrincipalTest {
   
    @Inject
    private Principal principal;
   
    public String userName(){
        return principal.getName();
    }
}

Inside a  JSF page I can use "User Name: #{principalTest.userName()}" to
display the user name. (See attached  leak2.war
<http://tomee-openejb.979440.n4.nabble.com/file/t376354/leak2.war>   or
https://1drv.ms/u/s!AlHB9FAlFWW_iLJlTcyBEqApE_UAvQ?e=HODheK for example. )


In 8.0.0. this is code will produce an IllegalArgumentException:

java.lang.IllegalArgumentException: object is not an instance of declaring
class
        java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)

java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.base/java.lang.reflect.Method.invoke(Method.java:566)

org.apache.openejb.cdi.ManagedSecurityService$PrincipalInvocationHandler.invoke(ManagedSecurityService.java:183)
        com.sun.proxy.$Proxy72.getName(Unknown Source)
        leaktest.PrincipalTest.userName(PrincipalTest.java:25)

leaktest.PrincipalTest$$OwbNormalScopeProxy0.userName(leaktest/PrincipalTest.java)
        java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)

java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.base/java.lang.reflect.Method.invoke(Method.java:566)
        javax.el.BeanELResolver.invoke(BeanELResolver.java:158)
...


Doese someone kow if this code is unsupported in 8.0.0 ? How can I get a
reference to the principal name in 8.0.0.

Best Regards,
Marcus




--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: CDI Principal injection: object is not an instance of declaring class

Richard Monson-Haefel
Thanks for this, Marcus!  I've asked the development community to look into
it. Please be patient as it can take a while to figure these things out.

On Mon, Oct 14, 2019 at 5:14 AM makkus <[hidden email]> wrote:

> Hi Folks,
>
> in TomEE 8.0.0 there seems to be something wrong with the Principal
> injection: The follwoing code works fine in M2:
>
> package leaktest;
>
> import java.security.Principal;
> import javax.enterprise.context.RequestScoped;
> import javax.inject.Inject;
> import javax.inject.Named;
>
> @Named
> @RequestScoped
> public class PrincipalTest {
>
>     @Inject
>     private Principal principal;
>
>     public String userName(){
>         return principal.getName();
>     }
> }
>
> Inside a  JSF page I can use "User Name: #{principalTest.userName()}" to
> display the user name. (See attached  leak2.war
> <http://tomee-openejb.979440.n4.nabble.com/file/t376354/leak2.war>   or
> https://1drv.ms/u/s!AlHB9FAlFWW_iLJlTcyBEqApE_UAvQ?e=HODheK for example. )
>
>
> In 8.0.0. this is code will produce an IllegalArgumentException:
>
> java.lang.IllegalArgumentException: object is not an instance of declaring
> class
>
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>
>
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
>
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         java.base/java.lang.reflect.Method.invoke(Method.java:566)
>
>
> org.apache.openejb.cdi.ManagedSecurityService$PrincipalInvocationHandler.invoke(ManagedSecurityService.java:183)
>         com.sun.proxy.$Proxy72.getName(Unknown Source)
>         leaktest.PrincipalTest.userName(PrincipalTest.java:25)
>
>
> leaktest.PrincipalTest$$OwbNormalScopeProxy0.userName(leaktest/PrincipalTest.java)
>
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>
>
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
>
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         java.base/java.lang.reflect.Method.invoke(Method.java:566)
>         javax.el.BeanELResolver.invoke(BeanELResolver.java:158)
> ...
>
>
> Doese someone kow if this code is unsupported in 8.0.0 ? How can I get a
> reference to the principal name in 8.0.0.
>
> Best Regards,
> Marcus
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>


--
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/
Reply | Threaded
Open this post in threaded view
|

Re: Re: CDI Principal injection: object is not an instance of declaring class

Zowalla, Richard
In reply to this post by makkus
Hi makkus,

I have opened an jira issue for further investigation:  https://jira.apache.org/jira/browse/TOMEE-2709

Could you upload the source code, you used for creating the WAR archive there?

It could be beneficial, if we are going into debugging this issue.

In addition, I can confirm, that this happens on M3 and Final.

Best,
Richard


-----------

Thanks for this, Marcus!  I've asked the development community to look into
it. Please be patient as it can take a while to figure these things out.

On Mon, Oct 14, 2019 at 5:14 AM makkus <[hidden email]> wrote:

> Hi Folks,
>
> in TomEE 8.0.0 there seems to be something wrong with the Principal
> injection: The follwoing code works fine in M2:
>
> package leaktest;
>
> import java.security.Principal;
> import javax.enterprise.context.RequestScoped;
> import javax.inject.Inject;
> import javax.inject.Named;
>
> @Named
> @RequestScoped
> public class PrincipalTest {
>
>     @Inject
>     private Principal principal;
>
>     public String userName(){
>         return principal.getName();
>     }
> }
>
> Inside a  JSF page I can use "User Name: #{principalTest.userName()}" to
> display the user name. (See attached  leak2.war
> <http://tomee-openejb.979440.n4.nabble.com/file/t376354/leak2.war>   or
https://1drv.ms/u/s!AlHB9FAlFWW_iLJlTcyBEqApE_UAvQ?e=HODheK for example. )
>
>
> In 8.0.0. this is code will produce an IllegalArgumentException:
>
> java.lang.IllegalArgumentException: object is not an instance of declaring
> class
>
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>
>
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
>
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         java.base/java.lang.reflect.Method.invoke(Method.java:566)
>
>
> org.apache.openejb.cdi.ManagedSecurityService$PrincipalInvocationHandler.invoke(ManagedSecurityService.java:183)
>         com.sun.proxy.$Proxy72.getName(Unknown Source)
>         leaktest.PrincipalTest.userName(PrincipalTest.java:25)
>
>
> leaktest.PrincipalTest$$OwbNormalScopeProxy0.userName(leaktest/PrincipalTest.java)
>
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>
>
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
>
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         java.base/java.lang.reflect.Method.invoke(Method.java:566)
>         javax.el.BeanELResolver.invoke(BeanELResolver.java:158)
> ...
>
>
> Doese someone kow if this code is unsupported in 8.0.0 ? How can I get a
> reference to the principal name in 8.0.0.
>
> Best Regards,
> Marcus
>
>
>
>
> --
> Sent from:
http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>-- 
Richard Zowalla, M.Sc.
Research Associate, PhD Student | Medical Informatics



Hochschule Heilbronn – University of Applied Sciences
Max-Planck-Str. 39 
D-74081 Heilbronn 
phone: +49 7131 504 6791

smime.p7s (9K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: CDI Principal injection: object is not an instance of declaring class

makkus
Hi Richard,

I have attached the source files here:

leak2.zip <http://tomee-openejb.979440.n4.nabble.com/file/t376354/leak2.zip>  

Maybe it is worth a note that the injection of SecurityContext still works.
So as a workaround the following will do the Job:

    @Context
    private SecurityContext  securityCtx;
   
    public String userName(){
        return securityCtx.getUserPrincipal().getName();
    }

Thanks for investigating this!
Marcus




--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: Re: CDI Principal injection: object is not an instance of declaring class

Richard Monson-Haefel
Hi Markus,

Do you want to try your hand at a doing a Pull-Request so you can get your
first commit on TomEE?  I can help you with that. It's actually pretty easy
to do.

Richard

On Tue, Oct 15, 2019 at 6:36 AM makkus <[hidden email]> wrote:

> Hi Richard,
>
> I have attached the source files here:
>
> leak2.zip <
> http://tomee-openejb.979440.n4.nabble.com/file/t376354/leak2.zip>
>
> Maybe it is worth a note that the injection of SecurityContext still works.
> So as a workaround the following will do the Job:
>
>     @Context
>     private SecurityContext  securityCtx;
>
>     public String userName(){
>         return securityCtx.getUserPrincipal().getName();
>     }
>
> Thanks for investigating this!
> Marcus
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>


--
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/
Reply | Threaded
Open this post in threaded view
|

Re: Re: CDI Principal injection: object is not an instance of declaring class

makkus
Hi Richard,

basically I might give it a try at some point, but currently I am a little
bit under pressure and still heavily figthing the the classloader leaks
TomEE produces
(http://tomee-openejb.979440.n4.nabble.com/Activating-CDI-creates-classloader-leak-in-tomee-tomcat-tp4690835.html)
- it seems impossible (even with a minimalistic app) to not leak classes on
reload, so I start considering wether I need to move to some other
container.

Marcus






--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

RE: Re: CDI Principal injection: object is not an instance of declaring class

COURTAULT Francois
In reply to this post by Richard Monson-Haefel
Hello,

May I make a comment on this.
Looking at https://docs.oracle.com/javaee/7/tutorial/cdi-adv004.htm, it looks like   you can't inject a Principal using @Inject annotation, right?
But using @Resource annotation, you are able to get the Principal.

So in your previous code:
@Named
@RequestScoped
 public class PrincipalTest {

     @Inject-> change @Inject by @Resource, does it work ?
     private Principal principal;

     public String userName(){
         return principal.getName();
     }
 }

Best Regards.

-----Original Message-----
From: Richard Monson-Haefel [mailto:[hidden email]]
Sent: mardi 15 octobre 2019 13:42
To: [hidden email]
Subject: Re: Re: CDI Principal injection: object is not an instance of declaring class

Hi Markus,

Do you want to try your hand at a doing a Pull-Request so you can get your first commit on TomEE?  I can help you with that. It's actually pretty easy to do.

Richard

On Tue, Oct 15, 2019 at 6:36 AM makkus <[hidden email]> wrote:

> Hi Richard,
>
> I have attached the source files here:
>
> leak2.zip <
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftomee
> -openejb.979440.n4.nabble.com%2Ffile%2Ft376354%2Fleak2.zip&amp;data=02
> %7C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d7516
> 4be4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C1%7C637067365437190360&
> amp;sdata=IxxcqUuO7L1CStvRUS0HCU3zs9PgIa%2FKxG8ziESdPDs%3D&amp;reserve
> d=0>
>
> Maybe it is worth a note that the injection of SecurityContext still works.
> So as a workaround the following will do the Job:
>
>     @Context
>     private SecurityContext  securityCtx;
>
>     public String userName(){
>         return securityCtx.getUserPrincipal().getName();
>     }
>
> Thanks for investigating this!
> Marcus
>
>
>
>
> --
> Sent from:
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftomee
> -openejb.979440.n4.nabble.com%2FTomEE-Users-f979441.html&amp;data=02%7
> C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d75164b
> e4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C1%7C637067365437190360&am
> p;sdata=eiF1kL6x7QMtJgEgINI%2BEzdJ5zgrh0Vyqqyr0yhCRho%3D&amp;reserved=
> 0
>


--
Richard Monson-Haefel
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwitter.com%2Frmonson&amp;data=02%7C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d75164be4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C0%7C637067365437190360&amp;sdata=mGvDJ72pYWoeSKFMPxpOIwZFqK%2F4CWutWTpzpga2vys%3D&amp;reserved=0
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.linkedin.com%2Fin%2Fmonsonhaefel%2F&amp;data=02%7C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d75164be4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C1%7C637067365437190360&amp;sdata=uaiPWx2%2BHL5c5lBlYhRqarcOP6eN5QDH0i0yShlDdYY%3D&amp;reserved=0
________________________________
 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.
Reply | Threaded
Open this post in threaded view
|

Re: Re: CDI Principal injection: object is not an instance of declaring class

Richard Monson-Haefel
Great find, Francois!  The article does use the @Resource annotation so
maybe that its the way to go, Marco.

On Tue, Oct 15, 2019 at 7:43 AM COURTAULT Francois <
[hidden email]> wrote:

> Hello,
>
> May I make a comment on this.
> Looking at https://docs.oracle.com/javaee/7/tutorial/cdi-adv004.htm, it
> looks like   you can't inject a Principal using @Inject annotation, right?
> But using @Resource annotation, you are able to get the Principal.
>
> So in your previous code:
> @Named
> @RequestScoped
>  public class PrincipalTest {
>
>      @Inject-> change @Inject by @Resource, does it work ?
>      private Principal principal;
>
>      public String userName(){
>          return principal.getName();
>      }
>  }
>
> Best Regards.
>
> -----Original Message-----
> From: Richard Monson-Haefel [mailto:[hidden email]]
> Sent: mardi 15 octobre 2019 13:42
> To: [hidden email]
> Subject: Re: Re: CDI Principal injection: object is not an instance of
> declaring class
>
> Hi Markus,
>
> Do you want to try your hand at a doing a Pull-Request so you can get your
> first commit on TomEE?  I can help you with that. It's actually pretty easy
> to do.
>
> Richard
>
> On Tue, Oct 15, 2019 at 6:36 AM makkus <[hidden email]> wrote:
>
> > Hi Richard,
> >
> > I have attached the source files here:
> >
> > leak2.zip <
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftomee
> > -openejb.979440.n4.nabble.com%2Ffile%2Ft376354%2Fleak2.zip&amp;data=02
> > %7C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d7516
> > 4be4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C1%7C637067365437190360&
> > amp;sdata=IxxcqUuO7L1CStvRUS0HCU3zs9PgIa%2FKxG8ziESdPDs%3D&amp;reserve
> > d=0>
> >
> > Maybe it is worth a note that the injection of SecurityContext still
> works.
> > So as a workaround the following will do the Job:
> >
> >     @Context
> >     private SecurityContext  securityCtx;
> >
> >     public String userName(){
> >         return securityCtx.getUserPrincipal().getName();
> >     }
> >
> > Thanks for investigating this!
> > Marcus
> >
> >
> >
> >
> > --
> > Sent from:
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftomee
> > -openejb.979440.n4.nabble.com%2FTomEE-Users-f979441.html&amp;data=02%7
> > C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d75164b
> > e4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C1%7C637067365437190360&am
> > p;sdata=eiF1kL6x7QMtJgEgINI%2BEzdJ5zgrh0Vyqqyr0yhCRho%3D&amp;reserved=
> > 0
> >
>
>
> --
> Richard Monson-Haefel
>
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwitter.com%2Frmonson&amp;data=02%7C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d75164be4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C0%7C637067365437190360&amp;sdata=mGvDJ72pYWoeSKFMPxpOIwZFqK%2F4CWutWTpzpga2vys%3D&amp;reserved=0
>
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.linkedin.com%2Fin%2Fmonsonhaefel%2F&amp;data=02%7C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d75164be4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C1%7C637067365437190360&amp;sdata=uaiPWx2%2BHL5c5lBlYhRqarcOP6eN5QDH0i0yShlDdYY%3D&amp;reserved=0
> ________________________________
>  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.
>


--
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/
Reply | Threaded
Open this post in threaded view
|

Re: Re: CDI Principal injection: object is not an instance of declaring class

Richard Monson-Haefel
In reply to this post by makkus
Understood.

On Tue, Oct 15, 2019 at 7:38 AM makkus <[hidden email]> wrote:

> Hi Richard,
>
> basically I might give it a try at some point, but currently I am a little
> bit under pressure and still heavily figthing the the classloader leaks
> TomEE produces
> (
> http://tomee-openejb.979440.n4.nabble.com/Activating-CDI-creates-classloader-leak-in-tomee-tomcat-tp4690835.html)
>
> - it seems impossible (even with a minimalistic app) to not leak classes on
> reload, so I start considering wether I need to move to some other
> container.
>
> Marcus
>
>
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>


--
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/
Reply | Threaded
Open this post in threaded view
|

Re: Re: CDI Principal injection: object is not an instance of declaring class

jgallimore
In reply to this post by makkus
I responded to your other email - I'll take a look at the classes leaking
on reload later today. Thank you for reporting it, I'll let you know what
I find.

Jon

On Tue, Oct 15, 2019 at 1:38 PM makkus <[hidden email]> wrote:

> Hi Richard,
>
> basically I might give it a try at some point, but currently I am a little
> bit under pressure and still heavily figthing the the classloader leaks
> TomEE produces
> (
> http://tomee-openejb.979440.n4.nabble.com/Activating-CDI-creates-classloader-leak-in-tomee-tomcat-tp4690835.html)
>
> - it seems impossible (even with a minimalistic app) to not leak classes on
> reload, so I start considering wether I need to move to some other
> container.
>
> Marcus
>
>
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>
Reply | Threaded
Open this post in threaded view
|

RE: Re: CDI Principal injection: object is not an instance of declaring class

COURTAULT Francois
In reply to this post by Richard Monson-Haefel
Hello Makkus,

Regarding  my last post, have you tried to change

@Inject
private Principal principal;

By

@Resource
private Principal principal;
?

Does it work or not ?

Best Regards.

-----Original Message-----
From: Richard Monson-Haefel [mailto:[hidden email]]
Sent: mardi 15 octobre 2019 14:53
To: [hidden email]
Subject: Re: Re: CDI Principal injection: object is not an instance of declaring class

Great find, Francois!  The article does use the @Resource annotation so maybe that its the way to go, Marco.

On Tue, Oct 15, 2019 at 7:43 AM COURTAULT Francois < [hidden email]> wrote:

> Hello,
>
> May I make a comment on this.
> Looking at https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.oracle.com%2Fjavaee%2F7%2Ftutorial%2Fcdi-adv004.htm&amp;data=02%7C01%7CFrancois.COURTAULT%40gemalto.com%7C60ec44c959ff44cb1d6b08d7516eaaec%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C0%7C637067408064770254&amp;sdata=nmvNDjfX48kLOiEEhitzD9glvxZ8sd%2B5K%2FHmYaWbFss%3D&amp;reserved=0, it
> looks like   you can't inject a Principal using @Inject annotation, right?
> But using @Resource annotation, you are able to get the Principal.
>
> So in your previous code:
> @Named
> @RequestScoped
>  public class PrincipalTest {
>
>      @Inject-> change @Inject by @Resource, does it work ?
>      private Principal principal;
>
>      public String userName(){
>          return principal.getName();
>      }
>  }
>
> Best Regards.
>
> -----Original Message-----
> From: Richard Monson-Haefel [mailto:[hidden email]]
> Sent: mardi 15 octobre 2019 13:42
> To: [hidden email]
> Subject: Re: Re: CDI Principal injection: object is not an instance of
> declaring class
>
> Hi Markus,
>
> Do you want to try your hand at a doing a Pull-Request so you can get
> your first commit on TomEE?  I can help you with that. It's actually
> pretty easy to do.
>
> Richard
>
> On Tue, Oct 15, 2019 at 6:36 AM makkus <[hidden email]> wrote:
>
> > Hi Richard,
> >
> > I have attached the source files here:
> >
> > leak2.zip <
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftom
> > ee
> > -openejb.979440.n4.nabble.com%2Ffile%2Ft376354%2Fleak2.zip&amp;data=
> > 02
> > %7C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d75
> > 16
> > 4be4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C1%7C63706736543719036
> > 0&
> > amp;sdata=IxxcqUuO7L1CStvRUS0HCU3zs9PgIa%2FKxG8ziESdPDs%3D&amp;reser
> > ve
> > d=0>
> >
> > Maybe it is worth a note that the injection of SecurityContext still
> works.
> > So as a workaround the following will do the Job:
> >
> >     @Context
> >     private SecurityContext  securityCtx;
> >
> >     public String userName(){
> >         return securityCtx.getUserPrincipal().getName();
> >     }
> >
> > Thanks for investigating this!
> > Marcus
> >
> >
> >
> >
> > --
> > Sent from:
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftom
> > ee
> > -openejb.979440.n4.nabble.com%2FTomEE-Users-f979441.html&amp;data=02
> > %7
> > C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d7516
> > 4b
> > e4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C1%7C637067365437190360&
> > am
> > p;sdata=eiF1kL6x7QMtJgEgINI%2BEzdJ5zgrh0Vyqqyr0yhCRho%3D&amp;reserve
> > d=
> > 0
> >
>
>
> --
> Richard Monson-Haefel
>
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwit
> ter.com%2Frmonson&amp;data=02%7C01%7CFrancois.COURTAULT%40gemalto.com%
> 7C60ec44c959ff44cb1d6b08d7516eaaec%7C37d0a9db7c464096bfe31add5b495d6d%
> 7C0%7C0%7C637067408064770254&amp;sdata=UVtPlK6gqBrpTAJQx8w2hoLZWZdTKhX
> X%2FWoU1Vah1mY%3D&amp;reserved=0
>
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.
> linkedin.com%2Fin%2Fmonsonhaefel%2F&amp;data=02%7C01%7CFrancois.COURTA
> ULT%40gemalto.com%7C60ec44c959ff44cb1d6b08d7516eaaec%7C37d0a9db7c46409
> 6bfe31add5b495d6d%7C0%7C0%7C637067408064770254&amp;sdata=B284Ow7dFdy%2
> Fe7hbC%2Bk7H%2FETjXGvCfq%2BgnaNKeIDCqY%3D&amp;reserved=0
> ________________________________
>  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.
>


--
Richard Monson-Haefel
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwitter.com%2Frmonson&amp;data=02%7C01%7CFrancois.COURTAULT%40gemalto.com%7C60ec44c959ff44cb1d6b08d7516eaaec%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C0%7C637067408064770254&amp;sdata=UVtPlK6gqBrpTAJQx8w2hoLZWZdTKhXX%2FWoU1Vah1mY%3D&amp;reserved=0
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.linkedin.com%2Fin%2Fmonsonhaefel%2F&amp;data=02%7C01%7CFrancois.COURTAULT%40gemalto.com%7C60ec44c959ff44cb1d6b08d7516eaaec%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C0%7C637067408064770254&amp;sdata=B284Ow7dFdy%2Fe7hbC%2Bk7H%2FETjXGvCfq%2BgnaNKeIDCqY%3D&amp;reserved=0
________________________________
 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.