-->
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.  [ 7 posts ] 
Author Message
 Post subject: SQLSERVER AND HIBERNATE
PostPosted: Mon Nov 29, 2004 10:53 am 
Newbie

Joined: Tue Nov 23, 2004 12:25 pm
Posts: 9
Hi friends.

I'm getting the following:

java.lang.ExceptionInInitializerError
at Hiberna_SQL.AmigoDAO.<init>(AmigoDAO.java:13)
at Hiberna_SQL.TesteAmigo.main(TesteAmigo.java:15)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at net.sf.hibernate.cfg.Configuration.<clinit>(Configuration.java:94)
... 2 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 6 more
Caused by: java.lang.NullPointerException
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
... 7 more
Exception in thread "main"

------------------------------------------------------------------------------------
This is my cfg:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory name="java:comp/env/hibernate/SessionFactory">
<!-- properties -->


<property name="dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="connection.url">jdbc:microsoft:sqlserver://w-062:1433:HIBERNATE</property>
<property name="connection.username">sa</property>
<property name="connection.password">sa</property>


<!-- mapping files -->
<mapping resource="HIBERNA/Amigo.hbm.xml"/>
</session-factory>
</hibernate-configuration>

-----------------------------------------------------------------------------------
and this is my called class:

package Hiberna_SQL;
import java.util.List;
import net.sf.hibernate.*;
import net.sf.hibernate.cfg.Configuration;

public class AmigoDAO{

private SessionFactory factory;


public AmigoDAO() throws Exception{

factory = new Configuration().configure().buildSessionFactory();
Session session = factory.openSession();
java.sql.Connection cn = session.connection();

}

public void insert(Amigo amigo) throws Exception{
Session session = factory.openSession();
session.save(amigo);
session.flush();
session.close();
}

public java.util.List getList(String hql) throws Exception{
Session session = factory.openSession();
//List amigos = session.find(condicao);

List pessoas = session.find(hql);
for(int indice=0; indice<pessoas.size(); indice++)
{
Amigo amigo = (Amigo)pessoas.get(indice);

}
session.flush();
session.close();
return pessoas;
}

public Amigo retrieve(String pk) throws Exception{
Session session = factory.openSession();
Amigo amigo = (Amigo)session.load(Amigo.class, pk);
session.flush();
session.close();
return amigo;
}

public void delete(Amigo amigo) throws Exception{
Session session = factory.openSession();
session.delete(amigo);
session.flush();
session.close();
}
}

----------------------------------------------------------------
I'm not using webserver, just trying to validade data with sql server 2000.

The database is called HIBERNA and the table amigo.

Can somebody help me, please?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 29, 2004 11:05 am 
Beginner
Beginner

Joined: Tue Oct 26, 2004 12:45 pm
Posts: 43
Location: Israel
It looks like you have a problem with the log, and not with hibernate.
do you have all the jars in the right place?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 29, 2004 12:02 pm 
Newbie

Joined: Tue Nov 23, 2004 12:25 pm
Posts: 9
Thanks for your attention, Issahar.

I have all my .jar inside the Eclipse Project Hiberna_SQL, addeds with the Add External Jars option, including the msutil.jar, mssqlserver.jar and msbase.jar i got from MS. I hope be that. My log config is

log4j.rootLogger=INFO, dest1

log4j.appender.dest1=org.apache.log4j.ConsoleAppender
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%d %-5p %-5c{3} %x -> %m%n

#log4j.appender.dest2=org.apache.log4j.RollingFileAppender
#log4j.appender.dest2.File=bridge.log

#log4j.appender.dest2.MaxFileSize=100KB
#Keep one backup file
#log4j.appender.dest2.MaxBackupIndex=3

#log4j.appender.dest2.layout=org.apache.log4j.PatternLayout
#log4j.appender.dest2.layout.ConversionPattern=%d [%t] %-5p %-5c{3}(%L) %x -> %m%n

---------------------------------------------


Top
 Profile  
 
 Post subject: Re: SQLSERVER AND HIBERNATE
PostPosted: Mon Nov 29, 2004 12:10 pm 
Beginner
Beginner

Joined: Tue Oct 26, 2004 12:45 pm
Posts: 43
Location: Israel
afarias wrote:
<session-factory name="java:comp/env/hibernate/SessionFactory">


maybe the name gets in the way?
You said you don't use any server, so you don't use jndi name, and also you gave all the jdbc data, so there's no need for jndi SessionFactory.
try removing the attribute, and see if it works.

Jus.


Top
 Profile  
 
 Post subject: Re: SQLSERVER AND HIBERNATE
PostPosted: Mon Nov 29, 2004 12:13 pm 
Beginner
Beginner

Joined: Tue Oct 26, 2004 12:45 pm
Posts: 43
Location: Israel
afarias wrote:
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)


I still thinks it is something to do with the log...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 29, 2004 12:48 pm 
Newbie

Joined: Tue Nov 23, 2004 12:25 pm
Posts: 9
well, i'm new in hibernate and have no knowledgment about it. I got an example from Javafree and did everything. It was working until i try to connect to Oracle. It dont show any error but the table is not updated. After, i get the sqlserver driver and create another project (all the 3 are the same, changing only the hibernate.cfg.xml for each one). Now, none is working and each one return to me different erroes. I ask, really need i a log4j.properties even if i dont use a webserver like tomcat?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 29, 2004 4:28 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No you don't, but you have to know enough about such a trivial thing as logging to use this software. Try Google as well.


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