[jboss-user] [JBoss Seam] - Re: Can't get Seam managed persistance working in an app sco
lle
do-not-reply at jboss.com
Thu Dec 14 15:33:31 EST 2006
Thanks Gavin.
I tried using SessionFactory.openSession() approach by having my application scope bean to read hibernate.cfg.xml file to build the SessionFactory.
However, I got the following exception when startup Tomcat:
| Caused by: org.hibernate.HibernateException: Could not find datasource
| at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
| at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
| at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
| at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:397)
| at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
| at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2006)
| at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1289)
| at com.ga.riskapp.usermgmt.action.GAHostAppManagedAction.openSession(GAHostAppManagedAction.java:126)
| ... 88 more
| Caused by: javax.naming.NameNotFoundException: Name hibernateDatasource-mysql is not bound in this Context
| at org.apache.naming.NamingContext.lookup(NamingContext.java:769)
| at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
| at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
| at javax.naming.InitialContext.lookup(InitialContext.java:351)
| at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
| ... 95 more
|
Here is a snippet of my application scope component:
| @Create
| public void init() {
| log.debug("in init()");
| List<GAHostAppInfo> allHostApps = GADAOFactory.DEFAULT.getHostAppDAO(this.openSession()).findAllOrderByHost();
| ...
| }
|
| private Session openSession() {
| try
| {
| SessionFactory sessionFactory = new Configuration().configure(GARiskAppConfig.getHibernateConfigProp()).buildSessionFactory();
| return sessionFactory.openSession();
| }
| catch (HibernateException ex)
| {
| throw new GAInfrastructureException("Failed to build session factory.", ex);
| }
| }
|
|
Did I do something wrong? Please note that similar approach worked without using Seam.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994015#3994015
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994015
More information about the jboss-user
mailing list