You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by GMAIL1 <am...@gmail.com> on 2009/05/25 11:58:36 UTC

[5.1.0.5] Ars-Machina - No service Implements the interface org.hibernate.SessionFactory

Hi all ,

I�m trying to use te modules Ars-Machina generic-dao & 
generic-dao-hibernate,
but i�m getting the following message :
*
No service implements the interface org.hibernate.SessionFactory*


I attach my current pom.xml, the following are the unique dependencies 
from the ars-machina project.
...
        <dependency>
          <groupId>br.com.arsmachina</groupId>
          <artifactId>generic-dao</artifactId>
          <version>${ars-machina-release-version}</version>
        </dependency>
       
        <dependency>
          <groupId>br.com.arsmachina</groupId>
          <artifactId>generic-dao-hibernate</artifactId>
          <version>${ars-machina-release-version}</version>
        </dependency>
...
( ...with 
<ars-machina-release-version>1.0</ars-machina-release-version>  ...)


� Any addicional dependency for get working ? I will try making my own 
builder method that returns an instance
of SessionFactory, getting the instance from one of the services 
provided the tapestry-hibernate module.


Thanks & Nice.Day
Antonio




Re: [5.1.0.5] Ars-Machina - No service Implements the interface org.hibernate.SessionFactory

Posted by Antonio Fernández <am...@gmail.com>.
Thiago H. de Paula Figueiredo escribió:
> Em Mon, 25 May 2009 12:43:17 -0300, Antonio Fernández 
> <am...@gmail.com> escreveu:
>
>> Hi again,
>
> Hi!
>
>>         * org.hibernate.HibernateException: No CurrentSessionContext
>>           configured!
>
> The suggested way is to override getSession() to return something 
> other than sessionFactory.getSession() or set a CurrentSessionContext 
> in you SessionFactory (recommended). This section in the Hibernate 
> documentation tells you why and how: 
> http://docs.jboss.org/hibernate/stable/core/reference/en/html_single/#architecture-current-session. 
>
>

. I tried with the three available values for property 
"hibernate.current_session_context_class",  it only works with
value org.hibernate.context.ThreadLocalSessionContext.

However, a new problem

        * org.hibernate.HibernateException: createCriteria is not valid
          without active transaction

Hide uninteresting stack frames Stack trace

        * org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:338)

        * $Proxy68.createCriteria(Unknown Source)
        * br.com.arsmachina.dao.hibernate.ReadableDAOImpl.createCriteria(ReadableDAOImpl.java:267)

        * br.com.arsmachina.dao.hibernate.ReadableDAOImpl.findAll(ReadableDAOImpl.java:125)

        * br.com.arsmachina.dao.hibernate.GenericDAOImpl.findAll(GenericDAOImpl.java:94)

        * $UserDAO_1217e966a63.findAll($UserDAO_1217e966a63.java)
        * org.jwp.ic20.pages.admin.user.UserShowAll.getUsers(UserShowAll.java:39)

        * $PropertyConduit_1217e966a93.get($PropertyConduit_1217e966a93.java)

        * org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:58)



My AppModule already includes the following contribution for decorating 
all the DAO services :

    @Match("*DAO")
    public static <T> T 
decorateTransactionally(HibernateTransactionDecorator decorator, 
Class<T> serviceInterface,
                                                T delegate,
                                                String serviceId)
    {
        return decorator.build(serviceInterface, delegate, serviceId);
    }

So at this point would require a deeper understanding of tapestry-hibernate.


Greetings,
Antonio









>> A few changes in BaseHibernateDAO :
>>
>>    - Replaced the import of class org.hibernate.classic.Session with
>> org.hibernate.Session.
>
> Thanks for pointing me that. I've just fixed this in the Generic 
> DAO-Hibernate branch. By the way, in the Maven repository, there is an 
> improved 1.1 version there.
>
>>    - Add the org.hibernate.Session object as a new paremeter in all the
>> constructor methods.
>>    - Changes in class BaseHibernateDAO :
>>
>>             Add new field of type org.hibernate.Session, that will be
>> initialized inside the constructor ( like the SessionFactory does )
>>             Modify the method getSession(), returning the new field 
>> reference
>
> These modifications aren't appropriate to *Generic* DAO-Hibernate, as 
> they wouldn't work without Tapestry-IoC (for example, when you're 
> building a desktop application or using Spring), and this package is 
> meant to be independetly from Tapestry-IoC.
>


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


Re: [5.1.0.5] Ars-Machina - No service Implements the interface org.hibernate.SessionFactory

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 25 May 2009 12:43:17 -0300, Antonio Fernández  
<am...@gmail.com> escreveu:

> Hi again,

Hi!

>         * org.hibernate.HibernateException: No CurrentSessionContext
>           configured!

The suggested way is to override getSession() to return something other  
than sessionFactory.getSession() or set a CurrentSessionContext in you  
SessionFactory (recommended). This section in the Hibernate documentation  
tells you why and how:  
http://docs.jboss.org/hibernate/stable/core/reference/en/html_single/#architecture-current-session.

> A few changes in BaseHibernateDAO :
>
>    - Replaced the import of class org.hibernate.classic.Session with
> org.hibernate.Session.

Thanks for pointing me that. I've just fixed this in the Generic  
DAO-Hibernate branch. By the way, in the Maven repository, there is an  
improved 1.1 version there.

>    - Add the org.hibernate.Session object as a new paremeter in all the
> constructor methods.
>    - Changes in class BaseHibernateDAO :
>
>             Add new field of type org.hibernate.Session, that will be
> initialized inside the constructor ( like the SessionFactory does )
>             Modify the method getSession(), returning the new field  
> reference

These modifications aren't appropriate to *Generic* DAO-Hibernate, as they  
wouldn't work without Tapestry-IoC (for example, when you're building a  
desktop application or using Spring), and this package is meant to be  
independetly from Tapestry-IoC.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: [5.1.0.5] Ars-Machina - No service Implements the interface org.hibernate.SessionFactory

Posted by Antonio Fernández <am...@gmail.com>.
Hi again, 

I tried adding the following builder method :
  
    public static SessionFactory buildSessionFactory(final 
HibernateSessionManager hibernateSessionManager) {
        return hibernateSessionManager.getSession().getSessionFactory();
    }

And T5 returns  ...

throwables

        * org.hibernate.HibernateException: No CurrentSessionContext
          configured!

Stack trace

        * org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:572)

        * $SessionFactory_1217831619b.getCurrentSession($SessionFactory_1217831619b.java)

        * br.com.arsmachina.dao.hibernate.BaseHibernateDAO.getSession(BaseHibernateDAO.java:111)

        * br.com.arsmachina.dao.hibernate.ReadableDAOImpl.createCriteria(ReadableDAOImpl.java:267)

        * br.com.arsmachina.dao.hibernate.ReadableDAOImpl.findAll(ReadableDAOImpl.java:125)

        * br.com.arsmachina.dao.hibernate.GenericDAOImpl.findAll(GenericDAOImpl.java:94)

        * $UserDAO_1217831614a.findAll($UserDAO_1217831614a.java)

I attached my custom implementations of the package 
"br.com.arsmachina.dao.hibernate" ,
now i have working ars-machina.generic-dao-hibernate and 
tapestry-hibernate modules together .

A few changes in BaseHibernateDAO :

   - Replaced the import of class org.hibernate.classic.Session with 
org.hibernate.Session.

   - Add the org.hibernate.Session object as a new paremeter in all the 
constructor methods.

   - Changes in class BaseHibernateDAO :

            Add new field of type org.hibernate.Session, that will be 
initialized inside the constructor ( like the SessionFactory does )
            Modify the method getSession(), returning the new field 
reference

By this way, the SessionFactory is Only used for his specific purposes 
and the Session
is provided directly by the HibernateSessionManager service from 
tapestry-hibernate.

That´s all , any suggestions, opinions..


Nice evening !
Antonio



Thiago H. de Paula Figueiredo escribió:
> On Mon, May 25, 2009 at 6:58 AM, GMAIL1 <am...@gmail.com> wrote:
>
>   
>> Hi all ,
>>     
>
> Hi!
>
>   
>> I´m trying to use te modules Ars-Machina generic-dao &
>> generic-dao-hibernate, but i´m getting the following message :
>>     
>
> Nice to see that someone besides me is using the Ars Machina Project
> packages. :)
>
>   
>> No service implements the interface org.hibernate.SessionFactory*
>>     
>
> These packages don't have a dependency on Tapestry-IoC, so they don't
> provide a SessionFactory service to T-IoC.
>
>   
>> Any addicional dependency for get working ? I will try making my own
>> builder method that returns an instance of SessionFactory, getting the instance from one of the services provided
>> the tapestry-hibernate module.
>>     
>
> I've never used Tapestry-Hibernate myself, but I guess that'll work. :)
>
>   



Re: [5.1.0.5] Ars-Machina - No service Implements the interface org.hibernate.SessionFactory

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, May 25, 2009 at 6:58 AM, GMAIL1 <am...@gmail.com> wrote:

> Hi all ,

Hi!

> I´m trying to use te modules Ars-Machina generic-dao &
> generic-dao-hibernate, but i´m getting the following message :

Nice to see that someone besides me is using the Ars Machina Project
packages. :)

> No service implements the interface org.hibernate.SessionFactory*

These packages don't have a dependency on Tapestry-IoC, so they don't
provide a SessionFactory service to T-IoC.

>Any addicional dependency for get working ? I will try making my own
> builder method that returns an instance of SessionFactory, getting the instance from one of the services provided
> the tapestry-hibernate module.

I've never used Tapestry-Hibernate myself, but I guess that'll work. :)

-- 
Thiago

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