Re: session is NULL

2010-11-11 Thread Everton Agner
 @Inject is for pages. Make your DAO a Tapestry service and inject the
 session to it via its constructor.

 Kalle

I guess not... Since the DAO is a service, you can either @Inject fields,
pass thru construtuctor call or build them.

___
Everton Agner Ramos


2010/11/10 Anas Mughal anasmug...@yahoo.com

 Yes, that worked. I wish to thank everyone for their help!

 Tapestry is great!
 Coming from the Spring world, I do not miss those verbose Spring
 configuration files!

 --Anas Mughal
 http://anas-mughal.com


 --- On Wed, 11/10/10, Rich M rich...@moremagic.com wrote:

 From: Rich M rich...@moremagic.com
 Subject: Re: session is NULL
 To: Tapestry users users@tapestry.apache.org
 Date: Wednesday, November 10, 2010, 10:34 AM

 On 11/10/2010 03:42 AM, Anas Mughal wrote:
  I have setup my DAO as a Tapestry service in the AppModule as:
   public class AppModule
 {
public static void bind(ServiceBinder binder)
{
  binder.bind(BranchDAO.class, BranchHibernateDAO.class);
 
}
 }
  Then, I try to inject the session as follows:
 public class BranchHibernateDAO implements BranchDAO {
 
@Inject
private Session session;
 
 
 @SuppressWarnings(unchecked)
public Object find( Class c , BigDecimal id)
{
  return session.get(c, id);
}
 
 }
 
  I still get a NULL session.
 
 
 
 
 
 
 
  Following the suggestion by Kalle, I injected the session to a page.
 Then, passed the session to my DAO in the contructor. That worked! However,
 I would rather keep the code cleaner by injecting the session directly into
 the DAO.
 
 To use the DAO, you will want the following setup.

 public class BranchHibernateDAO implements BranchDAO {

 private Session session;

 public BranchHibernateDAO(Session session){

 this.session = session;

 }

 ...

 }


 then in your page class:

 @Inject

 private BranchHibernateDAO bhdao;


 You do not need to initialize the BranchHibernateDAO yourself. Tapestry-IoC
 will initialize the BranchHibernateDAO lazily behind the scenes the first
 time you access it in the web application. In this case, that would be when
 you navigate to the page relating to your page class, where the DAO is
 injected.

 The convention for services, is that when they are setup in the bind method
 of the AppModule (or whatever your module is called), Tapestry will inject
 the appropriate objects to its constructor when it initializes the service.

 This convention will keep your page classes cleaner.
Any suggestion would be greatly appreciated.
  --- On Wed, 11/10/10, Kalle Korhonenkalle.o.korho...@gmail.com  wrote:
 
 
  From: Kalle Korhonenkalle.o.korho...@gmail.com
  Subject: Re: session is NULL
  To: Tapestry usersusers@tapestry.apache.org
  Date: Wednesday, November 10, 2010, 1:48 AM
 
 
  @Inject is for pages. Make your DAO a Tapestry service and inject the
  session to it via its constructor.
 
  Kalle
 
 
  On Tue, Nov 9, 2010 at 9:52 PM, Anas Mughalanasmug...@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
 
 
 
 
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
  For additional commands, e-mail: users-h...@tapestry.apache.org
 
 
 
 
 
 


 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org








Re: session is NULL

2010-11-11 Thread Anas Mughal

I initially had a constructor that accepted a session. That worked fine.

Then, I took out the constructor and simply injected the session. That is 
working fine as well.

Now, I am injecting my delegate as service into my page. The DAO is injected to 
my delegate. Then, the session is injected into my DAO. That is working well 
for me. (No constructors.)

Best Regards. 
--Anas Mughal
http://anas-mughal.com 
 

--- On Thu, 11/11/10, Everton Agner ton.ag...@gmail.com wrote:

From: Everton Agner ton.ag...@gmail.com
Subject: Re: session is NULL
To: Tapestry users users@tapestry.apache.org
Date: Thursday, November 11, 2010, 8:23 AM

 @Inject is for pages. Make your DAO a Tapestry service and inject the
 session to it via its constructor.

 Kalle

I guess not... Since the DAO is a service, you can either @Inject fields,
pass thru construtuctor call or build them.

___
Everton Agner Ramos


2010/11/10 Anas Mughal anasmug...@yahoo.com

 Yes, that worked. I wish to thank everyone for their help!

 Tapestry is great!
 Coming from the Spring world, I do not miss those verbose Spring
 configuration files!

 --Anas Mughal
 http://anas-mughal.com


 --- On Wed, 11/10/10, Rich M rich...@moremagic.com wrote:

 From: Rich M rich...@moremagic.com
 Subject: Re: session is NULL
 To: Tapestry users users@tapestry.apache.org
 Date: Wednesday, November 10, 2010, 10:34 AM

 On 11/10/2010 03:42 AM, Anas Mughal wrote:
  I have setup my DAO as a Tapestry service in the AppModule as:
       public class AppModule
     {
        public static void bind(ServiceBinder binder)
        {
          binder.bind(BranchDAO.class, BranchHibernateDAO.class);
 
        }
     }
      Then, I try to inject the session as follows:
         public class BranchHibernateDAO implements BranchDAO {
 
      �...@inject
        private Session session;
 
 
             @SuppressWarnings(unchecked)
        public Object find( Class c , BigDecimal id)
        {
          return session.get(c, id);
        }
 
     }
 
  I still get a NULL session.
 
 
 
 
 
 
 
  Following the suggestion by Kalle, I injected the session to a page.
 Then, passed the session to my DAO in the contructor. That worked! However,
 I would rather keep the code cleaner by injecting the session directly into
 the DAO.
 
 To use the DAO, you will want the following setup.

 public class BranchHibernateDAO implements BranchDAO {

     private Session session;

     public BranchHibernateDAO(Session session){

         this.session = session;

     }

     ...

 }


 then in your page class:

 @Inject

 private BranchHibernateDAO bhdao;


 You do not need to initialize the BranchHibernateDAO yourself. Tapestry-IoC
 will initialize the BranchHibernateDAO lazily behind the scenes the first
 time you access it in the web application. In this case, that would be when
 you navigate to the page relating to your page class, where the DAO is
 injected.

 The convention for services, is that when they are setup in the bind method
 of the AppModule (or whatever your module is called), Tapestry will inject
 the appropriate objects to its constructor when it initializes the service.

 This convention will keep your page classes cleaner.
    Any suggestion would be greatly appreciated.
  --- On Wed, 11/10/10, Kalle Korhonenkalle.o.korho...@gmail.com  wrote:
 
 
  From: Kalle Korhonenkalle.o.korho...@gmail.com
  Subject: Re: session is NULL
  To: Tapestry usersusers@tapestry.apache.org
  Date: Wednesday, November 10, 2010, 1:48 AM
 
 
  @Inject is for pages. Make your DAO a Tapestry service and inject the
  session to it via its constructor.
 
  Kalle
 
 
  On Tue, Nov 9, 2010 at 9:52 PM, Anas Mughalanasmug...@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
 
 
 
 
 
 
  -
  To unsubscribe, e-mail: users-unsubscr

Re: session is NULL

2010-11-10 Thread Anas Mughal

I have setup my DAO as a Tapestry service in the AppModule as:
 
  public class AppModule
  {
     public static void bind(ServiceBinder binder)
     {
   binder.bind(BranchDAO.class, BranchHibernateDAO.class);

 }
  }
 
 
Then, I try to inject the session as follows:
 
 
  public class BranchHibernateDAO implements BranchDAO {

     @Inject
     private Session session;



    �...@suppresswarnings(unchecked)
     public Object find( Class c , BigDecimal id)
     {
       return session.get(c, id);
     }

  }
 

I still get a NULL session.
 
 







Following the suggestion by Kalle, I injected the session to a page. Then, 
passed the session to my DAO in the contructor. That worked! However, I would 
rather keep the code cleaner by injecting the session directly into the DAO. 
 
Any suggestion would be greatly appreciated. 
 
 
 
 
 
 
 

--- On Wed, 11/10/10, Kalle Korhonen kalle.o.korho...@gmail.com wrote:


From: Kalle Korhonen kalle.o.korho...@gmail.com
Subject: Re: session is NULL
To: Tapestry users users@tapestry.apache.org
Date: Wednesday, November 10, 2010, 1:48 AM


@Inject is for pages. Make your DAO a Tapestry service and inject the
session to it via its constructor.

Kalle


On Tue, Nov 9, 2010 at 9:52 PM, 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






-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org




  

Re: session is NULL

2010-11-10 Thread ael

Kindly visit my post.

http://tapestry.1045711.n5.nabble.com/T5-Working-Tapestry-Hibernate-with-DAO-td3229905.html#a3229905
http://tapestry.1045711.n5.nabble.com/T5-Working-Tapestry-Hibernate-with-DAO-td3229905.html#a3229905
 
-- 
View this message in context: 
http://tapestry.1045711.n5.nabble.com/session-is-NULL-tp3258165p3258344.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: session is NULL

2010-11-10 Thread Cezary Biernacki
On Wed, Nov 10, 2010 at 9:42 AM, Anas Mughal anasmug...@yahoo.com wrote:


 I have setup my DAO as a Tapestry service in the AppModule as:


[...]


Then, I try to inject the session as follows:

   public class BranchHibernateDAO implements BranchDAO {

  @Inject
  private Session session;


  @SuppressWarnings(unchecked)
  public Object find( Class c , BigDecimal id)
  {
return session.get(c, id);
  }

   }


 I still get a NULL session.


 Following the suggestion by Kalle, I injected the session to a page. Then,
 passed the session to my DAO in the contructor. That worked! However, I
 would rather keep the code cleaner by injecting the session directly into
 the DAO.

 Any suggestion would be greatly appreciated.



How do you access an instance of BranchHibernateDAO?

I suspect that you might create it using 'new'. That is not correct. Use
Tapestry injections instead, e.g. in your page or component:

@Inject
private BranchDAO dao;

Regards,
Cezary


Re: session is NULL

2010-11-10 Thread Rich M

On 11/10/2010 03:42 AM, Anas Mughal wrote:

I have setup my DAO as a Tapestry service in the AppModule as:
  
   public class AppModule

   {
  public static void bind(ServiceBinder binder)
  {
binder.bind(BranchDAO.class, BranchHibernateDAO.class);

  }
   }
  
  
Then, I try to inject the session as follows:
  
  
   public class BranchHibernateDAO implements BranchDAO {


  @Inject
  private Session session;


 
  @SuppressWarnings(unchecked)

  public Object find( Class c , BigDecimal id)
  {
return session.get(c, id);
  }

   }
  


I still get a NULL session.
  
  








Following the suggestion by Kalle, I injected the session to a page. Then, 
passed the session to my DAO in the contructor. That worked! However, I would 
rather keep the code cleaner by injecting the session directly into the DAO.
   

To use the DAO, you will want the following setup.

public class BranchHibernateDAO implements BranchDAO {

private Session session;

public BranchHibernateDAO(Session session){

this.session = session;

}

...

}


then in your page class:

@Inject

private BranchHibernateDAO bhdao;


You do not need to initialize the BranchHibernateDAO yourself. 
Tapestry-IoC will initialize the BranchHibernateDAO lazily behind the 
scenes the first time you access it in the web application. In this 
case, that would be when you navigate to the page relating to your page 
class, where the DAO is injected.


The convention for services, is that when they are setup in the bind 
method of the AppModule (or whatever your module is called), Tapestry 
will inject the appropriate objects to its constructor when it 
initializes the service.


This convention will keep your page classes cleaner.
  
Any suggestion would be greatly appreciated. 
  
  
  
  
  
  
  


--- On Wed, 11/10/10, Kalle Korhonenkalle.o.korho...@gmail.com  wrote:


From: Kalle Korhonenkalle.o.korho...@gmail.com
Subject: Re: session is NULL
To: Tapestry usersusers@tapestry.apache.org
Date: Wednesday, November 10, 2010, 1:48 AM


@Inject is for pages. Make your DAO a Tapestry service and inject the
session to it via its constructor.

Kalle


On Tue, Nov 9, 2010 at 9:52 PM, Anas Mughalanasmug...@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





 

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





   



-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: session is NULL

2010-11-10 Thread Anas Mughal
Yes, that worked. I wish to thank everyone for their help! 
 
Tapestry is great!
Coming from the Spring world, I do not miss those verbose Spring configuration 
files!

--Anas Mughal 
http://anas-mughal.com 


--- On Wed, 11/10/10, Rich M rich...@moremagic.com wrote:

From: Rich M rich...@moremagic.com
Subject: Re: session is NULL
To: Tapestry users users@tapestry.apache.org
Date: Wednesday, November 10, 2010, 10:34 AM

On 11/10/2010 03:42 AM, Anas Mughal wrote:
 I have setup my DAO as a Tapestry service in the AppModule as:
      public class AppModule
    {
       public static void bind(ServiceBinder binder)
       {
         binder.bind(BranchDAO.class, BranchHibernateDAO.class);
 
       }
    }
     Then, I try to inject the session as follows:
        public class BranchHibernateDAO implements BranchDAO {
 
     �...@inject
       private Session session;
 
 
            @SuppressWarnings(unchecked)
       public Object find( Class c , BigDecimal id)
       {
         return session.get(c, id);
       }
 
    }
   
 I still get a NULL session.
     
 
 
 
 
 
 
 Following the suggestion by Kalle, I injected the session to a page. Then, 
 passed the session to my DAO in the contructor. That worked! However, I would 
 rather keep the code cleaner by injecting the session directly into the DAO.
    
To use the DAO, you will want the following setup.

public class BranchHibernateDAO implements BranchDAO {

    private Session session;

    public BranchHibernateDAO(Session session){

        this.session = session;

    }

    ...

}


then in your page class:

@Inject

private BranchHibernateDAO bhdao;


You do not need to initialize the BranchHibernateDAO yourself. Tapestry-IoC 
will initialize the BranchHibernateDAO lazily behind the scenes the first time 
you access it in the web application. In this case, that would be when you 
navigate to the page relating to your page class, where the DAO is injected.

The convention for services, is that when they are setup in the bind method of 
the AppModule (or whatever your module is called), Tapestry will inject the 
appropriate objects to its constructor when it initializes the service.

This convention will keep your page classes cleaner.
   Any suggestion would be greatly appreciated.               
 --- On Wed, 11/10/10, Kalle Korhonenkalle.o.korho...@gmail.com  wrote:
 
 
 From: Kalle Korhonenkalle.o.korho...@gmail.com
 Subject: Re: session is NULL
 To: Tapestry usersusers@tapestry.apache.org
 Date: Wednesday, November 10, 2010, 1:48 AM
 
 
 @Inject is for pages. Make your DAO a Tapestry service and inject the
 session to it via its constructor.
 
 Kalle
 
 
 On Tue, Nov 9, 2010 at 9:52 PM, Anas Mughalanasmug...@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
 
 
 
 
 
      
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 
 
 
 
 
    


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org




  

session is NULL

2010-11-09 Thread Anas Mughal
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

 


  

Re: session is NULL

2010-11-09 Thread Josh Kamau
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







Re: session is NULL

2010-11-09 Thread Anas Mughal
Yes, tapestry-hibernate dependency is added:
 
dependency
groupIdorg.apache.tapestry/groupId
artifactIdtapestry-hibernate/artifactId
version5.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








  

Re: session is NULL

2010-11-09 Thread Josh Kamau
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
 groupIdorg.apache.tapestry/groupId
 artifactIdtapestry-hibernate/artifactId
 version5.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
 
 
 
 
 







Re: session is NULL

2010-11-09 Thread Kalle Korhonen
@Inject is for pages. Make your DAO a Tapestry service and inject the
session to it via its constructor.

Kalle


On Tue, Nov 9, 2010 at 9:52 PM, 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






-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: [T5]: Hibernate question - session is null

2008-07-28 Thread 9902468

Is the hibernate service initialized at all? When Tapestry starts it lists
all known services, is Hibernate in that list?

 - 99


photos-4 wrote:
 
 Thanks for your help, but so far no joy:
 
 Quoting 9902468 [EMAIL PROTECTED]:
 
 And of course, check that you have Hibernate and hibernate  
 annotation in your libraries, they are NOT included automatically  
 by maven if maven is used.
 
 The libraries appear in my repository and appear under sources in  
 the Eclipse Run Configuration.
 
 

 Tapestry should be quite verbose about hibernate if tapestry is
 configured to
 run in debug mode:

 http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html

 add:

 
 I placed -Dtapestry.production-mode=false on the command line, which,  
 according to the docs, does the same thing.
 
 I see no output about Hibernate at all. It never gets mentioned...
 
 
 Also see that your entities are in correct place (same root package as
 pages
 and components, in entities package.)
 
 src/main/java/uk.bl.dlportal.entities
 src/main/java/uk.bl.dlportal.components
 src/main/java/uk.bl.dlportal.pages
 
 looks ok to me.
 
 
 Also perhaps use org.hibernate.dialect.MySQLInnoDBDialect to support
 foreign
 keys? (Change to hibernate config.)

 You should be able to see that Hibernate starts in the logs and maps User
 etc. classes.

 Remember to configure your Log4J or what ever logging u use to debug.
 
 I added some lines to log4j.properties to turn on hibernate logging  
 (debug), but I see no output - just the usual Tapestry debug output  
 that I've seen before.
 
 I'm really stumped... :-(  Hibernate never gets called and yet  
 everything appears to be in place.
 
 p.
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18684648.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5]: Hibernate question - session is null

2008-07-28 Thread photos

Quoting 9902468 [EMAIL PROTECTED]:



Is the hibernate service initialized at all? When Tapestry starts it lists
all known services, is Hibernate in that list?

 - 99



It looks like it:

...
   FieldValidationSupport: DEFINED
  FieldValidatorDefaultSource: DEFINED
 FieldValidatorSource: DEFINED
  FormSupport: DEFINED
HibernateEntityPackageManager: DEFINED
  HibernateSessionManager: DEFINED
   HibernateSessionSource: DEFINED
HibernateTransactionDecorator: DEFINED
 HiddenFieldLocationRules: DEFINED
   HttpServletRequest: DEFINED
HttpServletRequestHandler: VIRTUAL
   IgnoredPathsFilter: DEFINED
InjectionProvider: DEFINED
   InternalRequestGlobals: VIRTUAL
  LinkFactory: DEFINED
...


I still haven't figured out what is going on. I see no evidence of  
Hibernate ever being called. Are any Hibernate services missing from  
the above list?


p.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5]: Hibernate question - session is null

2008-07-28 Thread 9902468

Check also that you have the mysql-connector-java-5.1.6.jar or similar in
your libraries.

I have the following list:
FieldValidatorSource: DEFINED
  FormDAO: DEFINED
  FormSupport: DEFINED
FreeMarkerService: DEFINED
   FulfillmentDAO: DEFINED
 GoogleMapService: DEFINED
HibernateEntityPackageManager: DEFINED
  HibernateSessionManager: DEFINED
   HibernateSessionSource: DEFINED
HibernateTransactionDecorator: DEFINED
 HiddenFieldLocationRules: DEFINED
 HiveMind: DEFINED
   HttpServletRequest: DEFINED
HttpServletRequestHandler: VIRTUAL
   IgnoredPathsFilter: DEFINED

So that one should be ok. Is the page that you are testing with _really_
calling session.something? Tapestry lazy loads everything so Hibernate is
not really initialized without the call. Can we have the stack trace?

 - 99



photos-4 wrote:
 
 Quoting 9902468 [EMAIL PROTECTED]:
 

 Is the hibernate service initialized at all? When Tapestry starts it
 lists
 all known services, is Hibernate in that list?

  - 99
 
 
 It looks like it:
 
 ...
 FieldValidationSupport: DEFINED
FieldValidatorDefaultSource: DEFINED
   FieldValidatorSource: DEFINED
FormSupport: DEFINED
  HibernateEntityPackageManager: DEFINED
HibernateSessionManager: DEFINED
 HibernateSessionSource: DEFINED
  HibernateTransactionDecorator: DEFINED
   HiddenFieldLocationRules: DEFINED
 HttpServletRequest: DEFINED
  HttpServletRequestHandler: VIRTUAL
 IgnoredPathsFilter: DEFINED
  InjectionProvider: DEFINED
 InternalRequestGlobals: VIRTUAL
LinkFactory: DEFINED
 ...
 
 
 I still haven't figured out what is going on. I see no evidence of  
 Hibernate ever being called. Are any Hibernate services missing from  
 the above list?
 
 p.
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18685754.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5]: Hibernate question - session is null

2008-07-28 Thread photos
Ok, I have just checked. I have mysql-connector-java-5.1.5.jar in the  
maven repository.



Code is:
-
package uk.bl.dlportal.pages.util;

import java.util.List;

import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;


import uk.bl.dlportal.entities.User;


public class Security
{
@Inject
private Session session;

private final static Security security = new Security();


public User authenticate(String userName, String password)
{
System.out.println(SESSION   
+session);


Criteria c = session.createCriteria(User.class);

List result = c.list();

System.out.println(SESSION   
+session);


return null;
}

public static Security getSecurity()
{
return security;
}
}


Stack trace is:

84.73% unrealized services (111/131)

[INFO] mortbay.log Started [EMAIL PROTECTED]:8080
[DEBUG] AppModule.TimingFilter Creating service 'TimingFilter'.
[DEBUG] AppModule.TimingFilter Invoking method
uk.bl.dlportal.services.AppModule.buildTimingFilter(Logger) (at  
AppModule.java:71).

[INFO] AppModule.TimingFilter Request time: 4846 ms
[INFO] AppModule.TimingFilter Request time: 0 ms
[INFO] AppModule.TimingFilter Request time: 16 ms
SESSION  null
[INFO] AppModule.TimingFilter Request time: 251 ms
[ERROR] TapestryModule.RequestExceptionHandler Processing of request  
failed with uncaught

exception: org.apache.tapestry5.runtime.ComponentEventException
org.apache.tapestry5.runtime.ComponentEventException [at  
context:Index.tml, line 7,

column 28]
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1042)
at
org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:67)
at
org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42)
at
$ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java)
at  
org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42)

at
$ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java)
at  
org.apache.tapestry5.services.TapestryModule$37.handle(TapestryModule.java:1987)

at
$ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java)
at
$ComponentEventRequestHandler_11b68bd500b.handle($ComponentEventRequestHandler_11b68bd500b.java)
at
org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:135)
at $Dispatcher_11b68bd500e.dispatch($Dispatcher_11b68bd500e.java)
at $Dispatcher_11b68bd5000.dispatch($Dispatcher_11b68bd5000.java)
at  
org.apache.tapestry5.services.TapestryModule$12.service(TapestryModule.java:938)

at uk.bl.dlportal.services.AppModule$1.service(AppModule.java:84)
at $RequestFilter_11b68bd4fff.service($RequestFilter_11b68bd4fff.java)
at  
$RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)

at
org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42)
at  
$RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at  
org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:586)
at  
$RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)

at
org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
at  
$RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)

at
org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79)
at  
$RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)

at
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
at
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
at
org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:75)
at
org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106)
at  
$RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at  
$RequestHandler_11b68bd4ff8.service($RequestHandler_11b68bd4ff8.java)
at  
org.apache.tapestry5.services.TapestryModule$11.service(TapestryModule.java:918)

at
org.apache.tapestry5.internal.services.IgnoredPathsFilter.service

Re: [T5]: Hibernate question - session is null

2008-07-28 Thread Sven Homburg
its look like, that your Security class is only a helper class
and no page component.

in such classes the @Inject annotation doesnt work

2008/7/28 [EMAIL PROTECTED]

 Ok, I have just checked. I have mysql-connector-java-5.1.5.jar in the maven
 repository.


 Code is:
 -
 package uk.bl.dlportal.pages.util;

 import java.util.List;

 import org.apache.tapestry5.ioc.annotations.Inject;
 import org.hibernate.Criteria;
 import org.hibernate.Query;
 import org.hibernate.Session;


 import uk.bl.dlportal.entities.User;


 public class Security
 {
@Inject
private Session session;

private final static Security security = new Security();


public User authenticate(String userName, String password)
{
System.out.println(SESSION 
 +session);

Criteria c = session.createCriteria(User.class);

List result = c.list();

System.out.println(SESSION 
 +session);

return null;
}

public static Security getSecurity()
{
return security;
}
 }


 Stack trace is:
 
 84.73% unrealized services (111/131)

 [INFO] mortbay.log Started [EMAIL PROTECTED]:8080
 [DEBUG] AppModule.TimingFilter Creating service 'TimingFilter'.
 [DEBUG] AppModule.TimingFilter Invoking method
 uk.bl.dlportal.services.AppModule.buildTimingFilter(Logger) (at
 AppModule.java:71).
 [INFO] AppModule.TimingFilter Request time: 4846 ms
 [INFO] AppModule.TimingFilter Request time: 0 ms
 [INFO] AppModule.TimingFilter Request time: 16 ms
 SESSION  null
 [INFO] AppModule.TimingFilter Request time: 251 ms
 [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed
 with uncaught
 exception: org.apache.tapestry5.runtime.ComponentEventException
 org.apache.tapestry5.runtime.ComponentEventException [at context:Index.tml,
 line 7,
 column 28]
at

 org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1042)
at

 org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:67)
at

 org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42)
at

 $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java)
at
 org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42)
at

 $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java)
at
 org.apache.tapestry5.services.TapestryModule$37.handle(TapestryModule.java:1987)
at

 $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java)
at

 $ComponentEventRequestHandler_11b68bd500b.handle($ComponentEventRequestHandler_11b68bd500b.java)
at

 org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:135)
at $Dispatcher_11b68bd500e.dispatch($Dispatcher_11b68bd500e.java)
at $Dispatcher_11b68bd5000.dispatch($Dispatcher_11b68bd5000.java)
at
 org.apache.tapestry5.services.TapestryModule$12.service(TapestryModule.java:938)
at uk.bl.dlportal.services.AppModule$1.service(AppModule.java:84)
at
 $RequestFilter_11b68bd4fff.service($RequestFilter_11b68bd4fff.java)
at
 $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at

 org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42)
at
 $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at
 org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:586)
at
 $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at

 org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
at
 $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at

 org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79)
at
 $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at

 org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
at

 org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
at

 org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:75)
at

 org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106)
at
 $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at
 $RequestHandler_11b68bd4ff8.service

Re: [T5]: Hibernate question - session is null

2008-07-28 Thread 9902468

Yep, Injection works only in page and component classes that live the
ordinary Page or component lifecycle, and are requested from the web. :)

Move the session to a real page and have that util to take the session as
parameter, or even better move your logic to service that a page can use.
(SecurityService perhaps?)

 - 99


Sven Homburg wrote:
 
 its look like, that your Security class is only a helper class
 and no page component.
 
 in such classes the @Inject annotation doesnt work
 
 2008/7/28 [EMAIL PROTECTED]
 
 Ok, I have just checked. I have mysql-connector-java-5.1.5.jar in the
 maven
 repository.


 Code is:
 -
 package uk.bl.dlportal.pages.util;

 import java.util.List;

 import org.apache.tapestry5.ioc.annotations.Inject;
 import org.hibernate.Criteria;
 import org.hibernate.Query;
 import org.hibernate.Session;


 import uk.bl.dlportal.entities.User;


 public class Security
 {
@Inject
private Session session;

private final static Security security = new Security();


public User authenticate(String userName, String password)
{
System.out.println(SESSION 
 +session);

Criteria c = session.createCriteria(User.class);

List result = c.list();

System.out.println(SESSION 
 +session);

return null;
}

public static Security getSecurity()
{
return security;
}
 }


 Stack trace is:
 
 84.73% unrealized services (111/131)

 [INFO] mortbay.log Started [EMAIL PROTECTED]:8080
 [DEBUG] AppModule.TimingFilter Creating service 'TimingFilter'.
 [DEBUG] AppModule.TimingFilter Invoking method
 uk.bl.dlportal.services.AppModule.buildTimingFilter(Logger) (at
 AppModule.java:71).
 [INFO] AppModule.TimingFilter Request time: 4846 ms
 [INFO] AppModule.TimingFilter Request time: 0 ms
 [INFO] AppModule.TimingFilter Request time: 16 ms
 SESSION  null
 [INFO] AppModule.TimingFilter Request time: 251 ms
 [ERROR] TapestryModule.RequestExceptionHandler Processing of request
 failed
 with uncaught
 exception: org.apache.tapestry5.runtime.ComponentEventException
 org.apache.tapestry5.runtime.ComponentEventException [at
 context:Index.tml,
 line 7,
 column 28]
at

 org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1042)
at

 org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:67)
at

 org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42)
at

 $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java)
at
 org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42)
at

 $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java)
at
 org.apache.tapestry5.services.TapestryModule$37.handle(TapestryModule.java:1987)
at

 $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java)
at

 $ComponentEventRequestHandler_11b68bd500b.handle($ComponentEventRequestHandler_11b68bd500b.java)
at

 org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:135)
at $Dispatcher_11b68bd500e.dispatch($Dispatcher_11b68bd500e.java)
at $Dispatcher_11b68bd5000.dispatch($Dispatcher_11b68bd5000.java)
at
 org.apache.tapestry5.services.TapestryModule$12.service(TapestryModule.java:938)
at uk.bl.dlportal.services.AppModule$1.service(AppModule.java:84)
at
 $RequestFilter_11b68bd4fff.service($RequestFilter_11b68bd4fff.java)
at
 $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at

 org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42)
at
 $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at
 org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:586)
at
 $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at

 org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
at
 $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at

 org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79)
at
 $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java)
at

 org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
at

 org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84

Re: [T5]: Hibernate question - session is null

2008-07-26 Thread Mark Weissenberg
Hi,

I also had some trouble configuring hibernate, my session was also null.

After searching for a while I found this tutorial:
http://linuxboy.javaeye.com/blog/68311


Since I dont use a DAO, my code looks something like the following.


my db entity:
...

import org.hibernate.Session;

@Entity
@Table(name = EVENT)
public class EventDBEntity {
public EventDBEntity() {}
public EventDBEntity(Session session) {_session = session;}
@Transient
private Session _session;
// more stuff here.. methods to access the db
...


in my appmodule.java:

...

public static void bind(ServiceBinder binder)
{
binder.bind(TourDBEntity.class);
}
...


then I call an @Inject on the db-entity:
...
// db entity object
@Inject
private EventDBEntity _dbEntity;

// now tapestry injects the hibernate session in my _dbEntity
...

Hope this helps!

Greetings, Mark

--
Mark Weißenberg
Tel. +49 228 9599630
startext Unternehmensberatung GmbH
Kennedyallee 2, D-53175 Bonn
Geschäftsführer Paul Bantzer, HRB Bonn 2741
Sitz der Gesellschaft: Bonn

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5]: Hibernate question - session is null

2008-07-25 Thread photos


I'm using Eclipse. The XML config appears in target/classes and  
appears to be in the classpath.


I'm afraid I'm rather new to Tap 5 and also to Hibernate. I'm just  
following what is in the Tutorial. Unfortunately the session is still  
coming out as null.


Is there anywhere I can see that Tapestry is actually using Hibernate  
as a service?  I get the following in the console when I start my  
application:


...
HibernateEntityPackageManager: DEFINED
  HibernateSessionManager: DEFINED
   HibernateSessionSource: DEFINED
HibernateTransactionDecorator: DEFINED
...



Quoting Andreas Andreou [EMAIL PROTECTED]:


Perhaps hibernate.cfg.xml isn't in your runtime classpath?
Are you sure your IDE includes it to the output?

On Thu, Jul 24, 2008 at 6:09 PM,  [EMAIL PROTECTED] wrote:

I am following the tutorial at

http://tapestry.apache.org/tapestry5/tutorial1/forms2.html

but I find that the session (supposedly injected) is null. I'm not sure how
to proceed.

Could someone point me to documents/better tutorials on how to use Tapestry
with Hibernate?

Thanks,
p.




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






--
Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5]: Hibernate question - session is null

2008-07-25 Thread 9902468

Check that the 

@Inject
private Session session;

session is org.hibernate.Session.

 - 99



photos-4 wrote:
 
 
 I'm using Eclipse. The XML config appears in target/classes and  
 appears to be in the classpath.
 
 I'm afraid I'm rather new to Tap 5 and also to Hibernate. I'm just  
 following what is in the Tutorial. Unfortunately the session is still  
 coming out as null.
 
 Is there anywhere I can see that Tapestry is actually using Hibernate  
 as a service?  I get the following in the console when I start my  
 application:
 
 ...
  HibernateEntityPackageManager: DEFINED
HibernateSessionManager: DEFINED
 HibernateSessionSource: DEFINED
  HibernateTransactionDecorator: DEFINED
 ...
 
 
 
 Quoting Andreas Andreou [EMAIL PROTECTED]:
 
 Perhaps hibernate.cfg.xml isn't in your runtime classpath?
 Are you sure your IDE includes it to the output?

 On Thu, Jul 24, 2008 at 6:09 PM,  [EMAIL PROTECTED] wrote:
 I am following the tutorial at

 http://tapestry.apache.org/tapestry5/tutorial1/forms2.html

 but I find that the session (supposedly injected) is null. I'm not sure
 how
 to proceed.

 Could someone point me to documents/better tutorials on how to use
 Tapestry
 with Hibernate?

 Thanks,
 p.




 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





 --
 Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr
 Tapestry / Tacos developer
 Open Source / JEE Consulting

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18650658.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5]: Hibernate question - session is null

2008-07-25 Thread 9902468

Tapestry should be quite verbose about hibernate if tapestry is configured to
run in debug mode:

http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html

add:

 //This is the time in seconds that Tapestry waits before checking if a file
is modified
//Use a big number in production to imporve perfomance.
configuration.add(SymbolConstants.FILE_CHECK_INTERVAL, 1 s); //
600 to production!

// The factory default is true but during the early stages of an
application
// overriding to false is a good idea. In addition, this is often
overridden
// on the command line as -Dtapestry.production-mode=false
configuration.add(SymbolConstants.PRODUCTION_MODE, false);

to your AppModule.java's public static void
contributeApplicationDefaults(MappedConfigurationString, String
configuration) { method.

Also see that your entities are in correct place (same root package as pages
and components, in entities package.)

Also perhaps use org.hibernate.dialect.MySQLInnoDBDialect to support foreign
keys? (Change to hibernate config.)

You should be able to see that Hibernate starts in the logs and maps User
etc. classes.

Remember to configure your Log4J or what ever logging u use to debug.

 - 99


photos-4 wrote:
 
 
 I'm using Eclipse. The XML config appears in target/classes and  
 appears to be in the classpath.
 
 I'm afraid I'm rather new to Tap 5 and also to Hibernate. I'm just  
 following what is in the Tutorial. Unfortunately the session is still  
 coming out as null.
 
 Is there anywhere I can see that Tapestry is actually using Hibernate  
 as a service?  I get the following in the console when I start my  
 application:
 
 ...
  HibernateEntityPackageManager: DEFINED
HibernateSessionManager: DEFINED
 HibernateSessionSource: DEFINED
  HibernateTransactionDecorator: DEFINED
 ...
 
 
 
 Quoting Andreas Andreou [EMAIL PROTECTED]:
 
 Perhaps hibernate.cfg.xml isn't in your runtime classpath?
 Are you sure your IDE includes it to the output?

 On Thu, Jul 24, 2008 at 6:09 PM,  [EMAIL PROTECTED] wrote:
 I am following the tutorial at

 http://tapestry.apache.org/tapestry5/tutorial1/forms2.html

 but I find that the session (supposedly injected) is null. I'm not sure
 how
 to proceed.

 Could someone point me to documents/better tutorials on how to use
 Tapestry
 with Hibernate?

 Thanks,
 p.




 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





 --
 Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr
 Tapestry / Tacos developer
 Open Source / JEE Consulting

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18651481.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5]: Hibernate question - session is null

2008-07-25 Thread 9902468

And of course, check that you have Hibernate and hibernate annotation in your
libraries, they are NOT included automatically by maven if maven is used.

 - 99


photos-4 wrote:
 
 
 I'm using Eclipse. The XML config appears in target/classes and  
 appears to be in the classpath.
 
 I'm afraid I'm rather new to Tap 5 and also to Hibernate. I'm just  
 following what is in the Tutorial. Unfortunately the session is still  
 coming out as null.
 
 Is there anywhere I can see that Tapestry is actually using Hibernate  
 as a service?  I get the following in the console when I start my  
 application:
 
 ...
  HibernateEntityPackageManager: DEFINED
HibernateSessionManager: DEFINED
 HibernateSessionSource: DEFINED
  HibernateTransactionDecorator: DEFINED
 ...
 
 
 
 Quoting Andreas Andreou [EMAIL PROTECTED]:
 
 Perhaps hibernate.cfg.xml isn't in your runtime classpath?
 Are you sure your IDE includes it to the output?

 On Thu, Jul 24, 2008 at 6:09 PM,  [EMAIL PROTECTED] wrote:
 I am following the tutorial at

 http://tapestry.apache.org/tapestry5/tutorial1/forms2.html

 but I find that the session (supposedly injected) is null. I'm not sure
 how
 to proceed.

 Could someone point me to documents/better tutorials on how to use
 Tapestry
 with Hibernate?

 Thanks,
 p.




 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





 --
 Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr
 Tapestry / Tacos developer
 Open Source / JEE Consulting

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18651522.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5]: Hibernate question - session is null

2008-07-25 Thread photos

Quoting 9902468 [EMAIL PROTECTED]:



Check that the

@Inject
private Session session;

session is org.hibernate.Session.

- 99





It is.  I notice that when I switch on the mysql log that no attempt  
is ever made to
access the db. Is there any kind of logging I can switch on from  
Tapestry (or maybe
Hibernate) to tell me what is going on?  (I am quite sure the xml file  
is correct and in
the classpath, so I am running out of ideas! Although it must be  
something simple as

these things usually are). session is always null when this code is run.

Code and XML below:


package uk.bl.dlportal.pages.util;

import java.util.List;

import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Query;
import org.hibernate.Session;

import uk.bl.dlportal.entities.User;


public class Security
{
@Inject
private Session session;

private final static Security security = new Security();


public User authenticate(String userName, String password)
{
System.out.println(SESSION   
+session);


List result = session.createCriteria(User.class).list();

return null;
}

public static Security getSecurity()
{
return security;
}
}



XML hibernate.cfg.xml is in src/main/resources:

!DOCTYPE hibernate-configuration PUBLIC
-//Hibernate/Hibernate Configuration DTD 3.0//EN
http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd;
hibernate-configuration
session-factory
property
name=hibernate.connection.driver_classcom.mysql.jdbc.Driver/property
property
name=hibernate.connection.urljdbc:mysql://localhost:3306/dlportal/property
property  
name=hibernate.dialectorg.hibernate.dialect.MySQLDialect/property

property name=hibernate.connection.usernameroot/property
property name=hibernate.connection.passwordadmin/property
property name=hbm2ddl.autoupdate/property
property name=hibernate.show_sqltrue/property
property name=hibernate.format_sqltrue/property
/session-factory
/hibernate-configuration


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5]: Hibernate question - session is null

2008-07-25 Thread photos

Thanks for your help, but so far no joy:

Quoting 9902468 [EMAIL PROTECTED]:

And of course, check that you have Hibernate and hibernate  
annotation in your libraries, they are NOT included automatically  
by maven if maven is used.


The libraries appear in my repository and appear under sources in  
the Eclipse Run Configuration.





Tapestry should be quite verbose about hibernate if tapestry is configured to
run in debug mode:

http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html

add:



I placed -Dtapestry.production-mode=false on the command line, which,  
according to the docs, does the same thing.


I see no output about Hibernate at all. It never gets mentioned...



Also see that your entities are in correct place (same root package as pages
and components, in entities package.)


src/main/java/uk.bl.dlportal.entities
src/main/java/uk.bl.dlportal.components
src/main/java/uk.bl.dlportal.pages

looks ok to me.



Also perhaps use org.hibernate.dialect.MySQLInnoDBDialect to support foreign
keys? (Change to hibernate config.)

You should be able to see that Hibernate starts in the logs and maps User
etc. classes.

Remember to configure your Log4J or what ever logging u use to debug.


I added some lines to log4j.properties to turn on hibernate logging  
(debug), but I see no output - just the usual Tapestry debug output  
that I've seen before.


I'm really stumped... :-(  Hibernate never gets called and yet  
everything appears to be in place.


p.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]