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.  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Please Help
PostPosted: Tue Nov 06, 2007 4:16 am 
Newbie

Joined: Tue Nov 06, 2007 4:12 am
Posts: 17
I have a simple DAO that has this function.
public List findAll() {
log.debug("finding all PokerSites instances");
try {
String queryString = "from PokerSites";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();

} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}


In my struts ActionClass I have this simple line
PokerSitesDAO test = new PokerSitesDAO();
List services = test.findAll();

I get this error

java.lang.NullPointerException
com.gerberdata.poker.PokerSitesDAO.findAll(PokerSitesDAO.java:99)
com.gerberdata.poker.ShowSitesAction.execute(ShowSitesAction.java:35)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Any Idea Why this is happening. This works fine if I don't use the web and just run a java class as an application with the same function call. I would appreciate anyones input.
Dave


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 06, 2007 4:54 am 
Newbie

Joined: Wed Oct 31, 2007 5:36 pm
Posts: 13
What is PokerSitesDAO.java line 99?

That will tell us exactly what is null when invoked.

Possibilities include:

the log attribute is not instantiated correctly
configuration issue with getSession() returning null


Need to know what line 99 references to pinpoint error.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 06, 2007 8:49 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
getSession() must be returning null. How and where is getSession() implemented? I'm betting its an initialisation issue. Check you web/servlet logs for init errors.


Top
 Profile  
 
 Post subject: reply
PostPosted: Tue Nov 06, 2007 11:38 am 
Newbie

Joined: Tue Nov 06, 2007 4:12 am
Posts: 17
This is line 99.
Query queryObject = getSession().createQuery(queryString)

I was thinking the same thing but where do I instanciate the session object?

This was a class that myeclipse created automatically. Do I create a session somewhere in order for the queryQbject to instanciate correctly?


Top
 Profile  
 
 Post subject: and
PostPosted: Tue Nov 06, 2007 12:00 pm 
Newbie

Joined: Tue Nov 06, 2007 4:12 am
Posts: 17
where do I find the logs. I have no idea where my log files are written. Sorry kind of a newbie.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 06, 2007 12:19 pm 
Newbie

Joined: Thu Oct 25, 2007 3:37 pm
Posts: 17
Documentation for your server will show you where the server logs are. You can also implement some sort of application level logging, but you probably didn't do this if you super nooby. Don't sweat it, just look at your server docs and see wehre the logs are; there will probably be several different logs, you just need to find the one.


Top
 Profile  
 
 Post subject: Server Logs
PostPosted: Tue Nov 06, 2007 2:02 pm 
Newbie

Joined: Tue Nov 06, 2007 4:12 am
Posts: 17
When you say server logs do you mean tomcat?


Top
 Profile  
 
 Post subject: getSession()
PostPosted: Tue Nov 06, 2007 2:13 pm 
Newbie

Joined: Tue Nov 06, 2007 4:12 am
Posts: 17
can anyone explain how getSession() works. What would cause it to create a null instance. This code works fine if I run it as a java application but doesn't work in the struts Action Class.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 06, 2007 3:56 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 9:20 am
Posts: 74
we can't know, it's your method...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 06, 2007 4:14 pm 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
Are you creating a WAR file for tomcat? Your hibernate config might not be accessible in the WAR file - perhaps its not even included in the WAR or your initialising with a FILE reference. Expand the WAR and check the config file is present.

Again, I'm guessing.

Please post more details such as the implementation of the getSession method, how you initialise hibernate and perhaps a content listing of the WAR file.

The location of the tomcat logs might depend on the version you're running - please specify. For example, if running tomcat 6.0.14 check apache-tomcat-6.0.14/logs/localhost.2007-11-06.log (today's log file).


Top
 Profile  
 
 Post subject: Response
PostPosted: Tue Nov 06, 2007 4:44 pm 
Newbie

Joined: Tue Nov 06, 2007 4:12 am
Posts: 17
I am not creating a war file I am running this using myeclipse which does all that stuff automatically. I did see this in my server consold
INFO: Server startup in 12981 ms
%%%% Error Creating SessionFactory %%%%

I think it does have something to do with the session. I basically referse engineered for hibernate one database table and myeclipse created a DAO class and it also has a a SessionFactory class which calls this function getSession()

public static Session getSession() throws HibernateException {
Session session = (Session) threadLocal.get();

if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ? sessionFactory.openSession()
: null;
threadLocal.set(session);
}

return session;
}

Query queryObject = getSession().createQuery(queryString);


Top
 Profile  
 
 Post subject: hibernate config
PostPosted: Tue Nov 06, 2007 4:50 pm 
Newbie

Joined: Tue Nov 06, 2007 4:12 am
Posts: 17
I think it might be the location of the hibernate config file. Is there a specific place this should go?


Top
 Profile  
 
 Post subject: Reply
PostPosted: Tue Nov 06, 2007 5:02 pm 
Newbie

Joined: Tue Nov 06, 2007 4:12 am
Posts: 17
This is in the java file
Location of hibernate.cfg.xml file.
* Location should be on the classpath as Hibernate uses
* #resourceAsStream style lookup for its configuration file.


so what do they mean by classpath. The classpath of specific class?


Top
 Profile  
 
 Post subject: New Error
PostPosted: Tue Nov 06, 2007 5:53 pm 
Newbie

Joined: Tue Nov 06, 2007 4:12 am
Posts: 17
This is my new error

org.apache.commons.collections.SequencedHashMap"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 07, 2007 5:01 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
Could be an issue with myeclipse. Might need to upgrade to 6.0 GA according to this:
http://www.myeclipseide.com/PNphpBB2-printview-t-18247-start-45.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 22 posts ]  Go to page 1, 2  Next

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.