[jboss-jira] [JBoss JIRA] Commented: (EJBTHREE-615) Nullpointer exception in Embedded Jboos when getCallerPrincipal method on SessionContext

Daniel Young (JIRA) jira-events at jboss.com
Tue Jan 16 00:51:58 EST 2007


    [ http://jira.jboss.com/jira/browse/EJBTHREE-615?page=comments#action_12350853 ] 
            
Daniel Young commented on EJBTHREE-615:
---------------------------------------

I have what is possibly the same issue when using context.isCallerInRole("ROLE") or role-annotations on an EJB. 

My stacktrace when calling context.isCallerInRole():
java.lang.NullPointerException
	at org.jboss.security.plugins.JBossAuthorizationManager.getPrincipal(JBossAuthorizationManager.java:312)
	at org.jboss.security.plugins.JaasSecurityManager.getPrincipal(JaasSecurityManager.java:361)
	at org.jboss.ejb3.BaseSessionContext.getCallerPrincipal(BaseSessionContext.java:177)
	at org.jboss.ejb3.BaseSessionContext.isCallerInRole(BaseSessionContext.java:195)
	at com.synyati.spurwing.location.business.LocationServiceBean.findCountries(LocationServiceBean.java:50)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:121)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:110)
....

When using an annotation, it comes from the RoleBasedAuthorizationInterceptor:
java.lang.NullPointerException
	at org.jboss.security.Util.getSubjectRoles(Util.java:631)
	at org.jboss.security.plugins.JBossAuthorizationManager.getCurrentRoles(JBossAuthorizationManager.java:562)
	at org.jboss.security.plugins.JBossAuthorizationManager.doesUserHaveRole(JBossAuthorizationManager.java:241)
	at org.jboss.security.plugins.JaasSecurityManager.doesUserHaveRole(JaasSecurityManager.java:384)
	at org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:143)
	at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:108)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
	at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:211)
	at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
	at $Proxy65.saveCountry(Unknown Source)
	at com.synyati.spurwing.location.business.LocationServiceTest.testSaveCountryNewCountryNormalUser(LocationServiceTest.java:62)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
	at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
	at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
	at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
	at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
	at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
	at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
	at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
	at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
	at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)




> Nullpointer exception in Embedded Jboos when getCallerPrincipal method on SessionContext
> ----------------------------------------------------------------------------------------
>
>                 Key: EJBTHREE-615
>                 URL: http://jira.jboss.com/jira/browse/EJBTHREE-615
>             Project: EJB 3.0
>          Issue Type: Bug
>    Affects Versions: EJB 3.0 RC8 - FD
>            Reporter: Nicolai ?dum
>
> The bug is pretty easy to create.
> Modify the CalculaterBean in the security example that is distributed with JBoss embedded like this
> import javax.annotation.Resource;
> import java.security.Principal;
> import javax.ejb.SessionContext;
> ..
> public class CalculatorBean implements Calculator
> {
> @Resource SessionContext ctx;	
> @RolesAllowed({"student"})
> public int subtract(int x, int y)
> {
> Principal caller = ctx.getCallerPrincipal(); //Nullpointer
> return x - y;
> }
> The exception
> full stacktrace: 
> javax.ejb.EJBException: java.lang.NullPointerException 
> at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69) 
> at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83) 
> at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197) 
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) 
> at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) 
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) 
> at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62) 
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) 
> at org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:167) 
> at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:100) 
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) 
> at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78) 
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) 
> at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) 
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) 
> at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) 
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) 
> at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:181) 
> at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79) 
> at $Proxy15.getSubscriberDetails(Unknown Source) 
> Another user has reported that is is possible to get the principal from org.jboss.security.SecurityAssociation.getPrincipal(), but not from the Session Context.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list