2 Replies Latest reply on Dec 16, 2008 1:14 PM by Vitor Souza

    The @Create annotation is not working on POJOs (non-EJBs)

    Vitor Souza Newbie

      Using Seam 2.1.1.CR2.

      In my Seam application I have this bean:

      public class CreatePojoTest {
              String message = "init() HAS NOT been executed!";
              private void init() { message = "init() HAS been executed!"; }
              public String getMessage() { return message; }

      And in a JSF page, I pring the message with a <h:outputText value="#{createPojoTest.message}" />. However, I keep getting this exception:

      org.jboss.seam.InstantiationException: Could not instantiate Seam component: createPojoTest
              at org.jboss.seam.Component.newInstance(Component.java:2106)
      Caused by: java.lang.IllegalArgumentException: method not found: init for component: createPojoTest
              at org.jboss.seam.Component.callComponentMethod(Component.java:2229)
              at org.jboss.seam.Component.callCreateMethod(Component.java:2134)
              at org.jboss.seam.Component.newInstance(Component.java:2094)
              ... 70 more
      Caused by: java.lang.NoSuchMethodException: br.com.engenhodesoftware.sigme.core.controller.CreatePojoTest_$$_javassist_13.init()
              at java.lang.Class.getMethod(Class.java:1605)
              at org.jboss.seam.Component.callComponentMethod(Component.java:2208)
              ... 72 more

      If I remove the @Create annotation, I get no exception, but the init() method is obviously not called and I get the "init() HAS NOT been executed!" message in the web page.

      As I understood from Seam's documentation (section 4.4), @Create and @Destroy are provided as replacements for EJB 3.0 lifecycle callback methods so it can be used in normal POJOs. Did I misunderstand something?

      What should I do to fix this?

      Thank you,