-->
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.  [ 6 posts ] 
Author Message
 Post subject: Man -- I need help and I am about to scream - simple issue
PostPosted: Thu Sep 02, 2004 9:00 pm 
Newbie

Joined: Thu Sep 02, 2004 8:41 pm
Posts: 11
Okay -- I have pretty much read the manning book, went through all the examples noted in the roadmap -- SERIOUSLY! So I think "hey - let me actually get one of these to work on JBoss" -- big freakin mistake

I have been at it now for 2 days trying on and off to get this thing to work.

What in the world is wrong??? Any help is appreciated -- this should be simple shouldn't it?

JBoss mysql ds file - although this should not matter because i put the connection url in my hibernate.properties
<datasources>
<local-tx-datasource>
<jndi-name>mysqlTest</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/test</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password/>
</local-tx-datasource>
</datasources>

Hibernate version:2.1.6

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

<hibernate-mapping>
<class name="com.dbdemo.User" table="users">

<id name="ID" column="LogonId" type="string">
<generator class="assigned"/>
</id>
<property name="userName" column="Name" type="string"/>
<property name="password" type="string"/>
<property name="emailAddress" type="string"/>
<property name="lastLogon" type="date"/>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Configuration cfg = new Configuration();
cfg.addResource("com/dbdemo/User.hbm.xml");
cfg.setProperties(System.getProperties());

SessionFactory sessionsFact = cfg.buildSessionFactory();
System.out.println("Session Factory built");

Session session = sessionsFact.openSession();
System.out.println("Session built");

session.save(newUser);
System.out.println("User saved");
session.flush();
System.out.println("Session flushed");
session.close();


Full stack trace of any exception that occurs:

20:37:00,858 INFO [Environment] Hibernate 2.1.6
20:37:00,862 INFO [Environment] loaded properties from resource hibernate.properties: {hibernate.connection.username=root, hibernate.connection.password=, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost:3306/test, hibernate.connection.driver_class=org.gjt.mm.mysql.Driver}
20:37:00,868 INFO [Environment] using CGLIB reflection optimizer
20:37:00,879 INFO [Configuration] Mapping resource: com/dbdemo/User.hbm.xml
20:37:01,816 INFO [Binder] Mapping class: com.dbdemo.User -> users
20:37:02,090 INFO [Configuration] processing one-to-many association mappings
20:37:02,092 INFO [Configuration] processing one-to-one association property references
20:37:02,093 INFO [Configuration] processing foreign key constraints
20:37:02,179 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.MySQLDialect
20:37:02,189 INFO [SettingsFactory] Maximim outer join fetch depth: 2
20:37:02,192 INFO [SettingsFactory] Use outer join fetching: true
20:37:02,207 WARN [UserSuppliedConnectionProvider] No connection properties specified - the user must supply JDBC connections
20:37:02,223 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
20:37:02,224 INFO [SettingsFactory] Use scrollable result sets: false
20:37:02,225 INFO [SettingsFactory] Use JDBC3 getGeneratedKeys(): false
20:37:02,226 INFO [SettingsFactory] Optimize cache for minimal puts: false
20:37:02,228 INFO [SettingsFactory] Query language substitutions: {}
20:37:02,229 INFO [SettingsFactory] cache provider: net.sf.hibernate.cache.EhCacheProvider
20:37:02,264 INFO [Configuration] instantiating and configuring caches
20:37:02,683 INFO [SessionFactoryImpl] building session factory
20:37:03,292 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
20:37:03,294 INFO [STDOUT] Session Factory built
20:37:03,449 INFO [STDOUT] Session built
20:37:03,478 INFO [STDOUT] User saved
20:37:03,522 INFO [STDOUT] XXXXXXXX caught throwable The user must supply a JDBC connection


Name and version of the database you are using:

mysql - 4.0.20

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 9:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Um. Follow the instructions for using Hibernate with an appserver datasource, or check one of the Wiki pages which display correct Hibernate + JBoss configuration.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 9:23 pm 
Newbie

Joined: Thu Sep 02, 2004 8:41 pm
Posts: 11
Well I tried to do the SAR configuration - did not work out for me.

Tried to do the Tomcat configuration based on the roadmap.

Look I know it is me -- but I am on my 5th project in my IDE trying to figure out how to get this stuff to work. If I give the connection url should it not be going through JNDI to obtain a connection?

The reason I ask is due to the error I receive about providing a connection -- also, I can connect just fine through my own personal DAOs -- why shouldn't hibernate with the same configuration?

Also - nice to meet you Gavin -- wish it could be under better circumstances:-) I am sure you do not want to be bothered with such posts.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 9:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Well what is wrong with your current config is that you are trying to point hibernate direct to the database (but with insufficient properties). You need to point it to the datasource, using hibernate.connection.datasource.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 9:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
The reason you have insifficient properties, btw, is this line:

Code:
cfg.setProperties(System.getProperties());

where you hammer the properties coming from hibernate.properties. Get rid of it, for a start.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 10:56 pm 
Newbie

Joined: Thu Sep 02, 2004 8:41 pm
Posts: 11
First off - Thank you for your input.

Okay - so I created the SAR and worked through some of my initial errors (all my fault of course:-) Long story short is that everything is working fine - and I feel like a jackass that it took me this long.

The sar is the way to go - it just got me more intimately familiar with the jmx-console. Next I will put all the jars within the sar deployment and work on getting xdoclet in my development process.

Again - thank you for your help - I have enjoyed your book - bought the e-book and the hard-copy is on the way:-)

Take Care,

Starrin


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