1 Reply Latest reply on Nov 16, 2010 12:33 PM by Alexander Bell

    Entities and CDI

    Ryan Cuprak Newbie

      With CDI, is it possible to have a web form populate a JPA Entity and then persist it to the database? I am running into an issue where I get a java.lang.IllegalArgumentException: class_$$_javassist_92 exception when I go to persist. It is obvious that my instance is being "wrapped." I could add a clone method to my instance but that sounds gross and error prone. I wanted to use my annotations on the entities to drive both screen and database validation (trying to transition from Seam 2 to WELD). I have been googling and searching high and low for a solution to this problem. Another posting suggested using the @Producer method but that is also getting wrapped.


      Web form:
      <h:inputText size="25" required="true" value="#{member.firstname}"/>
      <h:commandButton value="Join" action="#{membershipBean.join(member)}"/>

      public class Member implements Serializable {

      Stateless Session Bean:
      public class MembershipBean {

          private EntityManager em;

          @Produces @Named @RequestScoped
          public Member getMember() {
              System.out.println("Producer CALLED----");
              return new Member();

           * Invoked for joining
          public String join(Member member) {
              System.out.println("Persisting: " + member);
              System.out.println("Classname: " + member.getClass().getName());
              return "welcome";


      Console output (System.outs):
      INFO: Creating a member.
      INFO: Producer CALLED----
      INFO: Creating a member.
      INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
      INFO: Producer CALLED----
      INFO: Creating a member.
      INFO: Persisting: asdf af
      INFO: Classname: org.ctjava.model.Member_$$_javassist_92
      WARNING: A system exception occurred during an invocation on EJB MembershipBean method public java.lang.String net.cuprak.ejb.MembershipBean.join(org.ctjava.model.Member)