You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Shawn Jiang <ge...@gmail.com> on 2011/04/12 08:36:49 UTC

NPE for a mdb.

Hi devs,


I met a NPE in

org.apache.openejb.assembler.classic.EjbJarBuilder.build(EjbJarInfo,
List<Injection>) {
...
Container container = (Container) props.get(ejbInfo.containerId);   //
containerId is null here
...
}


I tried to find when containerId is set.   and find it's here:

org.apache.openejb.config.AutoConfig.deploy(EjbModule, AppResources) {
...

 if (ejbDeployment.getContainerId() == null && !skipMdb(bean)) {
                String containerId = getUsableContainer(containerInfoType,
bean, appResources);
                if (containerId == null){
                    containerId = createContainer(containerInfoType,
ejbDeployment, bean);
                }
                ejbDeployment.setContainerId(containerId);
            }
...

}


The problem is that when using openejb in geronimo.   skipMdb(bean)  will
always return true if bean is a MDB.    So that the containerId does not
have a chance to be set at all.  The logic of skipMdb is:

 private static boolean skipMdb(Object bean) {
        return bean instanceof MessageDrivenBean &&
SystemInstance.get().hasProperty("openejb.geronimo");
    }


Any thoughts why we don't set the containerId for MDB from openejb side when
working with geronimo ?



-- 
Shawn

Re: NPE for a mdb.

Posted by David Blevins <da...@gmail.com>.
On Tue, Apr 12, 2011 at 8:36 AM, Shawn Jiang <ge...@gmail.com> wrote:
> Hi devs,
>
>
> I met a NPE in
>
> org.apache.openejb.assembler.classic.EjbJarBuilder.build(EjbJarInfo,
> List<Injection>) {
> ...
> Container container = (Container) props.get(ejbInfo.containerId);   //
> containerId is null here
> ...
> }
>
>
> I tried to find when containerId is set.   and find it's here:
>
> org.apache.openejb.config.AutoConfig.deploy(EjbModule, AppResources) {
> ...
>
>  if (ejbDeployment.getContainerId() == null && !skipMdb(bean)) {
>                String containerId = getUsableContainer(containerInfoType,
> bean, appResources);
>                if (containerId == null){
>                    containerId = createContainer(containerInfoType,
> ejbDeployment, bean);
>                }
>                ejbDeployment.setContainerId(containerId);
>            }
> ...
>
> }
>
>
> The problem is that when using openejb in geronimo.   skipMdb(bean)  will
> always return true if bean is a MDB.    So that the containerId does not
> have a chance to be set at all.  The logic of skipMdb is:
>
>  private static boolean skipMdb(Object bean) {
>        return bean instanceof MessageDrivenBean &&
> SystemInstance.get().hasProperty("openejb.geronimo");
>    }
>
>
> Any thoughts why we don't set the containerId for MDB from openejb side when
> working with geronimo ?

I seem to recall that was because Geronimo controls all connector
deployment and as an extension wanted to control MDB container
creation.  IIRC the MDB Container is created on the Geronimo side when
a Connector is deployed and the name of the container is predictable
-- something like {connectorName}-{messageListenerInterface}.

The "props.get(ejbInfo.containerId)" line is from 2007 as is all the
skipMdb stuff, so it seems all this worked at one point and broke
recently.  Might be worthwhile to launch off a 2.2.1 server on debug
and see when the Container value is added to the properties object
used in EjbJarBuilder.

-David

Re: NPE for a mdb.

Posted by Shawn Jiang <ge...@gmail.com>.
Can anyone shed some light on this ?

On Tue, Apr 12, 2011 at 2:36 PM, Shawn Jiang <ge...@gmail.com> wrote:

> Hi devs,
>
>
> I met a NPE in
>
> org.apache.openejb.assembler.classic.EjbJarBuilder.build(EjbJarInfo,
> List<Injection>) {
> ...
> Container container = (Container) props.get(ejbInfo.containerId);   //
> containerId is null here
> ...
> }
>
>
> I tried to find when containerId is set.   and find it's here:
>
> org.apache.openejb.config.AutoConfig.deploy(EjbModule, AppResources) {
> ...
>
>  if (ejbDeployment.getContainerId() == null && !skipMdb(bean)) {
>                 String containerId = getUsableContainer(containerInfoType,
> bean, appResources);
>                 if (containerId == null){
>                     containerId = createContainer(containerInfoType,
> ejbDeployment, bean);
>                 }
>                 ejbDeployment.setContainerId(containerId);
>             }
> ...
>
> }
>
>
> The problem is that when using openejb in geronimo.   skipMdb(bean)  will
> always return true if bean is a MDB.    So that the containerId does not
> have a chance to be set at all.  The logic of skipMdb is:
>
>  private static boolean skipMdb(Object bean) {
>         return bean instanceof MessageDrivenBean &&
> SystemInstance.get().hasProperty("openejb.geronimo");
>     }
>
>
> Any thoughts why we don't set the containerId for MDB from openejb side
> when working with geronimo ?
>
>
>
> --
> Shawn
>



-- 
Shawn