You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Richard Monson-Haefel <mo...@gmail.com> on 2019/10/14 11:11:58 UTC

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

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: 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 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 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/