You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2013/10/11 03:20:10 UTC

Re: Hibernate Search Fix

Hi, Lance Java offered the following snippet of code back in

http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/grid-dont-link-hibernate-classic-session-td5669885.html

-- 
You could add this to your app module:

    private static class LazyFullTextSession {
        private HibernateSessionManager sessionManager;

        public LazyFullTextSession(HibernateSessionManager sessionManager)
{
                this.sessionManager = sessionManager;
        }

        public FullTextSession getFullTextSession() {
                return
Search.getFullTextSession(sessionManager.getSession());
        }
    }

    public static FullTextSession
buildFullTextSession(HibernateSessionManager sessionManager,
PropertyShadowBuilder propertyShadowBuilder)

    {

//Seems to be failing on this line
        LazyFullTextSession lazy = new LazyFullTextSession(sessionManager);
        return propertyShadowBuilder.build(lazy, "fullTextSession",
FullTextSession.class);
    }

I'm seeing the following exception and wondering what might be causing it.
I"m using 5.4.22



org.apache.tapestry5.ioc.internal.OperationException

*Error invoking method public static org.hibernate.search.FullTextSession
org.company.tapdemo.services.AppModule.buildFullTextSession(org.apache.tapestry5.hibernate.HibernateSessionManager,org.apache.tapestry5.ioc.services.PropertyShadowBuilder):
Unable to instantiate instance of transformed class
$FullTextSession_132be93a98bd23ee:
java.lang.reflect.InvocationTargetException*
trace

   - Handling page render request for page forsale/Index
   - Triggering event 'activate' on forsale/Index
   - Realizing service FullTextSession
   - Instantiating service FullTextSession implementation via
   org.company.tapdemo.services.AppModule.buildFullTextSession(HibernateSessionManager,
   PropertyShadowBuilder) (at AppModule.java:218)
   - Constructing service implementation via
   org.company.tapdemo.services.AppModule.buildFullTextSession(HibernateSessionManager,
   PropertyShadowBuilder) (at AppModule.java:218)

java.lang.RuntimeException

*Error invoking method public static org.hibernate.search.FullTextSession
org.company.tapdemo.services.AppModule.buildFullTextSession(org.apache.tapestry5.hibernate.HibernateSessionManager,org.apache.tapestry5.ioc.services.PropertyShadowBuilder):
Unable to instantiate instance of transformed class
$FullTextSession_132be93a98bd23ee:
java.lang.reflect.InvocationTargetException*
java.lang.reflect.InvocationTargetExceptiontargetExceptionjava.lang.IllegalAccessError:
tried to access class
org.company.tapdemo.services.AppModule$LazyFullTextSession from class
$FullTextSession_132be93a98bd23ee
java.lang.IllegalAccessError

*tried to access class
org.company.tapdemo.services.AppModule$LazyFullTextSession from class
$FullTextSession_132be93a98bd23ee*


George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York

Re: Hibernate Search Fix

Posted by Lance Java <la...@googlemail.com>.
This would also work (and would only happen at most once per request:

@Scope(ScopeConstants.PERTHREAD)
public static FullTextSession buildFullTextSession(HibernateSessionManager
sessionManager) {
    return Search.getFullTextSession(sessionManager.getSession());
}

Re: Hibernate Search Fix

Posted by Lance Java <la...@googlemail.com>.
Seems like it's caused by your jvm's security and accessing a private class.

This should work (less verbose too):

    public static FullTextSession buildFullTextSession(
            final HibernateSessionManager sessionManager,
            PropertyShadowBuilder propertyShadowBuilder)
    {
        Object lazyBuilder = new Object() {
            public FullTextSession getFullTextSession() {
                return
Search.getFullTextSession(sessionManager.getSession());
            }
        };
        return propertyShadowBuilder.build(lazyBuilder, "fullTextSession",
FullTextSession.class);
    }