JBoss Community

@PostConstruct not inoked in ear packaging

created by Tomas Bartalos in EJB3 - View the full discussion

Hi,

 

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:

 

@Stateless

public class TestBeanImpl implements TestBean{

 

    public TestBeanImpl() {

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

    }

   

    @PostConstruct

    public void afterConstruction() {

        System.out.println("Test bean after construction");

    }

   

    @Override

    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

--META-INF

     /--application.xml

--postconstruct-test-ejb.jar

 

Here is my content of application.xml

<?xml version="1.0" encoding="UTF-8"?>

<application>

  <display-name>postconstruct-test-ear</display-name>

  <module>

    <ejb>postconstruct-test-ejb.jar</ejb>

  </module>

</application>

 

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