geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: NullPointerException by MDB in getCurrentContext()
Date Wed, 19 Mar 2008 22:55:08 GMT
On 3/19/08, ApolloX <> wrote:
>  I'm running Geronimo 1.2-beta and am getting a NullPointerException
> at line 167
>  when an MDB tries to access a finder method on a CMP bean.
>  I don't believe this problem existed in 1.1, as I don't recall seeing it
>  before we upgraded 1.2-beta.  Where the code crashes it appears to be
>  skipping the previous assertion that said "No registered context".  Why an
>  MDB would not have a proper context?  It's declared in the ejb-jar.xml and
>  geronimo.xml with resources, references to local EJBs, etc.

The assert verifies context is not null.  The error is from accessing
The null value is likely set in the fourth line of registerSubject(subject):

AccessControlContext acc = (AccessControlContext)
Subject.doAsPrivileged(subject, new PrivilegedAction() {
            public Object run() {
                return AccessController.getContext();
        }, null);

No code validates that acc is not null.

The null may need to be cast for the return value:
    public static AccessControlContext getCurrentContext() {
        return (AccessControlContext) context.context;

Dangerous, but you might also try:
    public static AccessControlContext getCurrentContext() {
        if(null == context.context) return AccessController.getContext();
        return context.context;

Hoping these suggestions do no permanent damage,

View raw message