Hi Jon

Side note before digging: you can rewrite the test this way (i find it
easier to enter in but surely personal):
https://gist.github.com/rmannibucau/86152958d9c139a45d4d80adbcc2c653

Now about the issue: if i get it right issue is we lookup the instance and
therefore unwrap the holder with predestroy info. So fix is just about
reading the raw wrapper (we don't have references of references of
references with resource so it is safe) and just destroy the holder.

Personally I'm very tempted to go away from the JNDI tree for the storage
of these metadata and just put them in the AppContext (resources list?) to
avoid to mess up wrappings/unwrapping like we do today and have a straight
implmentation. Then the JNDI interaction is a plain unbind but the app
resource lifecycle management is not relying on jndi by itself (like EJBs).


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2017-07-13 12:58 GMT+02:00 Jonathan Gallimore <[email protected]>
:

> Ooo, interesting. Thanks Svetlin! I'll add a test case for that as well and
> adjust.
>
> Cheers!
>
> Jon
>
> On Thu, Jul 13, 2017 at 11:54 AM, Svetlin Zarev <
> [email protected]> wrote:
>
> > Hi,
> >
> > I'm not sure what will happen if the IvmContext is in read-only mode
> (i.e.
> > openejb.forceReadOnlyAppNamingContext=true). You may-need to make the
> > context writable before unbinding.
> >
> > Svetlin
> >
> >
> > 2017-07-13 13:46 GMT+03:00 Jonathan Gallimore <
> > [email protected]>
> > :
> >
> > > Hey folks
> > >
> > > I noticed an issue when creating a resource inside an application:
> > >
> > > package org.superbiz;
> > >
> > >
> > > import javax.annotation.PostConstruct;
> > > import javax.annotation.PreDestroy;
> > > import java.util.logging.Logger;
> > >
> > > public class Startup {
> > >
> > >     private final Logger log = Logger.getLogger(Startup.
> > class.getName());
> > >
> > >     @PostConstruct
> > >     public void start() {
> > >         log.info("*** " + getClass().getName() + " started ***");
> > >     }
> > >
> > >     @PreDestroy
> > >     public void stop() {
> > >         log.info("*** " + getClass().getName() + " stopped ***");
> > >     }
> > >
> > > }
> > >
> > > and using WEB-INF/resources.xml to create the resource:
> > >
> > > <resources>
> > >     <Resource id="Startup" class-name="org.superbiz.Startup">
> > >         # any properties you need can go here
> > >     </Resource>
> > > </resources>
> > >
> > > It looks like my @PostConstruct is called ok, but my @PreDestroy is
> not.
> > I
> > > believe this works ok with resources defined in tomee.xml, but I'm
> happy
> > to
> > > check.
> > >
> > > I dug a bit deeper, and wrote a test. This appears to be an issue on
> both
> > > master and 1.7.x. I have created two PRs, and would appreciate any
> > > thoughts.
> > >
> > > https://github.com/apache/tomee/pull/91
> > > https://github.com/apache/tomee/pull/92
> > >
> > > Many thanks
> > >
> > > Jon
> > >
> >
>

Reply via email to