-->
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: After 2 long day- java.lang.UnsupportedOperationException:
PostPosted: Thu Jun 03, 2004 2:00 pm 
Beginner
Beginner

Joined: Sun Sep 07, 2003 9:04 am
Posts: 48
Hello forum, firstly thanks for your time.
I have installed hibernate synchronizer on eclipse-SDK-3.0M9-win32 then hook to a oracle10g db, then generated the files of 3 tables.
the hbh.xml, the java files.
then genrated the apping file cfg.xml.
but the tried this small example.
I am running it inside eclipse
the structure of problem
1: test.java
2:cfg.xml
3: the error message produced by running ttest.java
*************************************************************
public class test {

public static void main(String[] args) throws Exception {

Persons p = new Persons();
p.setId(Integer.getInteger("2"));
p.setFirstName("pus");

// 2. Fire up Hibernate
Configuration cfg = new Configuration ().addClassPersons.class)
.addClass(Reservations.class)
.addClass(Flights.class);

SessionFactory sf = cfg.buildSessionFactory();

// 3. Open Session
Session sess = sf.openSession();
// 4. Save Product and close Session
Transaction t = sess.beginTransaction();
sess.save(p);
t.commit();
sess.close();
System.out.println(p);
}
}

*************************************************************
here is my cfg.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory name="java:comp/env/hibernate/SessionFactory">
<!-- datasource connection properties -->
<property name="connection.datasource">
java:comp/env/hibernate/SessionFactory
</property>
<!-- dialect for Oracle (any version) -->
<property name="dialect">
net.sf.hibernate.dialect.OracleDialect
</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.transaction.factory_class">
net.sf.hibernate.transaction.JBossTransactionManagerLookup
</property>
<property name="jta.UserTransaction">
java:comp/UserTransaction
</property>
<mapping resource="Flights.hbm.xml" />
<mapping resource="Jultest.hbm.xml" />
<mapping resource="Persons.hbm.xml" />
<mapping resource="Reservations.hbm.xml" />
</session-factory>
</hibernate-configuration>
************************************************************
Error message

(impl.SessionFactoryObjectFactory 82 ) no JNDI name configured
java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at net.sf.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:32)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3297)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3277)
at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2220)
at src.test.main(test.java:37)
Exception in thread "main"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 03, 2004 11:18 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Your Hibernate config.xml is only useful within the app server.

Your test.java does not create a SessionFactory in JNDI.

Try running things with a straight JDBC connection.


Sherman


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.