aspose file tools*
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
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
Author

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

Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

Hi,

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
Greenhorn

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.


source:
http://www.163jsp.com/help/javaee50api/javax/annotation/PostConstruct.html

By.


SCJP 6.0, SCBCD 5.0, SCDJWS 5.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [JBoss 6.0 M1] EJB 3.0: @PostConstruct not called