1 Reply Latest reply on Jul 1, 2005 11:34 AM by j. Eduardo

    Hibernate 3.0.5 & JBoss 4.0.2, NullPointerException

    Markus Werner Newbie


      I'm searching for a persistence framework to use, and actually I try to test hibernate.
      My problem at the moment is that i get a NullPointerException if I make a lookup.

      In the JNDI VIEW page i found the entry: +- SessionFactory (class: org.hibernate.impl.SessionFactoryImpl)
      But in the log file I found these entries, and i don't know what to do now.

      [org.hibernate.impl.SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
      [org.jboss.hibernate.jmx.Hibernate] SessionFactory successfully built and bound into JNDI [SessionFactory]

       <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
       <attribute name="DatasourceName">java:/DefaultDS</attribute>
       <attribute name="Dialect">org.hibernate.dialect.Oracle9Dialect</attribute>
       <property name="hibernate.default_schema">LAGERDBA</property>
       <property name="connection.pool_size">1</property>
       <property name="show_sql">true</property>
       <attribute name="SessionFactoryName">SessionFactory</attribute>
       <attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
       <attribute name="ShowSqlEnabled">true</attribute>

      InitialContext ctx = new InitialContext();
      SessionFactory factory;
      factory = (SessionFactory) ctx.lookup("SessionFactory");
      Session hsession = factory.openSession();
      Transaction tx = hsession.beginTransaction();

      Sample Hibernate File

      package de.psb_gmbh.main.business.persistence.hibernate;
      import java.util.Set;
      public class AcUser implements java.io.Serializable {
       // Fields
       private String UserId;
       private AcGroup AcGroup;
       private String LoginName;
       private String Name;
       private String Password;
       private Integer CheckCount;
       private Set<AcUserToGroup> SetOfAcUserToGroup;
       // Constructors
       public AcUser() {
       // Property accessors
       public String getUserId() {
       return this.UserId;
       public void setUserId(String UserId) {
       this.UserId = UserId;
       public AcGroup getAcGroup() {
       return this.AcGroup;
       public void setAcGroup(AcGroup AcGroup) {
       this.AcGroup = AcGroup;
       public String getLoginName() {
       return this.LoginName;
       public void setLoginName(String LoginName) {
       this.LoginName = LoginName;
       public String getName() {
       return this.Name;
       public void setName(String Name) {
       this.Name = Name;
       public String getPassword() {
       return this.Password;
       public void setPassword(String Password) {
       this.Password = Password;
       public Integer getCheckCount() {
       return this.CheckCount;
       public void setCheckCount(Integer CheckCount) {
       this.CheckCount = CheckCount;
       public Set<AcUserToGroup> getSetOfAcUserToGroup() {
       return this.SetOfAcUserToGroup;
       public void setSetOfAcUserToGroup(Set<AcUserToGroup> setOfAcUserToGroup) {
       this.SetOfAcUserToGroup = setOfAcUserToGroup;

      <?xml version="1.0"?>
      <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
       <class name="de.psb_gmbh.main.business.persistence.hibernate.AcUser" table="AC_USER" schema="LAGERDBA">
       <id name="UserId">
       <column name="USER_ID"/>
       <generator class="assigned" />
       <many-to-one name="AcGroup" class="de.psb_gmbh.main.business.persistence.hibernate.AcGroup">
       <column name="MASTER_GROUP_ID"/>
       <property name="LoginName">
       <column name="LOGIN_NAME"/>
       <property name="Name">
       <column name="NAME"/>
       <property name="Password">
       <column name="PASSWORD"/>
       <property name="CheckCount">
       <column name="CHECK_COUNT"/>
       <set name="SetOfAcUserToGroup">
       <column name="USER_ID" />
       <one-to-many class="de.psb_gmbh.main.business.persistence.hibernate.AcUserToGroup" />

      I'm using
      - JBoss 4.0.2
      - Hibernate 3.0.5
      - Java 5.0
      - Oracle DB 9.2
      - Windows XP SP1
      - Eclipse 3.1M7 with MyEclipse 3.8.4, JBoss IDE1.5M1, XML Spy Pro 2005