Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread agumbrecht
If I understand correctly I think you are trying to share state between multiple apps in the same runtime. I've always found JMX meets this criteria nicely. Andy. - -- Andy Gumbrecht http://www.tomitribe.com agumbre...@tomitribe.com https://twitter.com/AndyGeeDe T

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Romain Manni-Bucau
Le 10 oct. 2017 15:14, "Paul Carter-Brown" a écrit : Hi Romain, mmm this really throws a spanner in the works. So let's say I have an EAR with many WARs and I have a jar which provides shared functionality to the WARs. In the jar are classes that are expensive to initialise and consume a lot of

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Matthew Broadhead
you could consider using a rest interface to get shared data across webapps?  i generally deploy the lib per webapp where i have a shared lib.  the data can be loaded from a single shared rest interface. On 10/10/2017 16:13, Paul Carter-Brown wrote: Hi Romain, mmm this really throws a spanner

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Paul Carter-Brown
Hi Romain, mmm this really throws a spanner in the works. So let's say I have an EAR with many WARs and I have a jar which provides shared functionality to the WARs. In the jar are classes that are expensive to initialise and consume a lot of memory. I hoped that putting the jar in EAR/lib and s

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Romain Manni-Bucau
Le 10 oct. 2017 14:26, "Paul Carter-Brown" a écrit : Hi, I've used @ApplicationScoped and @javax.inject.Singleton and both have the same behaviour. Seems like webbeans considers both to be Singleton as they are stored in the singleton context. Yes, was just a side note for other behaviors.

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Paul Carter-Brown
Hi, I've used @ApplicationScoped and @javax.inject.Singleton and both have the same behaviour. Seems like webbeans considers both to be Singleton as they are stored in the singleton context. In terms of the behaviour of these in an EAR: https://issues.jboss.org/browse/CDI-129 Doing more researc

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Romain Manni-Bucau
But with skinny wars you still get it in the webapp loader and lib part right ? It is not about physical model but resolved one. Le 10 oct. 2017 14:11, "Paul Carter-Brown" a écrit : Hi Romain, Correct me if I'm wrong but my understanding is that an EAR with shared library jars should be conside

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Paul Carter-Brown
Hi Romain, Correct me if I'm wrong but my understanding is that an EAR with shared library jars should be considered as a single application. If a class exists in a single jar and a single classloader and is marked as a singleton then is it wrong to expect it to only be constructed once by CDI? I

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Romain Manni-Bucau
That is what I had in mind and it matches the classloader model of skinny wars I think so it looks like it works as intended - as thought I mean. Side note: you surely meant @ApplicationScoped more than singleton. Le 10 oct. 2017 13:44, "Paul Carter-Brown" a écrit : > Hi Romain, > > As a non-s

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Paul Carter-Brown
Hi Romain, As a non-static it is different on each call. The singleton is being constructed twice within the same classloader. I did some more digging and debugging and can see that 2 singleton contexts are being created in CDI by two different initialisation flows that both end up at org.apache.

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Romain Manni-Bucau
And removing the static? Le 10 oct. 2017 11:45, "Paul Carter-Brown" < paul.carter-br...@opposablethumbs.io> a écrit : > Hi Andy/Romain, > > I'll load on github today and create a ticket. > > I have verified that it is a single instance by having a static > initializer: private static final String

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Paul Carter-Brown
Hi Andy/Romain, I'll load on github today and create a ticket. I have verified that it is a single instance by having a static initializer: private static final String uuid = UUID.randomUUID().toString(); The uuid remains the same on both calls to the postconstruct method Paul On Tue, Oct 10,

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Paul Carter-Brown
Hi, The use of plain CDI is intentional in this case. I don't need an EJB. Interestingly enough I did a test by changing the singleton to a javax.ejb.Singleton and using "@EJB" in the servlet. With the EJB packaged with "skinny war" the injection failed with an NPR when trying to use the EJB: 2017

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-10 Thread Helge Waastad
PS, are U sure you wanna use javax.inject.Singleton? Maybe javax.ejb.Singleton? /hw ti., 10.10.2017 kl. 08.34 +0200, skrev Paul Carter-Brown: > Hi, > > Loaded on github and created ticket: > > https://issues.apache.org/jira/browse/TOMEE-2134 > > On 10 October 2017 at 07:56, Romain Manni-Bucau

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-09 Thread Paul Carter-Brown
Hi, Loaded on github and created ticket: https://issues.apache.org/jira/browse/TOMEE-2134 On 10 October 2017 at 07:56, Romain Manni-Bucau wrote: > Hi Paul, > > Did you check the instance - identity hashcode for instance? I wonder if it > is not 2 instances triggered on the same event. > > Othe

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-09 Thread Romain Manni-Bucau
Hi Paul, Did you check the instance - identity hashcode for instance? I wonder if it is not 2 instances triggered on the same event. Otherwise Andy is fully right in terms of enabling us to help you. Le 10 oct. 2017 01:25, "Andy Gumbrecht" a écrit : > Hi Paul, > > In the interest of safety fir

Re: @PostConstruct called twice on @javax.inject.Singleton

2017-10-09 Thread Andy Gumbrecht
Hi Paul, In the interest of safety first, and benefit second, please create a ticket here: https://issues.apache.org/jira/projects/TOMEE Rather than attaching a ZIP here, please consider creating a GitHub project and sharing it in the ticket. Thanks, Andy. On 09/10/17 15:00, Paul Carter-B