[jboss-user] [EJB3] - @PostConstruct not inoked in ear packaging

Tomas Bartalos do-not-reply at jboss.com
Thu Jun 30 07:10:58 EDT 2011

Tomas Bartalos [http://community.jboss.org/people/barti] created the discussion

"@PostConstruct not inoked in ear packaging"

To view the discussion, visit: http://community.jboss.org/message/612722#612722


I have a very basic problem. I have an ejb with *@PostConstruct annotated method*. When I deploy this ejb packaged as jar to jboss, everything works fine. 
But when I package my ejb to ear archive, the *@Postconstruct method is never invoked.*
This means there must be something wrong with my ear packaging, but I have no idea what is the problem.

Here follows my ejb:

public class TestBeanImpl implements TestBean{

    public TestBeanImpl() {
        System.out.println("Test bean was instantiated");

    public void afterConstruction() {
        System.out.println("Test bean after construction");

    public void performTest() {
        System.out.println("Test was performed");


When I invoke performTest() method in jar packaging, the output is:
Test bean was instantiated
Test was performed

*But when I invoke performTest() in ear packaging, the output is:*
Test bean was instantiated
Test bean after construction
Test was performed

Here follows my ear package structure:
-- lib

Here is my content of application.xml
<?xml version="1.0" encoding="UTF-8"?>

*My jboss version: Jboss 6.0.0.Final*

I really don't know what is wrong here, please help

Reply to this message by going to Community

Start a new discussion in EJB3 at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110630/87aab4d5/attachment.html 

More information about the jboss-user mailing list