1 Reply Latest reply on Oct 17, 2007 2:11 PM by birwin

    Could not instantiate Seam component caused by: javax.naming

    birwin Newbie

      Where am I supposed to define the Spike7 datasource. I keep getting this error:

      javax.naming.NameNotFoundException: Spike7 not bound

      where I have defined in my @Stateful bean an Entity Manager like so:

      @javax.persistence.PersistenceContext (unitName="Spike7")
       private EntityManager em;

      and my persistence.xml file located in the WEB-INF/classes/META-INF directory has this entry:

       <persistence-unit name="Spike7">
       <property name="hibernate-dialect" value="org.hibernate.dialect.SQLServerDialect" />
       <property name="hibernate.hbm2ddl.auto" value="${hibernate.hbm2ddl.auto}"/>
       <property name="hibernate.show_sql" value="true"/>
       <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
       <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

      and I have a Spike7DataSource-ds.xml deployed on my JBoss server... The jmx-console has these MBeans deployed indicating the DataSource has been successfully deployed:


      Any ideas what I am doing wrong? Can I use the Stateful bean in a WAR application.

      Sorry if these are uneducated questions, but I am new to the seam world.

        • 1. Re: Could not instantiate Seam component caused by: javax.na
          birwin Newbie

          Okay, this solution is elementary, however, it was not obvious to me.

          By annotating my POJOs with the @In annotation instead of the @PersistenceContext annotation, and renaming the managed-persistence-context in my components.xml file to entityManager, I was able to fix this problem.

          I believe the name in the components.xml file can be something else, but then you have to specify the name next to the @In annotation in your POJOs.