You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by ApolloX <sc...@selikoff.net> on 2008/03/19 16:25:24 UTC
NullPointerException by MDB in getCurrentContext()
I'm running Geronimo 1.2-beta and am getting a NullPointerException
org.apache.geronimo.security.ContextManager.getCurrentContext() 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.
--
View this message in context: http://www.nabble.com/NullPointerException-by-MDB-in-getCurrentContext%28%29-tp16144723s134p16144723.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
Re: NullPointerException by MDB in getCurrentContext()
Posted by so...@apache.org.
On 3/19/08, ApolloX <sc...@selikoff.net> wrote:
> I'm running Geronimo 1.2-beta and am getting a NullPointerException
> org.apache.geronimo.security.ContextManager.getCurrentContext() 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
context.context.
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,
solprovider
Re: NullPointerException by MDB in getCurrentContext()
Posted by ApolloX <sc...@selikoff.net>.
djencks wrote:
> Can you post a stack trace?
Sure. See below. It seems to imply it might be a transactional attribute
issue, but the deployment descriptors are set up with transactional
attributes of "Required" so I still think its a Geronimo bug.
javax.ejb.TransactionRolledbackLocalException
at org.apache.openejb.transaction.TxRequired.invoke(TxRequired.java:64)
at
org.apache.openejb.transaction.TransactionPolicyInterceptor.invoke(TransactionPolicyInterceptor.java:50)
at
org.apache.openejb.NoConnectionEnlistingInterceptor.invoke(NoConnectionEnlistingInterceptor.java:68)
at
org.apache.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java:35)
at
org.apache.openejb.entity.cmp.DefaultCmpEjbContainer.invoke(DefaultCmpEjbContainer.java:150)
at
org.apache.openejb.entity.cmp.DefaultCmpEjbContainer$$FastClassByCGLIB$$e128ff0b.invoke(<generated>)
at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
at
org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
at
org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:122)
at
org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:820)
at org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
at
org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:35)
at
org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
at
org.apache.openejb.BmpEjbContainer$$EnhancerByCGLIB$$821fbd47.invoke(<generated>)
at
org.apache.openejb.AbstractEjbDeployment.invoke(AbstractEjbDeployment.java:195)
at
org.apache.openejb.proxy.EJBMethodInterceptor.intercept(EJBMethodInterceptor.java:145)
at
org.apache.openejb.proxy.EntityEJBLocalHome$$EnhancerByCGLIB$$a5fa9c5c.findAll(<generated>)
at com.mdb.BrokerBean.onMessage(MyMDB.java:215)
...
Caused by: java.lang.NullPointerException
at
org.apache.geronimo.security.ContextManager.getCurrentContext(ContextManager.java:167)
at
org.apache.openejb.security.EjbSecurityInterceptor.invoke(EjbSecurityInterceptor.java:65)
at
org.apache.openejb.security.EjbRunAsInterceptor.invoke(EjbRunAsInterceptor.java:50)
at
org.apache.openejb.security.PolicyContextHandlerEJBInterceptor.invoke(PolicyContextHandlerEJBInterceptor.java:64)
at
org.apache.openejb.naming.ComponentContextInterceptor.invoke(ComponentContextInterceptor.java:51)
at
org.apache.openejb.ConnectionTrackingInterceptor.invoke(ConnectionTrackingInterceptor.java:56)
at
org.apache.openejb.entity.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:110)
at
org.apache.openejb.entity.cmp.InTxCacheInterceptor.invoke(InTxCacheInterceptor.java:60)
at
org.apache.openejb.transaction.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:50)
at org.apache.openejb.transaction.TxRequired.invoke(TxRequired.java:60)
--
View this message in context: http://www.nabble.com/NullPointerException-by-MDB-in-getCurrentContext%28%29-tp16144723s134p16169955.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
Re: NullPointerException by MDB in getCurrentContext()
Posted by ApolloX <sc...@selikoff.net>.
Kevan Miller wrote:
> As David mentions, it's unlikely that you're going to generate too
> much attention for fixing a bug in 1.2-beta. You have a much better
> chance of getting our attention for a 2.0.x/2.1.x problem.
Actually when I searched Google for information about the bug, most of the
hits came up with this being a bug in 2.0 and 2.1.
--
View this message in context: http://www.nabble.com/NullPointerException-by-MDB-in-getCurrentContext%28%29-tp16144723s134p16171262.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
Re: NullPointerException by MDB in getCurrentContext()
Posted by Kevan Miller <ke...@gmail.com>.
On Mar 19, 2008, at 8:33 PM, ApolloX wrote:
<snip>
>
> We've gone off topic though, I have other posts (which no one has
> responded
> to) to discuss this:
>
> http://www.nabble.com/CMP2-on-G2---Delayed-Database-Flush-td15704963s134.html#a15704963
If we don't respond to an initial post within a couple of days, you
are more than welcom (encouraged, even) to post a followup with a
gentle nudge to the community. If necessary, followup that up with a
not-so-gentle nudge ;-). A single note can fall off our radar screen
(especially if our collective plates are full with other things, when
the note first shows up).
As David mentions, it's unlikely that you're going to generate too
much attention for fixing a bug in 1.2-beta. You have a much better
chance of getting our attention for a 2.0.x/2.1.x problem.
--kevan
Re: NullPointerException by MDB in getCurrentContext()
Posted by ApolloX <sc...@selikoff.net>.
djencks wrote:
> I talked with dain about this a little bit and his experience is that
> except for a couple of not-too-frequent and fixable situations
> (involving collections???) the jpa-based cmp2s are faster than the
> tranql ones in geronimo 1.x. Dain doesn't look at this mailing list
> much any more so I suggest you ask about this on the openejb lists.
I've mentioned what I think might be the problem, namely that I don't think
caching is enabled properly through JPA. Even though it's supposed to be
turned on by default, I've tried explicitly enabling it to now avail in the
config.xml file. One behavior that I noticed that leads me to this
conclusion is that in 1.X, ejbCreate would not hit the database immediately
after running. I could run create method (triggering an ejbCreate), then
set additional fields (marked as required in the DB) without any problems.
As soon as I moved to 2.X, all DB required fields had to be set in the
ejbCreate method or a SQL exception would be thrown.
Either way, the result is that the code works in G2.X but with extremely
slow performance along with the create errors as described above. I'm not
sure why anyone would think CMP2 would be faster in G2.X given the extra
layering involved.
We've gone off topic though, I have other posts (which no one has responded
to) to discuss this:
http://www.nabble.com/CMP2-on-G2---Delayed-Database-Flush-td15704963s134.html#a15704963
--
View this message in context: http://www.nabble.com/NullPointerException-by-MDB-in-getCurrentContext%28%29-tp16144723s134p16168613.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
Re: NullPointerException by MDB in getCurrentContext()
Posted by David Jencks <da...@yahoo.com>.
On Mar 19, 2008, at 4:24 PM, ApolloX wrote:
>
>
> djencks wrote:
>>
>> It would be a lot easier for us to investigate and possibly fix this
>> in a more current geronimo version such as 2.1.
>>
>
> I would like to but as I've mentioned in previous posts, the
> 'untested'
> support for CMP2 using JPA in 2.X versions of Geronimo leaves my
> application
> running at speeds 100s of times slower than they currently run at.
I talked with dain about this a little bit and his experience is that
except for a couple of not-too-frequent and fixable situations
(involving collections???) the jpa-based cmp2s are faster than the
tranql ones in geronimo 1.x. Dain doesn't look at this mailing list
much any more so I suggest you ask about this on the openejb lists.
>
>
> djencks wrote:
>>
>> While this is almost certainly a bug -- you should only be able to
>> access unchecked methods from a mdb without additional configuration
>> -- I think there is a way to configure a default principal or
>> default
>> subject or default role that would supply the missing Subject.
>>
>
> I've checked, there is a message context, but I'm guessing its a
> context on
> another layer thats broken. Interestingly, I can make session bean
> calls
> using a transaction from within the MDB, so right now I have the
> MDB taking
> to local session bean that can access entity objects. Not a great
> solution,
> but it works.
Can you post a stack trace?
I think I remember that in 2.x I have an empty, registered Subject so
that there is always a "unauthenticated" user with no checked
permissions, and that I added this so you wouldn't get into
situations like this. Can you show your security configuration in
the openejb-jar.xml? It might help to see if something can be
configured as a default subject.
thanks
david jencks
> --
> View this message in context: http://www.nabble.com/
> NullPointerException-by-MDB-in-getCurrentContext%28%29-
> tp16144723s134p16161205.html
> Sent from the Apache Geronimo - Users mailing list archive at
> Nabble.com.
>
Re: NullPointerException by MDB in getCurrentContext()
Posted by ApolloX <sc...@selikoff.net>.
djencks wrote:
>
> It would be a lot easier for us to investigate and possibly fix this
> in a more current geronimo version such as 2.1.
>
I would like to but as I've mentioned in previous posts, the 'untested'
support for CMP2 using JPA in 2.X versions of Geronimo leaves my application
running at speeds 100s of times slower than they currently run at.
djencks wrote:
>
> While this is almost certainly a bug -- you should only be able to
> access unchecked methods from a mdb without additional configuration
> -- I think there is a way to configure a default principal or default
> subject or default role that would supply the missing Subject.
>
I've checked, there is a message context, but I'm guessing its a context on
another layer thats broken. Interestingly, I can make session bean calls
using a transaction from within the MDB, so right now I have the MDB taking
to local session bean that can access entity objects. Not a great solution,
but it works.
--
View this message in context: http://www.nabble.com/NullPointerException-by-MDB-in-getCurrentContext%28%29-tp16144723s134p16161205.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
Re: NullPointerException by MDB in getCurrentContext()
Posted by David Jencks <da...@yahoo.com>.
It would be a lot easier for us to investigate and possibly fix this
in a more current geronimo version such as 2.1. Getting any updates
out for 1.2 is going to be difficult, slow, and unlikely.
While this is almost certainly a bug -- you should only be able to
access unchecked methods from a mdb without additional configuration
-- I think there is a way to configure a default principal or default
subject or default role that would supply the missing Subject.
thanks
david jencks
On Mar 19, 2008, at 8:25 AM, ApolloX wrote:
>
> I'm running Geronimo 1.2-beta and am getting a NullPointerException
> org.apache.geronimo.security.ContextManager.getCurrentContext() 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.
> --
> View this message in context: http://www.nabble.com/
> NullPointerException-by-MDB-in-getCurrentContext%28%29-
> tp16144723s134p16144723.html
> Sent from the Apache Geronimo - Users mailing list archive at
> Nabble.com.
>