1 Reply Latest reply on Feb 17, 2009 11:29 AM by Peter Johnson

    org.jboss.seam.InstantiationException: Could not instantiate

    Venkatraman Pattabiraman Newbie

      Hi,

      I'm a newbie to JSF/JBOSS/EJB3.0

      I did the setup correctly and was able to load the jsp pages.

      I created a Session Bean,entity bean and two xhtml pages.

      When i try to enter the details and click submit button, i'm getting Instantiationexception when invoking the session bean.

      Can anybody help me out.

      SessionBean:

      @Stateless
      @Name("registerSessionBean")
      public class RegisterSessionBean implements Register{

      @In
      private UsersImpl users;

      @In
      private EntityManager entityManager;

      @Logger
      private Log log;

      public String register()
      {
      List query = entityManager.createQuery("select username from User where username=#{user.username}").getResultList();
      if (query.size()==0)
      {
      entityManager.persist(users);

      log.info("Registered new user #{users.username}");
      return "/registered.xhtml";
      }
      else
      {
      FacesMessages.instance().add("User #{users.username} already exists");
      return null;
      }
      }

      }


      LoginUser.xhtml

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:rich="http://richfaces.org/rich"
      template="layout/template.xhtml"
      xmlns:a4j="http://richfaces.org/a4j">

      <ui:define name="body">
      <h:form>
      <h:messages globalOnly="true" styleClass="message"/>
      <rich:panel>
      <f:facet name="header">Welcome to the Create User Page</f:facet>
      <h:panelGrid columns="2" style="align:center" >
      <h:outputText value="#{message.firstName}" />
      <h:panelGroup>
      <h:inputText id="firstName" value="#{users.firstName}" required="true"/>
      <h:message for="firstName" styleClass="message" />
      </h:panelGroup>
      <h:outputText value="#{message.lastName}" />
      <h:panelGroup>
      <h:inputText id="lastName" value="#{users.lastName}" required="true" />
      <h:message for="lastName" styleClass="message" />
      </h:panelGroup>
      <h:outputText value="#{message.userName}" />
      <h:inputSecret id="userName" value="#{users.userName}" />


      </h:panelGrid>
      <h:panelGroup>
      <h:commandButton action="#{registerSessionBean.register}" value="Login" />
      <h:commandButton action="cancel" value="Cancel" immediate="true" />
      </h:panelGroup>
      </rich:panel>
      </h:form>
      </ui:define>

      </ui:composition>


      Components.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
      xmlns:core="http://jboss.com/products/seam/core"
      xmlns:persistence="http://jboss.com/products/seam/persistence"
      xmlns:drools="http://jboss.com/products/seam/drools"
      xmlns:bpm="http://jboss.com/products/seam/bpm"
      xmlns:security="http://jboss.com/products/seam/security"
      xmlns:mail="http://jboss.com/products/seam/mail"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation=
      "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
      http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
      http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
      http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.0.xsd
      http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
      http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
      http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">

      <core:init jndi-pattern="ear-1.0-SNAPSHOT/#{ejbName}/local"/>

      <core:manager concurrent-request-timeout="500"
      conversation-timeout="10000"
      conversation-id-parameter="cid"
      parent-conversation-id-parameter="pid"/>

      <persistence:managed-persistence-context name="entityManager"
      auto-create="true"
      persistence-unit-jndi-name="java:/arplabEntityManagerFactory"/>





      Persistence.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
      version="1.0">

      <persistence-unit name="arplab">
      org.hibernate.ejb.HibernatePersistence
      <!-- MySQL Local -->
      <jta-data-source>java:/arpLabMySQLLocalDatasource</jta-data-source>







      </persistence-unit>