Hey Kalle, thanks for the quick response.

I think I found the reason why it's not working for me (and I am surprised what 
you're describing could have worked for you at all).  By way of a unit test I 
tried your approach (adding the <dependency> for Hibernate 4.1.1), and for me 
it fails with a 

        Caused by: java.lang.NoSuchMethodError: 
org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;

Since then I have found the reason for that, which this that 
SessionFactory.openSession() in:
- Hibernate 4.1 returns org.hibernate.Session
- Hibernate 3.6 returns org.hibernate.classic.Session.

Now clearly that is something that can be resolved by way of compiling Tapestry 
5.3.2 from source with the dependency on Hibernate 4.1 as I described in my 
original mail, but I have no idea how it could have worked for you without 
doing the same thing, because I don't think there's a way to get Hibernate 4.1 
to return a "classic" Session to you, which is what tapestry-hibernate expects.

Am I missing something?  Should this work without a recompile?

A simple test case at the very end of this mail, together with the full stack 
trace.

Thanks!
Jochen

PS: Because (according to my experiments) it requires re-building the Tapestry 
binary, I assumed the 'dev' list was the right place ... 

On Mar 21, 2012, at 11:23 PM, Kalle Korhonen wrote:

> Just as a test I ran tynamo's tapestry-hibernate-seedentity against
> 4.1.1 and after fixing the api changes (the metadata api has some
> changes that are potentially a problem to tapestry integration) it
> worked out fine. I'm using tapestry-hibernate 5.3.2. I only added the
> following to the pom:
>               <dependency>
>                       <groupId>org.hibernate</groupId>
>                       <artifactId>hibernate-core</artifactId>
>                       <version>4.1.1.Final</version>
>               </dependency>
> 
>> 1)  Is there something obviously wrong with this approach (I haven't been 
>> hacking at TS proper that much), and
> 
> Nothing that wrong except it seems not to be necessary.
> 
>> 2) Is there an easier way (e.g. removing the "transitive: false" and hoping 
>> for the best)?
> 
> Dependencies are yours to manage, even if the tools may help with
> them. In other words, take transitive dependencies only as the tool's
> initial guess of what you might need and verify what and which version
> you need yourself.
> 
> Kalle
> 

public class SaveEntityTest extends TapestryTestCase {
    
    HibernateSessionManager manager;
    PageTester pageTester;

    public SaveEntityTest() {
        pageTester = new PageTester("com.example.newapp", "newapp");
    }

    @Test
    public void simpleTest()
    {
        manager = 
pageTester.getRegistry().getService(HibernateSessionManager.class);
        manager.getSession().createQuery("delete Game").executeUpdate();
        manager.commit();

        Game game = new Game();
        game.setName("test");
        manager.getSession().save(game);
        manager.commit();
    }
}

[ERROR] ioc.Registry Error invoking method public static 
org.apache.tapestry5.hibernate.HibernateSessionManager 
org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionManager(org.apache.tapestry5.hibernate.HibernateSessionSource,org.apache.tapestry5.ioc.services.PerthreadManager):
 org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
[ERROR] ioc.Registry Operations trace:
[ERROR] ioc.Registry [ 1] Instantiating service HibernateSessionManager 
implementation via 
org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionManager(HibernateSessionSource,
 PerthreadManager) (at HibernateCoreModule.java:96)
[ERROR] ioc.Registry [ 2] Constructing service implementation via 
org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionManager(HibernateSessionSource,
 PerthreadManager) (at HibernateCoreModule.java:96)
org.apache.tapestry5.ioc.internal.OperationException: Error invoking method 
public static org.apache.tapestry5.hibernate.HibernateSessionManager 
org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionManager(org.apache.tapestry5.hibernate.HibernateSessionSource,org.apache.tapestry5.ioc.services.PerthreadManager):
 org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
        at 
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.logAndRethrow(OperationTrackerImpl.java:121)
        at 
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:88)
        at 
org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
        at 
org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1121)
        at 
org.apache.tapestry5.ioc.internal.util.ConstructionPlan.createObject(ConstructionPlan.java:60)
        at 
org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:60)
        at 
org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator$1.invoke(OperationTrackingObjectCreator.java:45)
        at 
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
        at 
org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
        at 
org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1121)
        at 
org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator.createObject(OperationTrackingObjectCreator.java:49)
        at 
org.apache.tapestry5.ioc.internal.services.PerThreadServiceCreator.createObject(PerThreadServiceCreator.java:47)
        at $HibernateSessionManager_127dc602c6524ef5.delegate(Unknown Source)
        at $HibernateSessionManager_127dc602c6524ef5.getSession(Unknown Source)
        at $HibernateSessionManager_127dc602c6524ef4.getSession(Unknown Source)
        at 
com.example.newapp.entities.SaveEntityTest.simpleTest(SaveEntityTest.java:31)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1208)
        at 
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
        at org.testng.TestRunner.privateRun(TestRunner.java:758)
        at org.testng.TestRunner.run(TestRunner.java:613)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
        at org.testng.SuiteRunner.run(SuiteRunner.java:240)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1137)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1062)
        at org.testng.TestNG.run(TestNG.java:974)
        at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)
        at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
        at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:106)
Caused by: java.lang.RuntimeException: Error invoking method public static 
org.apache.tapestry5.hibernate.HibernateSessionManager 
org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionManager(org.apache.tapestry5.hibernate.HibernateSessionSource,org.apache.tapestry5.ioc.services.PerthreadManager):
 org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
        at 
org.apache.tapestry5.ioc.internal.util.MethodInvoker.invoke(MethodInvoker.java:61)
        at 
org.apache.tapestry5.ioc.internal.util.LoggingInvokableWrapper.invoke(LoggingInvokableWrapper.java:42)
        at 
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
        ... 39 more
Caused by: java.lang.NoSuchMethodError: 
org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
        at 
org.apache.tapestry5.internal.hibernate.HibernateSessionSourceImpl.create(HibernateSessionSourceImpl.java:69)
        at $HibernateSessionSource_127dc602c6524ef2.create(Unknown Source)
        at 
org.apache.tapestry5.internal.hibernate.HibernateSessionManagerImpl.<init>(HibernateSessionManagerImpl.java:31)
        at 
org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionManager(HibernateCoreModule.java:96)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.apache.tapestry5.ioc.internal.util.MethodInvoker.invoke(MethodInvoker.java:50)
        ... 41 more



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

Reply via email to