1 Reply Latest reply on Jun 30, 2011 8:18 AM by Tomas Bartalos

    @PostConstruct not invoked in ear packaging

    Tomas Bartalos Newbie



      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 bean after construction

      Test was performed


      But when I invoke performTest() in ear packaging, the output is:

      Test bean was instantiated

      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

        • 1. Re: @PostConstruct not inoked in ear packaging
          Tomas Bartalos Newbie

          So finally I've found the solution. The problem was in included library jsr250-api-1.0.jar.

          I used maven for building and this library was transitive dependency of resteasy-jaxrs lib.

          I marked this lib as provided and now the @PostConstruct works.

          But anyway its a strange behavior from jboss side, because there was no error message in logs, only the postcontruct simply stopped working.