-->
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.  [ 2 posts ] 
Author Message
 Post subject: Unable to get an instance of Session Factory
PostPosted: Tue Oct 14, 2008 10:18 am 
Newbie

Joined: Tue Oct 14, 2008 9:50 am
Posts: 2
Hi,

I am using hibernate version 3.
I am unable to get an instance of session factory

Code which I have written is :

public class HibernateSession {
private static SessionFactory sessionFactory;
public static void main(String args[])
{

AnnotationConfiguration an = new AnnotationConfiguration();
Configuration cf = an.configure();
System.out.println( "Got Configuration........");
sessionFactory = cf.buildSessionFactory();
.....
}
}

O/P which I am getting on console is
Got Configuration........ ( sysout... given by me...)

Exception in thread "main" java.lang.NoSuchFieldError: sqlResultSetMappings
at org.hibernate.cfg.AnnotationConfiguration.createExtendedMappings(AnnotationConfiguration.java:166)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:254)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1036)
at com.sun.micfet.persistent.HibernateSession.main(HibernateSession.java:33)


[b]CONTENTS OF HIBERNATE.CFG.XML
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory >
<!-- Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@172.20.9.29:1522:SCHDEVAM</property>
<property name="connection.username">scholar</property>
<property name="connection.password">baseball1</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">none</property>
<mapping class="com.sun.micfet.persistent.Dealer"/>
</session-factory>
</hibernate-configuration>

Database used is oracle
Jar's added are:

ejb3-persistence.jar
hibernate-annotations.jar
antlr-2.7.6.jar
hibernate-commons-annotations.jar
asm-3.0.jar
hibernate3.jar
asm-attrs.jar
javassist-3.4.GA.jar
c3p0-0.9.1.jar
jaxen.jar
cglib-full-2.0.2.jar
jta-1.1.jar
cglib.jar
classes12.zip
log4j-1.2.9.jar
commons-collections-3.1.jar
commons-logging-1.0.4.jar
dom4j-1.5.2.jar
oscache-2.1.jar
ehcache-1.2.4.jar



If somebody can pls. help me... I AM COMPLETELY STUCK!!!!!!!!!!!!!!!


Thanks,
Sheetal


Top
 Profile  
 
 Post subject: Sorry now the exception has changed
PostPosted: Tue Oct 14, 2008 11:30 am 
Newbie

Joined: Tue Oct 14, 2008 9:50 am
Posts: 2
Hi,
I changed the jars and complied again.


Jar used now are
dom4j.jar
jta-1.1.jar

ejb3-persistence.jar
log4j-1.2.9.jar
antlr-2.7.6.jar
hibernate-annotations.jar
slf4j-api-1.5.2.jar
commons-collections-3.1.jar
hibernate-commons-annotations.jar
commons-logging-1.0.4.jar
hibernate-core.jar
slf4j-log4j12.jar
dom4j-1.6.1.jar
javassist-3.4.GA.jar



Dealer.java
*
* Dealer.java
*
* Created on October 14, 2008, 4:13 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/


@Entity
@Table(name="DEALER")
public class Dealer implements Serializable {
@Id
@Column(name="DEALER_ID")
private Integer dealerId;


@Column(name = "ADDRESS")
private String address;

@Column(name = "NAME")
private String name;


private static final long serialVersionUID = 1L;

public Dealer() {
super();
}

public Integer getDealerId() {
return this.dealerId;
}

public void setDealerId(Integer dealerId) {
this.dealerId = dealerId;
}

public String getAddress() {
return this.address;
}

public void setAddress(String address) {
this.address = address;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}
/*
public Set<Subscriber> getSubscriberCollection() {
return this.subscriberCollection;
}

public void setSubscriberCollection(Set<Subscriber> subscriberCollection) {
this.subscriberCollection = subscriberCollection;
}

public Set<Subscriber> getSubscriberCollection2() {
return this.subscriberCollection2;
}

public void setSubscriberCollection2(Set<Subscriber> subscriberCollection2) {
this.subscriberCollection2 = subscriberCollection2;
}

public OEM getOem() {
return oem;
}

public void setOem(OEM oem) {
this.oem = oem;
}
*/

}

Version Used:
hibernate-distribution-3.3.1.GA
hibernate-annotations-3.4.0.GA
*

This time I am getting the undermentioned error.

deps-jar:
Warning: com/sun/micfet/persistent/Dealer.java modified in the future.
Warning: com/sun/micfet/persistent/HibernateSession.java modified in the future.
Warning: log4j.properties modified in the future.
Warning: log4j.properties modified in the future.
Warning: modified in the future.
Warning: com/sun/micfet/persistent modified in the future.
compile:
run:
20:50:02,122 INFO Version:15 - Hibernate Annotations 3.4.0.GA
20:50:02,166 INFO Environment:543 - Hibernate 3.3.0.SP1
20:50:02,181 INFO Environment:576 - hibernate.properties not found
20:50:02,193 INFO Environment:709 - Bytecode provider name : javassist
20:50:02,205 INFO Environment:627 - using JDK 1.4 java.sql.Timestamp handling
20:50:02,390 INFO Version:14 - Hibernate Commons Annotations 3.1.0.GA
20:50:02,399 INFO Configuration:1460 - configuring from resource: /hibernate.cfg.xml
20:50:02,401 INFO Configuration:1437 - Configuration resource: /hibernate.cfg.xml
20:50:02,605 DEBUG DTDEntityResolver:64 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
20:50:02,609 DEBUG DTDEntityResolver:66 - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
20:50:02,615 DEBUG DTDEntityResolver:76 - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
20:50:02,732 DEBUG Configuration:1421 - connection.driver_class=oracle.jdbc.driver.OracleDriver
20:50:02,734 DEBUG Configuration:1421 - connection.url=jdbc:oracle:thin:@172.20.9.29:1522:SCHDEVAM
20:50:02,736 DEBUG Configuration:1421 - connection.username=scholar
20:50:02,739 DEBUG Configuration:1421 - connection.password=baseball1
20:50:02,741 DEBUG Configuration:1421 - dialect=org.hibernate.dialect.OracleDialect
20:50:02,742 DEBUG Configuration:1421 - show_sql=true
20:50:02,744 DEBUG Configuration:1421 - hbm2ddl.auto=none
20:50:02,749 DEBUG AnnotationConfiguration:644 - null <- org.dom4j.tree.DefaultAttribute@1ea0252 [Attribute: name class value "com.sun.micfet.persistent.Dealer"]
20:50:02,796 INFO Configuration:1575 - Configured SessionFactory: null
20:50:02,803 DEBUG Configuration:1576 - properties: {hibernate.connection.password=baseball1, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=/usr/dist/share/java,v1.5.0/5.x-sun4/jre/lib/sparc, java.vm.version=1.5.0-b64, hibernate.connection.username=scholar, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=:, java.vm.name=Java HotSpot(TM) Server VM, file.encoding.pkg=sun.io, sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/home/sg227479/micfet_proj/Try, java.runtime.version=1.5.0-b64, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, hbm2ddl.auto=none, java.endorsed.dirs=/usr/dist/share/java,v1.5.0/5.x-sun4/jre/lib/endorsed, os.arch=sparc, java.io.tmpdir=/var/tmp/, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., os.name=SunOS, sun.jnu.encoding=ISO646-US, java.library.path=/usr/dist/share/java,v1.5.0/5.x-sun4/jre/lib/sparc/server:/usr/dist/share/java,v1.5.0/5.x-sun4/jre/lib/sparc:/usr/dist/share/java,v1.5.0/5.x-sun4/jre/../lib/sparc:/usr/openwin/lib:/opt/CA/CAlib:/opt/CA/SharedComponents/lib:/usr/lib, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot Server Compiler, os.version=5.10, connection.password=baseball1, user.home=/home/sg227479, user.timezone=Asia/Calcutta, connection.username=scholar, java.awt.printerjob=sun.print.PSPrinterJob, file.encoding=ISO646-US, java.specification.version=1.5, hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver, show_sql=true, user.name=sg227479, java.class.path=/home/sg227479/micfet_proj/lib2/ejb3-persistence.jar:/home/sg227479/micfet_proj/lib2/hibernate-commons-annotations.jar:/home/sg227479/micfet_proj/lib2/hibernate-core.jar:/home/sg227479/micfet_proj/lib2/hibernate-annotations.jar:/home/sg227479/micfet_proj/lib2/slf4j-log4j12.jar:/home/sg227479/micfet_proj/lib2/slf4j-api.jar:/home/sg227479/micfet_proj/lib2/antlr-2.7.6.jar:/home/sg227479/micfet_proj/lib2/commons-collections-3.1.jar:/home/sg227479/micfet_proj/lib2/dom4j-1.6.1.jar:/home/sg227479/micfet_proj/lib2/javassist-3.4.GA.jar:/home/sg227479/micfet_proj/lib2/jta-1.1.jar:/home/sg227479/micfet_proj/lib2/log4j-1.2.9.jar:/home/sg227479/micfet_proj/Try/build/classes, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=/usr/dist/share/java,v1.5.0/5.x-sun4/jre, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.OracleDialect, hibernate.connection.url=jdbc:oracle:thin:@172.20.9.29:1522:SCHDEVAM, user.language=en, java.specification.vendor=Sun Microsystems Inc., java.vm.info=mixed mode, java.version=1.5.0, java.ext.dirs=/usr/dist/share/java,v1.5.0/5.x-sun4/jre/lib/ext, sun.boot.class.path=/usr/dist/share/java,v1.5.0/5.x-sun4/jre/lib/rt.jar:/usr/dist/share/java,v1.5.0/5.x-sun4/jre/lib/i18n.jar:/usr/dist/share/java,v1.5.0/5.x-sun4/jre/lib/sunrsasign.jar:/usr/dist/share/java,v1.5.0/5.x-sun4/jre/lib/jsse.jar:/usr/dist/share/java,v1.5.0/5.x-sun4/jre/lib/jce.jar:/usr/dist/share/java,v1.5.0/5.x-sun4/jre/lib/charsets.jar:/usr/dist/share/java,v1.5.0/5.x-sun4/jre/classes, java.vendor=Sun Microsystems Inc., connection.driver_class=oracle.jdbc.driver.OracleDriver, file.separator=/, hibernate.hbm2ddl.auto=none, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeBig, sun.cpu.endian=big, sun.desktop=gnome, connection.url=jdbc:oracle:thin:@172.20.9.29:1522:SCHDEVAM, dialect=org.hibernate.dialect.OracleDialect, sun.cpu.isalist=sparcv9+vis2 sparcv9+vis sparcv9 sparcv8plus+vis2 sparcv8plus+vis sparcv8plus sparcv8 sparcv8-fsmuld sparcv7 sparc}
Got Configuration........
20:50:02,812 DEBUG AnnotationConfiguration:806 - Validator not present in classpath, ignoring event listener registration
20:50:02,824 DEBUG HibernateSearchEventListenerRegister:209 - Search not present in classpath, ignoring event listener registration.
20:50:02,832 INFO HibernateSearchEventListenerRegister:53 - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
20:50:02,835 DEBUG Configuration:1318 - Preparing to build session factory with filters : {}
20:50:02,836 DEBUG AnnotationConfiguration:258 - Execute first pass mapping processing
20:50:03,062 DEBUG AnnotationConfiguration:529 - Process hbm files
20:50:03,065 DEBUG AnnotationConfiguration:537 - Process annotated classes
20:50:03,084 INFO AnnotationBinder:419 - Binding entity from annotated class: com.sun.micfet.persistent.Dealer
20:50:03,158 DEBUG Ejb3Column:161 - Binding column DTYPE. Unique false. Nullable false.
20:50:03,202 DEBUG EntityBinder:295 - Import with entity name Dealer
20:50:03,212 INFO EntityBinder:422 - Bind entity com.sun.micfet.persistent.Dealer on table DEALER
20:50:03,232 DEBUG AnnotationBinder:1022 - Processing com.sun.micfet.persistent.Dealer property annotation
20:50:03,265 DEBUG AnnotationBinder:1022 - Processing com.sun.micfet.persistent.Dealer field annotation
20:50:03,313 DEBUG AnnotationBinder:1133 - Processing annotations of com.sun.micfet.persistent.Dealer.dealerId
20:50:03,318 DEBUG Ejb3Column:161 - Binding column DEALER_ID. Unique false. Nullable true.
20:50:03,324 DEBUG AnnotationBinder:1257 - dealerId is an id
20:50:03,336 DEBUG SimpleValueBinder:220 - building SimpleValue for dealerId
20:50:03,345 DEBUG PropertyBinder:131 - Building property dealerId
Exception in thread "main" java.lang.NoSuchFieldError: TRACE
at org.slf4j.impl.Log4jLoggerAdapter.trace(Log4jLoggerAdapter.java:90)
at org.hibernate.cfg.annotations.PropertyBinder.make(PropertyBinder.java:184)
at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1911)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1279)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:754)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:546)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:291)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1319)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at com.sun.micfet.persistent.HibernateSession.main(HibernateSession.java:33)

Pls. help me... i even tried remove common-logging.jar... But it was not much off help...


Thanks
Sheetal


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.