4 Replies Latest reply on Dec 11, 2013 6:10 AM by marius.gerwinn

    @PostConstruct not been called

    jose.alejandro

      I'm trying to write a proof of concept using errai-ui and errai-ioc. So I have my @EntryPoint  where I'm injecting the RootPanel and a @Templated composite. The problem is that the @EntryPoint @PostConstruc method is not been called, I'm not getting any errors in the browser and it looks like the ioc container gets initialized since I see the logs in the browser console.


      In the docs it says

      Errai only scans the contents of classpath locations (JARs and directories) that have a file called ErraiApp.properties at their root. If dependency injection is not working for you, double-check that you have an ErraiApp.properties in every JAR and directory that contains classes Errai should know about.

      So I put an ErraiApp.properties in src/main/resources/ but that didn't work. So I manually copied the file in the root of the war file, copied it also in WEB-INF/classes but I really don't know exactly in which part of the war it is supposed to end, and I don't see any errors anywhere, the page just loads blank.

       

      I'll appreciate a lot any help, thank you.

       

      -- update --

      I fixed some errors with a junit servlet that the eclipse plugin was complaining for but nothing. Debugging org.jboss.errai.ioc.client.Container (to check the 15 beans it says are been loaded) I see a map which have the RootPanelProvider and others, is it supposed to contain my managed beans? I mean, if I have a class annotated with @EntryPoint, should I see it in that map?

       

      Maybe I could debug the code generator or something to see why it is not picking my class, is it possible?

       

      -- update --

      The problem was that I had an injection point to a class outside the client directory of the gwt module, everything is working now.

        • 1. Re: @PostCosntruct not been called
          mbarkley

          Hey Jose,

           

          So just to confirm: you have a class annotated with @EntryPoint, in a package *.client.local.*, with a method annotated with @PostConstruct, and you have an ErraiApp.properties in your src/main/resource directory.

           

          Have you verified that the entrypoint class is being instantiated? If not, can you try putting print statement in the beans constructor and seeing if the constructor is invoked?

          1 of 1 people found this helpful
          • 2. Re: @PostCosntruct not been called
            jose.alejandro

            Ok, so I was trying too many things at the same time because injecting the RootPanel alone and adding a dummy label works, the @PostConstruct gets called. The thing is that I'm trying the Presenter First approach for mvp where you have to write a presenter only using interfaces of the views and model. So, I have an interface on top of my @Templated class which would be my view implementation.

             

            When I injected the view interface in my presenter I was hoping for errai to do some magic   and pick up my @Templated implementation, which didn't work of course, and that experiment was the problem. I'll try to write a provider to make it work. The weird thing is that if I uncomment the interface injection it stops working but there is not erros in the console.

            • 3. Re: @PostConstruct not been called
              jose.alejandro

              Now it works! I didn't had to write a provider, actually the interface thing with the @Tamplated as implementation works very well. The problem was just that I was trying to inject my model from outside the client directory of the gwt module so... layer 8?

               

              And my tests are working with jukito! you guys have made a great work, thank you for the help. Probably I will be back very soon asking more questions.

              • 4. Re: @PostConstruct not been called
                marius.gerwinn

                The problem was that I had an injection point to a class outside the client directory of the gwt module, everything is working now.

                We running into the same problem from time to time. Especially when refactoring the codebase. The IOC generators does not produce a sufficient log for this problem.

                Meanwhile the maven compiler (logLevel=TRACE) shows some warning for not reachable class.

                 

                Some more specific logging that points to the specific error would be a major improvement.