You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Richard Zowalla (Jira)" <ji...@apache.org> on 2019/10/14 11:54:00 UTC

[jira] [Created] (TOMEE-2709) CDI Principal injection: object is not an instance of declaring class

Richard Zowalla created TOMEE-2709:
--------------------------------------

             Summary: CDI Principal injection: object is not an instance of declaring class
                 Key: TOMEE-2709
                 URL: https://issues.apache.org/jira/browse/TOMEE-2709
             Project: TomEE
          Issue Type: Bug
    Affects Versions: 8.0.0-Final, 8.0.0-M3
            Reporter: Richard Zowalla


Copied from the Mailing-List:

{quote}---------- 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{quote}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)