You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by makkus <sa...@gmx.de> on 2019/10/14 10:14:21 UTC

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

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

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

Posted by Richard Monson-Haefel <mo...@gmail.com>.
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 <sa...@gmx.de> 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/

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

Posted by Richard Monson-Haefel <mo...@gmail.com>.
Good move, Richard

On Mon, Oct 14, 2019 at 8:11 AM Zowalla, Richard <
richard.zowalla@hs-heilbronn.de> wrote:

> I opened a JIRA for it for further investigation:
> https://jira.apache.org/jira/browse/TOMEE-2709
>
> If it is not a bug or something else, we can simply close it and keep
> track on this.
>
> Best,
> Richard
>
> Am Montag, den 14.10.2019, 11:43 +0000 schrieb Zowalla, Richard:
>
> Hi,
>
> I tested the attached WAR with M2,M3 and RELEASE, results below:
>
> - M2: works as stated by the user
> - M3: Exception as stated below by the user
> - Release: same as M3 (exception as stated below).
>
> Source-code would be beneficial for debug purpose :)
>
> Best,
> Richard
>
>
>
> Am Montag, den 14.10.2019, 06:11 -0500 schrieb Richard Monson-Haefel:
>
> It would be great if someone in the community could take a quick look at
>
> this and report back.  It seems to be a bug, but I'm not sure.
>
>
> Anyone?
>
>
> ---------- Forwarded message ---------
>
> From: makkus <sa...@gmx.de>
>
> Date: Mon, Oct 14, 2019 at 5:14 AM
>
> Subject: CDI Principal injection: object is not an instance of declaring
>
> class
>
> To: <us...@tomee.apache.org>
>
>
>
> 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
> mail: richard.zowalla@hs-heilbronn.de
> web: http://www.mi.hs-heilbronn.de/
>
> --
>
> 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
> mail: richard.zowalla@hs-heilbronn.de
> web: http://www.mi.hs-heilbronn.de/
>


-- 
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/

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

Posted by "Zowalla, Richard" <ri...@hs-heilbronn.de>.
I opened a JIRA for it for further investigation: 
https://jira.apache.org/jira/browse/TOMEE-2709
If it is not a bug or something else, we can simply close it and keep
track on this.
Best,Richard
Am Montag, den 14.10.2019, 11:43 +0000 schrieb Zowalla, Richard:
> Hi,
> I tested the attached WAR with M2,M3 and RELEASE, results below:
> - M2: works as stated by the user- M3: Exception as stated below by
> the user- Release: same as M3 (exception as stated below).
> Source-code would be beneficial for debug purpose :)
> Best,Richard
> 
> 
> Am Montag, den 14.10.2019, 06:11 -0500 schrieb Richard Monson-Haefel:
> > It would be great if someone in the community could take a quick
> > look atthis and report back.  It seems to be a bug, but I'm not
> > sure.
> > Anyone?
> > ---------- Forwarded message ---------From: makkus <
> > sancho-fx3@gmx.de>Date: Mon, Oct 14, 2019 at 5:14 AMSubject: CDI
> > Principal injection: object is not an instance of declaringclassTo:
> > <us...@tomee.apache.org>
> > 
> > Hi Folks,
> > in TomEE 8.0.0 there seems to be something wrong with the
> > Principalinjection: 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@RequestScopedpublic class PrincipalTest {
> >     @Inject    private Principal principal;
> >     public String userName(){        return
> > principal.getName();    }}
> > Inside a  JSF page I can use "User Name:
> > #{principalTest.userName()}" todisplay the user name. (See
> > attached  leak2.war<
> > http://tomee-openejb.979440.n4.nabble.com/file/t376354/leak2.war>  
> >  orhttps://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
> > declaringclass
> > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Nat
> > iveMethod)
> > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Nati
> > veMethodAccessorImpl.java:62)
> > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
> > DelegatingMethodAccessorImpl.java:43)        java.base/java.lang.re
> > flect.Method.invoke(Method.java:566)
> > org.apache.openejb.cdi.ManagedSecurityService$PrincipalInvocationHa
> > ndler.invoke(ManagedSecurityService.java:183)        com.sun.proxy.
> > $Proxy72.getName(Unknown
> > Source)        leaktest.PrincipalTest.userName(PrincipalTest.java:2
> > 5)
> > leaktest.PrincipalTest$$OwbNormalScopeProxy0.userName(leaktest/Prin
> > cipalTest.java)
> > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Nat
> > iveMethod)
> > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Nati
> > veMethodAccessorImpl.java:62)
> > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
> > DelegatingMethodAccessorImpl.java:43)        java.base/java.lang.re
> > flect.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 areference 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 SciencesMax-Planck-Str.
> 39 D-74081 Heilbronn phone: +49 7131 504 6791mail:
> richard.zowalla@hs-heilbronn.deweb: http://www.mi.hs-heilbronn.de/ 
-- 
Richard Zowalla, M.Sc.Research Associate, PhD Student | Medical Informatics


Hochschule Heilbronn – University of Applied SciencesMax-Planck-Str. 39 D-74081 Heilbronn phone: +49 7131 504 6791mail: richard.zowalla@hs-heilbronn.deweb: http://www.mi.hs-heilbronn.de/ 

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

Posted by Richard Monson-Haefel <mo...@gmail.com>.
Thank you, Richard!  So great to have dedicated community members!

On Mon, Oct 14, 2019 at 7:36 AM Zowalla, Richard <
richard.zowalla@hs-heilbronn.de> wrote:

> Yup. Will do.
>
> Am Montag, den 14.10.2019, 07:17 -0500 schrieb Richard Monson-Haefel:
>
> Thanks for looking into this, Richard!  (great name btw).
>
> Would you be interested in subscribing to the users mailing list and
> talking to him directly?  Here is where you subscribe if interested:
>
> http://tomee.apache.org/mailing-lists.html
>
> You can always unsubscribe after if you want.
>
> On Mon, Oct 14, 2019 at 6:44 AM Zowalla, Richard <
> richard.zowalla@hs-heilbronn.de> wrote:
>
> Hi,
>
> I tested the attached WAR with M2,M3 and RELEASE, results below:
>
> - M2: works as stated by the user
> - M3: Exception as stated below by the user
> - Release: same as M3 (exception as stated below).
>
> Source-code would be beneficial for debug purpose :)
>
> Best,
> Richard
>
>
>
> Am Montag, den 14.10.2019, 06:11 -0500 schrieb Richard Monson-Haefel:
>
> It would be great if someone in the community could take a quick look at
>
> this and report back.  It seems to be a bug, but I'm not sure.
>
>
> Anyone?
>
>
> ---------- Forwarded message ---------
>
> From: makkus <sa...@gmx.de>
>
> Date: Mon, Oct 14, 2019 at 5:14 AM
>
> Subject: CDI Principal injection: object is not an instance of declaring
>
> class
>
> To: <us...@tomee.apache.org>
>
>
>
> 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
> mail: richard.zowalla@hs-heilbronn.de
> web: http://www.mi.hs-heilbronn.de/
>
>
>
> --
>
> 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
> mail: richard.zowalla@hs-heilbronn.de
> web: http://www.mi.hs-heilbronn.de/
>


-- 
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/

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

Posted by "Zowalla, Richard" <ri...@hs-heilbronn.de>.
Yup. Will do.
Am Montag, den 14.10.2019, 07:17 -0500 schrieb Richard Monson-Haefel:
> Thanks for looking into this, Richard!  (great name btw).
> Would you be interested in subscribing to the users mailing list and
> talking to him directly?  Here is where you subscribe if interested:
> 
> http://tomee.apache.org/mailing-lists.html
> 
> You can always unsubscribe after if you want.
> 
> On Mon, Oct 14, 2019 at 6:44 AM Zowalla, Richard <
> richard.zowalla@hs-heilbronn.de> wrote:
> > Hi,
> > 
> > I tested the attached WAR with M2,M3 and RELEASE, results below:
> > 
> > - M2: works as stated by the user
> > - M3: Exception as stated below by the user
> > - Release: same as M3 (exception as stated below).
> > 
> > Source-code would be beneficial for debug purpose :)
> > 
> > Best,
> > Richard
> > 
> > 
> > 
> > Am Montag, den 14.10.2019, 06:11 -0500 schrieb Richard Monson-
> > Haefel:
> > > It would be great if someone in the community could take a quick
> > > look atthis and report back.  It seems to be a bug, but I'm not
> > > sure.
> > > Anyone?
> > > ---------- Forwarded message ---------From: makkus <
> > > sancho-fx3@gmx.de>Date: Mon, Oct 14, 2019 at 5:14 AMSubject: CDI
> > > Principal injection: object is not an instance of
> > > declaringclassTo: <us...@tomee.apache.org>
> > > 
> > > Hi Folks,
> > > in TomEE 8.0.0 there seems to be something wrong with the
> > > Principalinjection: 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@RequestScopedpublic class PrincipalTest {
> > >     @Inject    private Principal principal;
> > >     public String userName(){        return
> > > principal.getName();    }}
> > > Inside a  JSF page I can use "User Name:
> > > #{principalTest.userName()}" todisplay the user name. (See
> > > attached  leak2.war<
> > > http://tomee-openejb.979440.n4.nabble.com/file/t376354/leak2.war>
> > >    orhttps://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
> > > declaringclass
> > > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(N
> > > ativeMethod)
> > > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Na
> > > tiveMethodAccessorImpl.java:62)
> > > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invok
> > > e(DelegatingMethodAccessorImpl.java:43)        java.base/java.lan
> > > g.reflect.Method.invoke(Method.java:566)
> > > org.apache.openejb.cdi.ManagedSecurityService$PrincipalInvocation
> > > Handler.invoke(ManagedSecurityService.java:183)        com.sun.pr
> > > oxy.$Proxy72.getName(Unknown
> > > Source)        leaktest.PrincipalTest.userName(PrincipalTest.java
> > > :25)
> > > leaktest.PrincipalTest$$OwbNormalScopeProxy0.userName(leaktest/Pr
> > > incipalTest.java)
> > > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(N
> > > ativeMethod)
> > > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Na
> > > tiveMethodAccessorImpl.java:62)
> > > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invok
> > > e(DelegatingMethodAccessorImpl.java:43)        java.base/java.lan
> > > g.reflect.Method.invoke(Method.java:566)        javax.el.BeanELRe
> > > solver.invoke(BeanELResolver.java:158)...
> > > 
> > > Doese someone kow if this code is unsupported in 8.0.0 ? How can
> > > I get areference 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 SciencesMax-Planck-
> > Str. 39 D-74081 Heilbronn phone: +49 7131 504 6791mail:
> > richard.zowalla@hs-heilbronn.deweb: http://www.mi.hs-heilbronn.de/ 
> 
> 
-- 
Richard Zowalla, M.Sc.Research Associate, PhD Student | Medical Informatics


Hochschule Heilbronn – University of Applied SciencesMax-Planck-Str. 39 D-74081 Heilbronn phone: +49 7131 504 6791mail: richard.zowalla@hs-heilbronn.deweb: http://www.mi.hs-heilbronn.de/ 

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

Posted by Richard Monson-Haefel <mo...@gmail.com>.
Thanks for looking into this, Richard!  (great name btw).

Would you be interested in subscribing to the users mailing list and
talking to him directly?  Here is where you subscribe if interested:

http://tomee.apache.org/mailing-lists.html

You can always unsubscribe after if you want.

On Mon, Oct 14, 2019 at 6:44 AM Zowalla, Richard <
richard.zowalla@hs-heilbronn.de> wrote:

> Hi,
>
> I tested the attached WAR with M2,M3 and RELEASE, results below:
>
> - M2: works as stated by the user
> - M3: Exception as stated below by the user
> - Release: same as M3 (exception as stated below).
>
> Source-code would be beneficial for debug purpose :)
>
> Best,
> Richard
>
>
>
> Am Montag, den 14.10.2019, 06:11 -0500 schrieb Richard Monson-Haefel:
>
> It would be great if someone in the community could take a quick look at
>
> this and report back.  It seems to be a bug, but I'm not sure.
>
>
> Anyone?
>
>
> ---------- Forwarded message ---------
>
> From: makkus <sa...@gmx.de>
>
> Date: Mon, Oct 14, 2019 at 5:14 AM
>
> Subject: CDI Principal injection: object is not an instance of declaring
>
> class
>
> To: <us...@tomee.apache.org>
>
>
>
> 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
> mail: richard.zowalla@hs-heilbronn.de
> web: http://www.mi.hs-heilbronn.de/
>


-- 
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/

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

Posted by Jonathan Gallimore <jo...@gmail.com>.
Also, do shout if you need any help.

Jon

On Mon, Oct 14, 2019 at 2:09 PM Jonathan Gallimore <
jonathan.gallimore@gmail.com> wrote:

> I did crack the .war file open - it looks like this is a JSF application
> that uses basic auth. The app uses a @RequestScoped bean which uses @Inject
> to get a Principal:
>
> @Named
> @RequestScoped
> public class PrincipalTest {
>   @Inject
>   private Principal principal;
>
>   public String userName() {
>     return this.principal.getName();
>   }
> }
>
> I suspect (but guessing) the MP-JWT Principal injection is having an
> impact on this.
>
> Jon
>
> On Mon, Oct 14, 2019 at 12:44 PM Zowalla, Richard <
> richard.zowalla@hs-heilbronn.de> wrote:
>
>> Hi,
>>
>> I tested the attached WAR with M2,M3 and RELEASE, results below:
>>
>> - M2: works as stated by the user
>> - M3: Exception as stated below by the user
>> - Release: same as M3 (exception as stated below).
>>
>> Source-code would be beneficial for debug purpose :)
>>
>> Best,
>> Richard
>>
>>
>>
>> Am Montag, den 14.10.2019, 06:11 -0500 schrieb Richard Monson-Haefel:
>>
>> It would be great if someone in the community could take a quick look at
>>
>> this and report back.  It seems to be a bug, but I'm not sure.
>>
>>
>> Anyone?
>>
>>
>> ---------- Forwarded message ---------
>>
>> From: makkus <sa...@gmx.de>
>>
>> Date: Mon, Oct 14, 2019 at 5:14 AM
>>
>> Subject: CDI Principal injection: object is not an instance of declaring
>>
>> class
>>
>> To: <us...@tomee.apache.org>
>>
>>
>>
>> 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
>> mail: richard.zowalla@hs-heilbronn.de
>> web: http://www.mi.hs-heilbronn.de/
>>
>

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

Posted by Jonathan Gallimore <jo...@gmail.com>.
I did crack the .war file open - it looks like this is a JSF application
that uses basic auth. The app uses a @RequestScoped bean which uses @Inject
to get a Principal:

@Named
@RequestScoped
public class PrincipalTest {
  @Inject
  private Principal principal;

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

I suspect (but guessing) the MP-JWT Principal injection is having an impact
on this.

Jon

On Mon, Oct 14, 2019 at 12:44 PM Zowalla, Richard <
richard.zowalla@hs-heilbronn.de> wrote:

> Hi,
>
> I tested the attached WAR with M2,M3 and RELEASE, results below:
>
> - M2: works as stated by the user
> - M3: Exception as stated below by the user
> - Release: same as M3 (exception as stated below).
>
> Source-code would be beneficial for debug purpose :)
>
> Best,
> Richard
>
>
>
> Am Montag, den 14.10.2019, 06:11 -0500 schrieb Richard Monson-Haefel:
>
> It would be great if someone in the community could take a quick look at
>
> this and report back.  It seems to be a bug, but I'm not sure.
>
>
> Anyone?
>
>
> ---------- Forwarded message ---------
>
> From: makkus <sa...@gmx.de>
>
> Date: Mon, Oct 14, 2019 at 5:14 AM
>
> Subject: CDI Principal injection: object is not an instance of declaring
>
> class
>
> To: <us...@tomee.apache.org>
>
>
>
> 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
> mail: richard.zowalla@hs-heilbronn.de
> web: http://www.mi.hs-heilbronn.de/
>

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

Posted by "Zowalla, Richard" <ri...@hs-heilbronn.de>.
Hi,
I tested the attached WAR with M2,M3 and RELEASE, results below:
- M2: works as stated by the user- M3: Exception as stated below by the
user- Release: same as M3 (exception as stated below).
Source-code would be beneficial for debug purpose :)
Best,Richard


Am Montag, den 14.10.2019, 06:11 -0500 schrieb Richard Monson-Haefel:
> It would be great if someone in the community could take a quick look
> atthis and report back.  It seems to be a bug, but I'm not sure.
> Anyone?
> ---------- Forwarded message ---------From: makkus <sancho-fx3@gmx.de
> >Date: Mon, Oct 14, 2019 at 5:14 AMSubject: CDI Principal injection:
> object is not an instance of declaringclassTo: <
> users@tomee.apache.org>
> 
> Hi Folks,
> in TomEE 8.0.0 there seems to be something wrong with the
> Principalinjection: 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@RequestScopedpublic class PrincipalTest {
>     @Inject    private Principal principal;
>     public String userName(){        return
> principal.getName();    }}
> Inside a  JSF page I can use "User Name: #{principalTest.userName()}"
> todisplay the user name. (See attached  leak2.war<
> http://tomee-openejb.979440.n4.nabble.com/file/t376354/leak2.war>   o
> rhttps://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
> declaringclass
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Nativ
> eMethod)
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Native
> MethodAccessorImpl.java:62)
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(De
> legatingMethodAccessorImpl.java:43)        java.base/java.lang.reflec
> t.Method.invoke(Method.java:566)
> org.apache.openejb.cdi.ManagedSecurityService$PrincipalInvocationHand
> ler.invoke(ManagedSecurityService.java:183)        com.sun.proxy.$Pro
> xy72.getName(Unknown
> Source)        leaktest.PrincipalTest.userName(PrincipalTest.java:25)
> leaktest.PrincipalTest$$OwbNormalScopeProxy0.userName(leaktest/Princi
> palTest.java)
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Nativ
> eMethod)
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Native
> MethodAccessorImpl.java:62)
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(De
> legatingMethodAccessorImpl.java:43)        java.base/java.lang.reflec
> t.Method.invoke(Method.java:566)        javax.el.BeanELResolver.invok
> e(BeanELResolver.java:158)...
> 
> Doese someone kow if this code is unsupported in 8.0.0 ? How can I
> get areference 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 SciencesMax-Planck-Str. 39 D-74081 Heilbronn phone: +49 7131 504 6791mail: richard.zowalla@hs-heilbronn.deweb: http://www.mi.hs-heilbronn.de/ 

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

Posted by Richard Monson-Haefel <mo...@gmail.com>.
It would be great if someone in the community could take a quick look at
this and report back.  It seems to be a bug, but I'm not sure.

Anyone?

---------- Forwarded message ---------
From: makkus <sa...@gmx.de>
Date: Mon, Oct 14, 2019 at 5:14 AM
Subject: CDI Principal injection: object is not an instance of declaring
class
To: <us...@tomee.apache.org>


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/

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

Posted by Jonathan Gallimore <jo...@gmail.com>.
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 <sa...@gmx.de> 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
>

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

Posted by Richard Monson-Haefel <mo...@gmail.com>.
Understood.

On Tue, Oct 15, 2019 at 7:38 AM makkus <sa...@gmx.de> 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/

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

Posted by makkus <sa...@gmx.de>.
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

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

Posted by COURTAULT Francois <fr...@thalesgroup.com>.
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:monsonhaefel@gmail.com]
Sent: mardi 15 octobre 2019 14:53
To: users@tomee.apache.org
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 < francois.courtault@thalesgroup.com> 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:monsonhaefel@gmail.com]
> Sent: mardi 15 octobre 2019 13:42
> To: users@tomee.apache.org
> 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 <sa...@gmx.de> 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.

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

Posted by Richard Monson-Haefel <mo...@gmail.com>.
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 <
francois.courtault@thalesgroup.com> 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:monsonhaefel@gmail.com]
> Sent: mardi 15 octobre 2019 13:42
> To: users@tomee.apache.org
> 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 <sa...@gmx.de> 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/

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

Posted by COURTAULT Francois <fr...@thalesgroup.com>.
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:monsonhaefel@gmail.com]
Sent: mardi 15 octobre 2019 13:42
To: users@tomee.apache.org
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 <sa...@gmx.de> 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.

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

Posted by Richard Monson-Haefel <mo...@gmail.com>.
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 <sa...@gmx.de> 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/

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

Posted by makkus <sa...@gmx.de>.
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