Anas,

Your Dao must be a service managed by tapestry for it to benefit from the
injection of the rest of tapestry services. To ensure that ,
make sure you bind it in the application module. If you used the archetype
to generate the application, then there is  module class in the services
directory. The class is well commented with an example on how to bind a
service

Something like bind(MyDaoInterface.class ,
MyDaoInterfaceImplementation.class);


regards.
On Wed, Nov 10, 2010 at 1:40 AM, Anas Mughal <anasmug...@yahoo.com> wrote:

> Yes, tapestry-hibernate dependency is added:
>
> <dependency>
> <groupId>org.apache.tapestry</groupId>
> <artifactId>tapestry-hibernate</artifactId>
> <version>5.2.2</version>
> </dependency>
>
> And, it is being resolved and included successfully in the project.
>
> The hibernate configuration seems to be picked up properly as well. (There
> was a problem with the path to the mapping files. After fixing it, now there
> is no error with respect to the hibernate configuration.)
>
> I don't know how to resolve the session object being NULL in my simple DAO
> below.
>
>
>
>
>
>
>
> Thanks for your help!
> --
> Anas Mughal
>
> http://anas-mughal.com
>
>
>
>
>
>
> --- On Wed, 11/10/10, Josh Kamau <joshnet2...@gmail.com> wrote:
>
>
> From: Josh Kamau <joshnet2...@gmail.com>
> Subject: Re: session is NULL
> To: "Tapestry users" <users@tapestry.apache.org>
> Date: Wednesday, November 10, 2010, 1:04 AM
>
>
> Hi Anas;
>
> Have you added the tapestry-hibernate dependency on your pom.xml?
>
> On Wed, Nov 10, 2010 at 12:52 AM, Anas Mughal <anasmug...@yahoo.com>
> wrote:
>
> > I have setup my Tapestry project using the Maven archetype. Then, I setup
> > my hibernate.cfg.xml file with references to my hibernate mapping files.
> (I
> > am not using annotations for hibernate.)
> >
> > Now, I have setup a simple DAO object to try to retrieve an object from
> the
> > database:
> >
> > public class BranchDAO {
> >
> >     @Inject
> >     private Session session;
> >
> >     @SuppressWarnings("unchecked")
> >     public Object find( Class c , BigDecimal id)
> >     {
> >         return  session.get(c, id);  // session is NULL here
> >     }
> > }
> >
> >
> > I get a NULL pointer exception because my session does not seem to be
> >  initialized.
> >
> > Searching online, I came accross:
> > http://wiki.apache.org/tapestry/SessionPagePersistence
> >
> > I have not setup any hivemind configuration or any of the suggested
> classes
> > on that wiki page. Please advise me what do I need to be able to fetch
> > objects using Tapestry-Hibernate. I don't know where to place the
> hivemind
> > configuration file -- if I need it.
> >
> > I am new to Tapestry. Please bear with me.
> >
> > Thank you for your kind assistance.
> > --Anas Mughal
> > http://anas-mughal.com
> >
> >
> >
> >
> >
>
>
>
>
>

Reply via email to