users@glassfish.java.net

Re: Curious about this -- any explanation?

From: Sivakumar Thyagarajan <Sivakumar.Thyagarajan_at_Sun.COM>
Date: Wed, 06 Oct 2010 08:56:12 +0530

On Tuesday 05 October 2010 09:33 PM, Dominik Dorn wrote:
>> It looks like the constructor is being executed twice on the same object -- is this possibly true as some side-effect of CDI?
> Yes. You should create constructors that don't do anything and put
> every initialization logic into a method annotated with
> @PostConstruct
>
> Also you should switch from System.out.println to a logger (e.g. Log4J)
> as System.out.println will slow down your system in production.

To add more information to why the constructor is executed twice for
normal-scoped CDI beans, please also see the discussion at [1]

Thanks
--Siva.
[1]
http://weld-development-discussions.46994.n3.nabble.com/Bean-created-twice-tt987853.html#a994358
and http://www.seamframework.org/Community/BeanCreatedTwice
>
> kind regards,
> dominik