You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Christian Bourque <ch...@gmail.com> on 2010/09/21 20:19:24 UTC

embedded restart & resources cleanup

Hi,

I have a problem with some unit tests who need to start/stop the embedded
container in the same JVM instance. I have a singleton EJB which uses a
connection factory via injection:

@Singleton
@Startup
public class DummyResourceBean
{
    @Resource
    private ConnectionFactory connectionFactory;

    ...
}

When the container is restarted with a fresh InitialContext I get the
following error:

javax.naming.NamingException: Cannot instantiate a LocalInitialContext.
Exception: java.lang.NullPointerException null [Root exception is
java.lang.NullPointerException]
        at
org.apache.openejb.client.LocalInitialContextFactory.getLocalInitialContext(LocalInitialContextFactory.java:98)
        at
org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:43)
        ...
Caused by: java.lang.NullPointerException
        at
org.apache.openejb.client.LocalInitialContext.getRoot(LocalInitialContext.java:165)
        at
org.apache.openejb.client.LocalInitialContext.getContainerSystemEjbContext(LocalInitialContext.java:158)
        at
org.apache.openejb.client.LocalInitialContext.<init>(LocalInitialContext.java:64)
        ...

If I remove the connection factory reference from my resource bean it works!

It looks like the resource is not correctly cleaned after the first
shutdown...

NOTE: To shutdown the container I'm using this system property:
openejb.embedded.initialcontext.close=DESTROY

Thanks

Christian

Re: embedded restart & resources cleanup

Posted by David Blevins <da...@visi.com>.
On Sep 21, 2010, at 11:19 AM, Christian Bourque wrote:

> Hi,
> 
> I have a problem with some unit tests who need to start/stop the embedded
> container in the same JVM instance. I have a singleton EJB which uses a
> connection factory via injection:
> 
> @Singleton
> @Startup
> public class DummyResourceBean
> {
>    @Resource
>    private ConnectionFactory connectionFactory;
> 
>    ...
> }
> 
> When the container is restarted with a fresh InitialContext I get the
> following error:
> 
> javax.naming.NamingException: Cannot instantiate a LocalInitialContext.
> Exception: java.lang.NullPointerException null [Root exception is
> java.lang.NullPointerException]
>        at
> org.apache.openejb.client.LocalInitialContextFactory.getLocalInitialContext(LocalInitialContextFactory.java:98)
>        at
> org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:43)
>        ...
> Caused by: java.lang.NullPointerException
>        at
> org.apache.openejb.client.LocalInitialContext.getRoot(LocalInitialContext.java:165)
>        at
> org.apache.openejb.client.LocalInitialContext.getContainerSystemEjbContext(LocalInitialContext.java:158)
>        at
> org.apache.openejb.client.LocalInitialContext.<init>(LocalInitialContext.java:64)
>        ...
> 
> If I remove the connection factory reference from my resource bean it works!
> 
> It looks like the resource is not correctly cleaned after the first
> shutdown...
> 
> NOTE: To shutdown the container I'm using this system property:
> openejb.embedded.initialcontext.close=DESTROY

If you have anything that can reproduce this -- maybe a tweaked example -- that would be a great time saver.  


-David