2 Replies Latest reply on Aug 20, 2008 5:26 AM by Oliver Becherer

    NullPointer on Entitymanager using Seam Project

    Oliver Becherer Newbie

      hi there,

      i am new to Jboss - development with seam and have problems with my first Database - project :

      I generated a SeamWebProject by Jboss Tools for Eclipse and ReverseEngineered a Database into the Seam - Project, e.g. the Class ArticleHome :

      / Generated 13.08.2008 15:14:13 by Hibernate Tools 3.2.2.GA

      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;

      /**
      * Home object for domain model class Article.
      * @see de.medint.webshop.Article
      * @author Hibernate Tools
      */
      @Stateless
      public class ArticleHome {

      private static final Log log = LogFactory.getLog(ArticleHome.class);

      @PersistenceContext
      private EntityManager entityManager;

      public void persist(Article transientInstance) {
      log.debug("persisting Article instance");
      try {
      entityManager.persist(transientInstance);
      log.debug("persist successful");
      } catch (RuntimeException re) {
      log.error("persist failed", re);
      throw re;
      }
      }
      }

      The components.xml looks as follows :

      <?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 debug="true" jndi-pattern="@jndiPattern@"/>

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

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

      <drools:rule-base name="securityRules">
      <drools:rule-files>
      /security.drl
      </drools:rule-files>
      </drools:rule-base>

      <security:identity security-rules="#{securityRules}" authenticate-method="#{authenticator.authenticate}" remember-me="true"/>








      <mail:mail-session host="localhost" port="2525" username="test" password="test" />

      <!-- For use with jBPM pageflow or process management -->
      <!--
      <bpm:jbpm>
      <bpm:process-definitions></bpm:process-definitions>
      <bpm:pageflow-definitions></bpm:pageflow-definitions>
      </bpm:jbpm>
      -->




      Heres the persistence.xml :

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- Persistence deployment descriptor for dev profile -->
      <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="webshop">
      org.hibernate.ejb.HibernatePersistence
      <jta-data-source>java:/webshopDatasource</jta-data-source>








      </persistence-unit>




      Using a function of ArticleHome i get a NullPointer on Entitymanager...

      whats wrong - can somebody help?


      thnx