File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes [JBoss 6.0 M1]  EJB 3.0: @PostConstruct not called Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "[JBoss 6.0 M1]  EJB 3.0: @PostConstruct not called" Watch "[JBoss 6.0 M1]  EJB 3.0: @PostConstruct not called" New topic

[JBoss 6.0 M1] EJB 3.0: @PostConstruct not called

Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 549


I have a pretty weird and basic problem.
I have 2 session beans. One is stateful, the other one is stateless.
Both have a method which is annotated with @PostConstruct :

None returns the logs and the new value of myVar.
How come ? The @PostConstruct annotation is used to annotate a method that should be called after instantiation.
Edit :
Never mind, fixed it, the method should return void of course !

SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCBCD 5
Visit my blog
Yair Ivan

Joined: Jul 13, 2008
Posts: 15

Hi Celinio:

The method on which the PostConstruct annotation is applied MUST fulfill all of the following criteria:

- The method MUST NOT have any parameters except in the case of EJB interceptors in which case it takes
an InvocationContext object as defined by the EJB specification.

- The return type of the method MUST be void.

- The method MUST NOT throw a checked exception.

- The method on which PostConstruct is applied MAY be public, protected, package private or private.

- The method MUST NOT be static except for the application client.

- The method MAY be final.

- If the method throws an unchecked exception the class MUST NOT be put into service except in
the case of EJBs where the EJB can handle exceptions and even recover from them.



SCJP 6.0, SCBCD 5.0, SCDJWS 5.0
I agree. Here's the link:
subject: [JBoss 6.0 M1] EJB 3.0: @PostConstruct not called
It's not a secret anymore!