-->
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.  [ 11 posts ] 
Author Message
 Post subject: No action, no reason
PostPosted: Tue Mar 09, 2004 2:59 pm 
Newbie

Joined: Tue Mar 09, 2004 2:44 pm
Posts: 15
I have just started evaluating Hibernate and am trying to set up a slightly modified version of the example in the Quick Start with Tomcat section of documentation. Here is what I have:


public class HibernateUtil exactly as in example (here)

Code:
public class HibernateWork {

    public static void execute () {
        try {
            Session session = HibernateUtil.currentSession();
            Transaction tx= session.beginTransaction();
            HibernateExUser newUser = new HibernateExUser(); //standard JavaBean
            newUser.setUsername("User1");
            newUser.setFirstName("The First");
            newUser.setFirstName("User");
            newUser.setUserId(0);
            session.save(newUser);
            tx.commit();
            HibernateUtil.closeSession();
        } catch (HibernateException e) {
            e.printStackTrace();
        }
    }
}


This is the output (seems to read configurations okay):
Code:
Mar 9, 2004 1:46:21 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.2
Mar 9, 2004 1:46:21 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Mar 9, 2004 1:46:21 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Mar 9, 2004 1:46:22 PM net.sf.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Mar 9, 2004 1:46:22 PM net.sf.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Mar 9, 2004 1:46:23 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: user.fr.hbm.xml
Mar 9, 2004 1:46:25 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: com.plexsci.foo.HibernateExUser -> usersex
Mar 9, 2004 1:46:27 PM net.sf.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Mar 9, 2004 1:46:27 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Mar 9, 2004 1:46:27 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Mar 9, 2004 1:46:27 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Mar 9, 2004 1:46:27 PM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.SQLServerDialect
Mar 9, 2004 1:46:27 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
Mar 9, 2004 1:46:27 PM net.sf.hibernate.util.NamingHelper getInitialContext
INFO: JNDI InitialContext properties:{}
Mar 9, 2004 1:46:27 PM net.sf.hibernate.connection.DatasourceConnectionProvider configure
INFO: Using datasource: java:comp/env/jdbc/SQLServer/foo
Mar 9, 2004 1:46:27 PM net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
Mar 9, 2004 1:46:27 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
Mar 9, 2004 1:46:27 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): false
Mar 9, 2004 1:46:27 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
Mar 9, 2004 1:46:27 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Mar 9, 2004 1:46:27 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.ehcache.hibernate.Provider


I have my debugger on and the code steps through the first line (Session object creation), and into the static code of the HibernateUtil class, but does not reach any other code in my application. Obviously, no object gets stored in the database, because no object is ever created in memory as far as I can tell. No exceptions are thrown or reported. Can anyone tell me what might be going on? Why is nothing happening beyond the configuration?


Top
 Profile  
 
 Post subject: New information
PostPosted: Tue Mar 09, 2004 3:12 pm 
Newbie

Joined: Tue Mar 09, 2004 2:44 pm
Posts: 15
It seems to be a null pointer exception somewhere that I can not pinpoint within the
Code:
sessionFactory = new Configuration().configure().buildSessionFactory();
line of method calls.

Any help to anyone?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 3:26 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
Post the NullPointerException stack trace. Sounds like some kind of configuration problem.

Cheers!
Rob


Top
 Profile  
 
 Post subject: NullPointer stack - and further pinpointing...
PostPosted: Tue Mar 09, 2004 3:35 pm 
Newbie

Joined: Tue Mar 09, 2004 2:44 pm
Posts: 15
The NullPointer stack comes through the jsp error handling and seems very unhelpful:

Code:
null java.lang.NullPointerException at org.apache.jsp.error$jsp._jspService(error$jsp.java:134) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355) at org.apache.catalina.valves.ErrorDispatcherValve.custom(ErrorDispatcherValve.java:391) at org.apache.catalina.valves.ErrorDispatcherValve.throwable(ErrorDispatcherValve.java:250) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:178) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:368) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125) at java.lang.Thread.run(Thread.java:536)


The error seems to be in the buildSessionFactory() method. I agree it seems to be a configuration issue, but I believe (probably incorrectly) I followed the tutorial pretty closely. Is there a gotcha with SQL Server and/or identity columns, the main changes I made from the tutorial's Postgres?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 3:40 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
Hm. You could try changing your example to catch Exception instead of just HibernateException and print the stack trace. That would probably give you the REAL NullPointerException stack trace which is what would be very helpful here. Don't know about any specific SQL Server issues -- haven't used it with Hibernate.

Cheers,
Rob


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 3:53 pm 
Newbie

Joined: Tue Mar 09, 2004 2:44 pm
Posts: 15
The underlying exception (I think we're getting closer) message:
could not instantiate CacheProvider: net.sf.ehcache.hibernate.Provider

There is nothing about this in the tutorial.

Thanks,

CJ


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 3:55 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Cop ehcache.jar to your classpath or use the hibernate.properties file from the distribution. This looks like a wrong default setting we have to fix. I'm on it.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 3:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Take a look at this FAQ please: http://www.hibernate.org/74.html#A29


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 4:06 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Fixed in CVS.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 4:09 pm 
Newbie

Joined: Tue Mar 09, 2004 2:44 pm
Posts: 15
Thanks, everything is still not working right, but I can tell where these are coming from (my own bad configs). Will write again if I get stuck.

_________________
Thanks,
CJ


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 2:04 pm 
Newbie

Joined: Tue Mar 09, 2004 2:44 pm
Posts: 15
P.S. I also needed to add jta.jar before everything worked okay.

_________________
Thanks,
CJ


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