-->
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: Error Creating SessionFactory
PostPosted: Sun Dec 26, 2004 5:17 pm 
Newbie

Joined: Thu Dec 02, 2004 10:51 am
Posts: 6
dear all;
i need some help to figure out what is really wrong with the information below ?
my junit fails , but i am not sure where to look to fix the problem.

i am also not sure if i need the hibernate.cfg.xml file , because i am using the hibernate.properties file instead . But if i really need the hibernate.cfg.xml file , where exactly should it be placed in the directory structure ?

Any help will be greatly appreciated .
thanks



Hibernate version:

2.1.2

Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="hinetlogic.Customer" table="CUSTOMER">
<id name="id" type="integer" unsaved-value="-1">
<generator class="identity"/>
</id>
<property name="name" column="name" type="string" length="100" not-null="true"/>
<property name="customerId" column="customer_Id" type="string" length="10" not-null="true"/>
<property name="emailAdress" column="email_address" type="string" length="50" not-null="true"/>
<property name="ophone" column="office_phone" type="string" length="20" not-null="true"/>
<property name="date" column="date_entered" type="date" not-null="true"/>
<property name="hphone" column="home_phone" type="string" length="20" not-null="true"/>
<property name="stree" column="street" type="string" length="100" not-null="true"/>
<property name="state" column="state" type="string" length="20" not-null="true"/>
<property name="pcode" column="postal_code" type="string" length="10" not-null="true"/>
<property name="country" column="country" type="string" length="20" not-null="true"/>

</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

public static Session currentSession() throws DAOException {
Session s = (Session) session.get();
//System.err.println("after the session statement");

try {
if(s == null ||s.isOpen()== false)
{
if (sf == null)
{
try
{
cfg.configure();
loadClasses();
// System.err.println("after the load classes");
sf = cfg.buildSessionFactory();

}
catch(Exception e) {
System.err.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
s = sf.openSession();
session.set(s);
}
}
catch (HibernateException he) {
throw new DAOException(he);
}
return s;
}

/**
Closes the session object.

@throws DAOException
*/
public static void closeSession() throws DAOException {
Session s = (Session) session.get();
session.set(null);

if(s != null) {
try {
s.close();
}
catch (HibernateException he) {
throw new DAOException(he);
}
}
}


Full stack trace of any exception that occurs:

Buildfile: build.xml

build:
[javac] Compiling 2 source files to E:\hinetlogic\build

make-docs:
[javadoc] Generating Javadoc
[javadoc] Javadoc execution
[javadoc] Loading source files for package hinetlogic...
[javadoc] Loading source files for package hinetlogic.persistence...
[javadoc] Loading source files for package hinetlogic.test...
[javadoc] Loading source files for package hinetlogic.util...
[javadoc] Constructing Javadoc information...
[javadoc] Standard Doclet version 1.4.2_05
[javadoc] Building tree for all the packages and classes...
[javadoc] Building index for all the packages and classes...
[javadoc] Building index for all classes...

gen-classes:

make-props:
[propertyfile] Updating property file: E:\hinetlogic\config\hibernate.properties


init-db:
[schemaexport] 05:17:10,713 INFO Environment:462 - Hibernate 2.1.2
[schemaexport] 05:17:10,763 INFO Environment:496 - loaded properties from resou
rce hibernate.properties: {hibernate.connection.driver_class=COM.ibm.db2.jdbc.ap
p.DB2Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=ne
t.sf.hibernate.dialect.DB2Dialect, hibernate.jdbc.use_scrollable_resultsets=fals
e, hibernate.jdbc.batch_size=0 , hibernate.use_outer_join=true, hibernate.connec
tion.username=ne, hibernate.connection.url=jdbc:db2:sample, hibernate.connec
tion.password=ad}
[schemaexport] 05:17:10,813 INFO Environment:519 - using CGLIB reflection optim
izer
[schemaexport] 05:17:10,894 INFO Configuration:166 - Mapping file: E:\hinetlogi
c\build\hinetlogic\Customer.hbm.xml
[schemaexport] 05:17:12,356 INFO Binder:229 - Mapping class: hinetlogic.Custome
r -> CUSTOMER
[schemaexport] 05:17:13,317 INFO Dialect:82 - Using dialect: net.sf.hibernate.d
ialect.DB2Dialect
[schemaexport] 05:17:13,317 INFO Configuration:595 - processing one-to-many ass
ociation mappings
[schemaexport] 05:17:13,317 INFO Configuration:604 - processing one-to-one asso
ciation property references
[schemaexport] 05:17:13,327 INFO Configuration:629 - processing foreign key con
straints
[schemaexport] 05:17:13,608 INFO Configuration:595 - processing one-to-many ass
ociation mappings
[schemaexport] 05:17:13,608 INFO Configuration:604 - processing one-to-one asso
ciation property references
[schemaexport] 05:17:13,608 INFO Configuration:629 - processing foreign key con
straints
[schemaexport] 05:17:13,638 INFO SchemaExport:98 - Running hbm2ddl schema expor
t
[schemaexport] 05:17:13,648 INFO SchemaExport:112 - writing generated schema to
file: E:\hinetlogic/db/schema.sql
[schemaexport] 05:17:13,648 INFO SchemaExport:117 - exporting generated schema
to database
[schemaexport] 05:17:13,698 INFO DriverManagerConnectionProvider:41 - Using Hib
ernate built-in connection pool (not for production use!)
[schemaexport] 05:17:13,698 INFO DriverManagerConnectionProvider:42 - Hibernate
connection pool size: 20
[schemaexport] 05:17:13,838 INFO DriverManagerConnectionProvider:71 - using dri
ver: COM.ibm.db2.jdbc.app.DB2Driver at URL: jdbc:db2:sample
[schemaexport] 05:17:13,838 INFO DriverManagerConnectionProvider:72 - connectio
n properties: {user=neuron, password=admin}
[schemaexport] 05:17:14,949 DEBUG SchemaExport:132 - drop table CUSTOMER;
[schemaexport] 05:17:15,530 DEBUG SchemaExport:149 - create table CUSTOMER (
[schemaexport] id INTEGER not null generated by default as identity,
[schemaexport] name VARCHAR(100) not null,
[schemaexport] customer_Id VARCHAR(10) not null,
[schemaexport] email_address VARCHAR(50) not null,
[schemaexport] office_phone VARCHAR(20) not null,
[schemaexport] date_entered DATE not null,
[schemaexport] home_phone VARCHAR(20) not null,
[schemaexport] street VARCHAR(100) not null,
[schemaexport] state VARCHAR(20) not null,
[schemaexport] postal_code VARCHAR(10) not null,
[schemaexport] country VARCHAR(20) not null,
[schemaexport] primary key (id)
[schemaexport] );
[schemaexport] 05:17:16,001 INFO SchemaExport:160 - schema export complete
[schemaexport] 05:17:16,021 INFO DriverManagerConnectionProvider:137 - cleaning
up connection pool: jdbc:db2:sample

run-tests:
[junit] Running hinetlogic.test.TestCustomerDAO
[junit] 05:17:19,746 INFO Environment:462 - Hibernate 2.1.2
[junit] 05:17:19,796 INFO Environment:496 - loaded properties from resource
hibernate.properties: {hibernate.connection.driver_class=COM.ibm.db2.jdbc.app.D
B2Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.s
f.hibernate.dialect.DB2Dialect, hibernate.jdbc.use_scrollable_resultsets=false,
hibernate.jdbc.batch_size=0 , hibernate.use_outer_join=true, hibernate.connectio
n.username=ne, hibernate.connection.url=jdbc:db2:sample, hibernate.connectio
n.password=ad}
[junit] 05:17:19,816 INFO Environment:519 - using CGLIB reflection optimize
r
[junit] 05:17:19,836 INFO Configuration:329 - Mapping resource: hinetlogic/
Customer.hbm.xml
[junit] 05:17:22,220 INFO Binder:229 - Mapping class: hinetlogic.Customer -
> CUSTOMER
[junit] 05:17:22,540 INFO Configuration:595 - processing one-to-many associ
ation mappings
[junit] 05:17:22,550 INFO Configuration:604 - processing one-to-one associa
tion property references
[junit] 05:17:22,550 INFO Configuration:629 - processing foreign key constr
aints
[junit] 05:17:22,640 INFO Dialect:82 - Using dialect: net.sf.hibernate.dial
ect.DB2Dialect
[junit] 05:17:22,651 INFO SettingsFactory:62 - Use outer join fetching: tru
e
[junit] 05:17:22,671 INFO DriverManagerConnectionProvider:41 - Using Hibern
ate built-in connection pool (not for production use!)
[junit] 05:17:22,681 INFO DriverManagerConnectionProvider:42 - Hibernate co
nnection pool size: 20
[junit] 05:17:22,821 INFO DriverManagerConnectionProvider:71 - using driver
: COM.ibm.db2.jdbc.app.DB2Driver at URL: jdbc:db2:sample
[junit] 05:17:22,821 INFO DriverManagerConnectionProvider:72 - connection p
roperties: {user=ne, password=in}
[junit] 05:17:22,871 INFO TransactionManagerLookupFactory:33 - No Transacti
onManagerLookup configured (in JTA environment, use of process level read-write
cache is not recommended)
[junit] %%%% Error Creating SessionFactory %%%%
[junit] java.lang.NumberFormatException: For input string: "0 "
[junit] at java.lang.NumberFormatException.forInputString(NumberFormatEx
ception.java:48)
[junit] at java.lang.Integer.parseInt(Integer.java:477)
[junit] at java.lang.Integer.parseInt(Integer.java:518)
[junit] at net.sf.hibernate.util.PropertiesHelper.getInt(PropertiesHelpe
r.java:23)
[junit] at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFa
ctory.java:70)
[junit] at net.sf.hibernate.cfg.Configuration.buildSettings(Configuratio
n.java:1119)
[junit] at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Config
uration.java:748)
[junit] at hinetlogic.persistence.HibernateSession.currentSession(Hibern
ateSession.java:27)
[junit] at hinetlogic.persistence.BaseDAO.storeObj(BaseDAO.java:90)
[junit] at hinetlogic.persistence.CustomerDAO.saveCustomer(CustomerDAO.j
ava:10)
[junit] at hinetlogic.test.TestCustomerDAO.testSaveCustomer(TestCustomer
DAO.java:49)
[junit] 05:17:22,901 INFO DriverManagerConnectionProvider:137 - cleaning up
connection pool: jdbc:db2:sample
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:324)
[junit] at junit.framework.TestCase.runTest(TestCase.java:154)
[junit] at junit.framework.TestCase.runBare(TestCase.java:127)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.
run(JUnitTestRunner.java:325)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.
main(JUnitTestRunner.java:536)
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 3.305 sec
[junit] Test hinetlogic.test.TestCustomerDAO FAILED

all:

BUILD SUCCESSFUL
Total time: 35 seconds
E:\hinetlogic>



Name and version of the database you are using:

DB2 7.x

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 26, 2004 6:05 pm 
Newbie

Joined: Sun Dec 26, 2004 3:49 pm
Posts: 4
The exception is thrown when it attempts to convert a string property value into an integer. Check that the property values such as hibernate.jdbc.batch_size is correctly specified.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 26, 2004 6:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it has a space at the end....so remember to check for that.

_________________
Max
Don't forget to rate


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.