O.K after some time I see that you set up the session the following way:
Context ctx = new InitialContext();
SessionFactory factory = (SessionFactory)ctx.lookup("java:/DefaultDS");
However the second line throws a ClassCastException because ctx.lookup
returns an Object of type: org.jboss.resource.adapter.jdbc.WrapperDataSource
so all I can do is:
DataSource ds = (DataSource)ctx.lookup("java:/DefaultDS");
How can I obtain a SessionFactory then?
If you set up hibernate in a sar you should set your config in jboss-service.xml
Have you read the doc on the hibernate site?
Here is how I got mine configured:
at the bottom of the thread I describe the setup that finally worked for me.
Hope it helps