-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Mapping problem
PostPosted: Thu May 20, 2010 1:25 pm 
Newbie

Joined: Thu May 20, 2010 1:13 pm
Posts: 1
Hi guys!
I have a problem that is haunting me for quite a long time, and after googling I still can't find an answer nor solution. Maybe you can help me overcome this.

so I had Hibernate running fine, everything looking good. Yesterday I had to add a new column to the DB, so I in Eclipse I ran hibernate code generator to map the new hbm.xml and the .java file.
but when I try to run the program an error occurrs:

Quote:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:80)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:323)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:456)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:131)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:267)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 30 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedConstructorAccessor11.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
... 43 more
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for userVar in class waf.data.entities.Devices
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:306)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:299)
at org.hibernate.mapping.Property.getGetter(Property.java:294)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:300)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:141)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:78)


In my readings I learned that the problem could be the getter for the userVar, but I have the getter and setter properly done:
Code:
public String getUserVar() {
return this.userVar;
}

public void setUserVar(String userVar) {
      this.userVar = userVar;
}


So I don't really know what to look for anymore...

any hints or tips?

thanks in advance!


Top
 Profile  
 
 Post subject: Re: Mapping problem
PostPosted: Thu Mar 31, 2011 2:47 pm 
Newbie

Joined: Thu Mar 31, 2011 2:18 pm
Posts: 2
I was about to post a new topic for this, but I'm running into exactly the same problem (only I've used the NetBeans 6.9.1 wizard to generate the .hbm.xml and .java files).

The dbms is MySQL 5.1. Table 'survey' has one row, and can be queried just fine using MySQL Workbench.

1. Here's the table definition:

Table survey
============
surv_id, surv_name, surv_sqftnow, surv_typenow, surv_sqftgrowth, surv_periodgrowth, surv_entered
------------
surv_id INT
surv_name VARCHAR
surv_sqftnow INT
surv_typenow INT
surv_sqftgrowth INT
surv_periodgrowth VARCHAR
surv_entered DATETIME


2. Here's the error message:
org.hibernate.PropertyNotFoundException: Could not find a getter for survSqftnow in class survey.Survey
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
(11 lines follow)


3. Here's the Survey.hbm.xml file generated by NetBeans:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Mar 31, 2011 10:51:49 AM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
    <class name="survey.Survey" table="survey" catalog="survey">
        <id name="survId" type="int">
            <column name="surv_id" />
            <generator class="assigned" />
        </id>
        <property name="survName" type="string">
            <column name="surv_name" length="50" not-null="true" />
        </property>
        <property name="survSqftnow" type="java.lang.Integer">
            <column name="surv_sqftnow" />
        </property>

        <!-- other property elements removed for clarity -->

    </class>
</hibernate-mapping>



4. Here's the code from the POJO:

Code:
package survey;
// Generated Mar 31, 2011 10:51:48 AM by Hibernate Tools 3.2.1.GA

import java.util.Date;

/**
* Survey generated by hbm2java
*/
public class Survey  implements java.io.Serializable {

     private int survId;
     private String survName;
     private Integer survSqftnow;
     private Integer survTypenow;
     private Integer survSqftgrowth;
     private String survPeriodgrowth;
     private Date survEntered;

    public Survey() {
    }
   
    public Survey(int survId, String survName) {
        this.survId = survId;
        this.survName = survName;
    }
    public Survey(int survId, String survName, Integer survSqftnow, Integer survTypenow, Integer survSqftgrowth, String survPeriodgrowth, Date survEntered) {
       this.survId = survId;
       this.survName = survName;
       this.survSqftnow = survSqftnow;
       this.survTypenow = survTypenow;
       this.survSqftgrowth = survSqftgrowth;
       this.survPeriodgrowth = survPeriodgrowth;
       this.survEntered = survEntered;
    }
   
    public int getSurvId() {
        return this.survId;
    }
   
    public void setSurvId(int survId) {
        this.survId = survId;
    }
    public String getSurvName() {
        return this.survName;
    }
   
    public void setSurvName(String survName) {
        this.survName = survName;
    }
    public Integer getSurvSqftnow() {
        return this.survSqftnow;
    }
   
    public void setSurvSqftnow(Integer survSqftnow) {
        this.survSqftnow = survSqftnow;
    }
[b]    public Integer getSurvTypenow() {
        return this.survTypenow;
[/b]    }
   
   /* other getter and setter methods removed for clarity */
}



The only thing I can see that may be significant is, the error did not happen on the first non-PK field, which is a String type. Instead, it happened on field survSqftNow, which is mapped to java.lang.Integer.

I've seen a lot of posts, here and on other forums, about this particular exception, but many of them were resolved by correcting a typo, removing a rogue space character, etc. Here, the config file and the Java class code were both generated by a wizard.

Any thoughts would be most appreciated.


Top
 Profile  
 
 Post subject: Re: Mapping problem
PostPosted: Sat Apr 02, 2011 1:07 pm 
Newbie

Joined: Thu Mar 31, 2011 2:18 pm
Posts: 2
Well, I've solved this (or at least, it's working now).
The solution was to rebuild the project (in NetBeans, Clean and Build) before attempting to run the HQL query.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.