Jboss version: jboss-4.0.3SP1
Spring version: 1.2.6
Hibernate version: 3.0.5
I configured the mysql-ds.xml in Jboss deploy directory which had deployed my application:
mysql-ds.xml -gt;
Code:
lt;datasourcesgt; lt;local-tx-datasourcegt; lt;jndi-namegt;jdbc/platolt;/jndi-namegt; lt;connection-uclgt;jdbc:mysql--localhost:3307/platolt;/connection-uclgt; lt;driver-classgt;com.mysql.jdbc.Driverlt;/driver-classgt; lt;user-namegt;rootlt;/user-namegt; lt;passwordgt;rootlt;/passwordgt;
lt;exception-sorter-class-namegt;
org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
lt;/exception-sorter-class-namegt; lt;metadatagt; lt;type-mappinggt;mySQLlt;/type-mappinggt; lt;/metadatagt; lt;/local-tx-datasourcegt;
lt;/datasourcesgt;
The configuration files in plato.ear\META-INF listed as below:
application.xml -gt;
Code: lt;modulegt; lt;webgt;lt;web-urigt;plato.warlt;/web-urigt;lt;context-rootgt;platolt;/context-rootgt; lt;/webgt; lt;/modulegt;
jboss-app.xml -gt;
Code:
lt;jboss-appgt; lt;modulegt; lt;hargt;platoEntity.harlt;/hargt; lt;/modulegt;
lt;/jboss-appgt;
The platoEntity.har existed in plato.ear and there was a jboss-service.xml existed in platoEntity.har/META-INF directory:
jboss-service.xml -gt;
Code:
lt;servergt;
lt;mbean code=quot;org.jboss.hibernate.jmx.Hibernatequot; name=quot;jboss.har:service=Hibernatequot;gt;
lt;attribute name=quot;DatasourceNamequot;gt;java:/jdbc/platolt;/attributegt;
lt;attribute name=quot;SessionFactoryNamequot;gt;java:/hibernate/SessionFactorylt;/attributegt;
lt;attribute name=quot;Dialectquot;gt;org.hibernate.dialect.MySQLInnoDBDialectlt;/attributegt;
lt;attribute name=quot;CacheProviderClassquot;gt;org.hibernate.cache.HashtableCacheProviderlt;/attributegt;
lt;attribute name=quot;ShowSqlEnabledquot;gt;truelt;/attributegt;
lt;/mbeangt;
lt;/servergt; And I inject the jndi object in applicationContext-hibernate.xml that existed in WEB-INF directory:
applicationContext-hibernate.xml -gt;
Code: lt;bean id=quot;sessionFactoryquot; class=quot;org..jndi.JndiObjectFactoryBeanquot; lazy-init=quot;truequot;gt; lt;property name=quot;jndiNamequot;gt;lt;valuegt;java:/hibernate/SessionFactorylt;/valuegt; lt;/propertygt; lt;/beangt;
Error occured when I start jboss server:
Code:
21:00:50,000 INFO [Hibernate] SessionFactory successfully built and bound into JNDI [java:/hibernate/SessionFactory]
21:00:50,046 INFO [TomcatDeployer] deploy, ctxPath=/plato, warucl=.../deploy/plato.ear/plato.war/
21:00:50,406 INFO [WebappClassLoader] validateJarFile(D:\Application Server\jboss-4.0.3SP1\server\default\.\deploy\plato.ear\plato.war\WEB-INF\lib\jsdk23.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
21:00:50,953 INFO [ContextLoader] Root WebApplicationContext: initialization started
21:00:50,953 INFO [[/plato]] Loading Spring root WebApplicationContext
21:00:51,437 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [WEB-INF/applicationContext-hibernate.xml]
21:00:53,859 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [WEB-INF/applicationContext-service.xml]
21:00:54,328 INFO [WebClassPathXmlApplicationContext] Bean factory for application context [org.framework.core.web.spring.WebClassPathXmlApplicationContext;hashCode=2438443]: org..beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,sessionFactory,transactionManager,userDAO,platoMessagesDAO,mediaDAO,attachmentDAO,friendDAO,groupDAO,lovePassDAO,flirtContentDAO,favoriteDAO,adminUserDAO,adminPermissionDAO,systemDAO,engagementDAO,appointmentDAO,orderDAO,mailEngine,mailSender,velocityEngine,mailMessage,mailManager,txProxyTemplate,cacheManagerService,userManager,platoMessagesManager,mediaManager,attachmentManager,friendManager,groupManager,lovePassManager,flirtContentManager,favoriteManager,adminUserManager,adminPermissionManager,engagementManager,appointmentManager,orderManager,systemManager]; root of BeanFactory hierarchy
21:00:54,406 INFO [WebClassPathXmlApplicationContext] 40 beans defined in application context [org.framework.core.web.spring.WebClassPathXmlApplicationContext;hashCode=2438443]
21:00:54,734 INFO [PropertyPlaceholderConfigurer] Loading properties file from class path resource [main.properties]
21:00:54,812 INFO [CollectionFactory] JDK 1.4+ collections available
21:00:54,843 INFO [WebClassPathXmlApplicationContext] Unable to locate MessageSource with name 'messageSource': using default [org..context.support.DelegatingMessageSource@ced1ac]
21:00:54,859 INFO [WebClassPathXmlApplicationContext] Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org..context.event.SimpleApplicationEventMulticaster@1d66aa9]
21:00:54,875 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in factory [org..beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,sessionFactory,transactionManager,userDAO,platoMessagesDAO,mediaDAO,attachmentDAO,friendDAO,groupDAO,lovePassDAO,flirtContentDAO,favoriteDAO,adminUserDAO,adminPermissionDAO,systemDAO,engagementDAO,appointmentDAO,orderDAO,mailEngine,mailSender,velocityEngine,mailMessage,mailManager,txProxyTemplate,cacheManagerService,userManager,platoMessagesManager,mediaManager,attachmentManager,friendManager,groupManager,lovePassManager,flirtContentManager,favoriteManager,adminUserManager,adminPermissionManager,engagementManager,appointmentManager,orderManager,systemManager]; root of BeanFactory hierarchy]
21:00:55,171 WARN [SessionFactoryObjectFactory] Not found: 4028818a0d2bab35010d2bab4fb00000
21:00:55,171 INFO [DefaultListableBeanFactory] Destroying singletons in factory {org..beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,sessionFactory,transactionManager,userDAO,platoMessagesDAO,mediaDAO,attachmentDAO,friendDAO,groupDAO,lovePassDAO,flirtContentDAO,favoriteDAO,adminUserDAO,adminPermissionDAO,systemDAO,engagementDAO,appointmentDAO,orderDAO,mailEngine,mailSender,velocityEngine,mailMessage,mailManager,txProxyTemplate,cacheManagerService,userManager,platoMessagesManager,mediaManager,attachmentManager,friendManager,groupManager,lovePassManager,flirtContentManager,favoriteManager,adminUserManager,adminPermissionManager,engagementManager,appointmentManager,orderManager,systemManager]; root of BeanFactory hierarchy}
21:00:55,171 ERROR [ContextLoader] Context initialization failed
org..beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [WEB-INF/applicationContext-hibernate.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org..beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is javax.naming.NamingException: JNDI object with [java:/hibernate/SessionFactory] not found: JNDI implementation returned null
org..beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is javax.naming.NamingException: JNDI object with [java:/hibernate/SessionFactory] not found: JNDI implementation returned null
javax.naming.NamingException: JNDI object with [java:/hibernate/SessionFactory] not found: JNDI implementation returned null
at org..jndi.JndiTemplate$1.doInContext(JndiTemplate.java:125)
Who encounter the problem same as me and help me, thanks you!!!
SOS , your help is highly appreciated!
21:00:50,406 INFO [WebappClassLoader] validateJarFile(D:\Application Server\jboss-4.0.3SP1\server\default\.\deploy\plato.ear\plato.w ar\WEB-INF\lib\jsdk23.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
You should not put the javax.servlet files in your classpath - they are already provided by the servlet container.
21:00:55,171 ERROR [ContextLoader] Context initialization failed
org..beans.factory.BeanCreationExce ption: Error creating bean with name 'transactionManager' defined in class path resource [WEB-INF/applicationContext-hibernate.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org..beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is javax.naming.NamingException: JNDI object with [java:/hibernate/SessionFactory] not found: JNDI implementation returned null
org..beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is javax.naming.NamingException: JNDI object with [java:/hibernate/SessionFactory] not found: JNDI implementation returned null
javax.naming.NamingException: JNDI object with [java:/hibernate/SessionFactory] not found: JNDI implementation returned null
at org..jndi.JndiTemplate$1.doInContex t(JndiTemplate.java:125)
The JNDI object is not found - Jboss uses java:comp/env I think though you can very easily find the JNDI location by using the JMX console (provided with JBoss).
Originally Posted by Costin LeauThe JNDI object is not found - Jboss uses java:comp/env I think though you can very easily find the JNDI location by using the JMX console (provided with JBoss).
I did the try as below, but still not work:
Code: lt;bean id=quot;sessionFactoryquot; class=quot;org..jndi.JndiObjectFactoryBeanquot;gt; lt;property name=quot;jndiNamequot;gt;lt;valuegt; java:comp/env/hibernate/SessionFactory lt;/valuegt; lt;/propertygt; lt;/beangt;
SessionFactory successfully built and bound into JNDI [java:/hibernate/SessionFactory]
From above debug info on jboss console, it should be correct used java:/hibernate/SessionFactory as our jndi name, but the same exception throwed:Code:
23:11:35,234 INFO [Hibernate] SessionFactory successfully built and bound into JNDI [java:/hibernate/SessionFactory]
23:11:35,250 INFO [TomcatDeployer] deploy, ctxPath=/plato, warucl=.../deploy/plato.ear/plato.war/
23:11:35,875 INFO [ContextLoader] Root WebApplicationContext: initialization started
23:11:35,875 INFO [[/plato]] Loading Spring root WebApplicationContext
23:11:36,140 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]
23:11:37,093 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext-service.xml]
23:11:37,281 INFO [XmlWebApplicationContext] Bean factory for application context [Root WebApplicationContext]: org..beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,sessionFactory,transactionManager,userDAO,platoMessagesDAO,mediaDAO,attachmentDAO,friendDAO,groupDAO,lovePassDAO,flirtContentDAO,favoriteDAO,adminUserDAO,adminPermissionDAO,systemDAO,engagementDAO,appointmentDAO,orderDAO,mailEngine,mailSender,velocityEngine,mailMessage,mailManager,txProxyTemplate,cacheManagerService,userManager,platoMessagesManager,mediaManager,attachmentManager,friendManager,groupManager,lovePassManager,flirtContentManager,favoriteManager,adminUserManager,adminPermissionManager,engagementManager,appointmentManager,orderManager,systemManager]; root of BeanFactory hierarchy
23:11:37,328 INFO [XmlWebApplicationContext] 40 beans defined in application context [Root WebApplicationContext]
23:11:37,484 INFO [PropertyPlaceholderConfigurer] Loading properties file from class path resource [main.properties]
23:11:37,500 INFO [CollectionFactory] JDK 1.4+ collections available
23:11:37,515 INFO [XmlWebApplicationContext] Unable to locate MessageSource with name 'messageSource': using default [org..context.support.DelegatingMessageSource@1885088]
23:11:37,531 INFO [XmlWebApplicationContext] Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org..context.event.SimpleApplicationEventMulticaster@752144]
23:11:37,546 INFO [UiApplicationContextUtils] Unable to locate ThemeSource with name 'themeSource': using default [org..ui.context.support.ResourceBundleThemeSource@138ef1d]
23:11:37,546 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in factory [org..beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,sessionFactory,transactionManager,userDAO,platoMessagesDAO,mediaDAO,attachmentDAO,friendDAO,groupDAO,lovePassDAO,flirtContentDAO,favoriteDAO,adminUserDAO,adminPermissionDAO,systemDAO,engagementDAO,appointmentDAO,orderDAO,mailEngine,mailSender,velocityEngine,mailMessage,mailManager,txProxyTemplate,cacheManagerService,userManager,platoMessagesManager,mediaManager,attachmentManager,friendManager,groupManager,lovePassManager,flirtContentManager,favoriteManager,adminUserManager,adminPermissionManager,engagementManager,appointmentManager,orderManager,systemManager]; root of BeanFactory hierarchy]
23:11:37,593 INFO [DefaultListableBeanFactory] Destroying singletons in factory {org..beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,sessionFactory,transactionManager,userDAO,platoMessagesDAO,mediaDAO,attachmentDAO,friendDAO,groupDAO,lovePassDAO,flirtContentDAO,favoriteDAO,adminUserDAO,adminPermissionDAO,systemDAO,engagementDAO,appointmentDAO,orderDAO,mailEngine,mailSender,velocityEngine,mailMessage,mailManager,txProxyTemplate,cacheManagerService,userManager,platoMessagesManager,mediaManager,attachmentManager,friendManager,groupManager,lovePassManager,flirtContentManager,favoriteManager,adminUserManager,adminPermissionManager,engagementManager,appointmentManager,orderManager,systemManager]; root of BeanFactory hierarchy}
23:11:37,593 ERROR [ContextLoader] Context initialization failed
org..beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is javax.naming.NameNotFoundException: SessionFactory not bound
javax.naming.NameNotFoundException: hibernate not boundTry specifying java:/hibernate/SessionFactory instead of java:comp/env/...
Also to avoid looking for the SF before getting binded to JNDI set LookupOnStartup to false.
I ever try to configure lazy load listed as below, jboss start up well, but the
exception quot;javax.naming.NamingException: JNDI object with [java:/hibernate/SessionFactory] not found: JNDI implementation returned null
quot; still throwed once i do some persistent operation.
Code:
lt;bean id=quot;sessionFactoryquot; class=quot;org..jndi.JndiObjectFactoryBeanquot; lazy-init=quot;truequot;gt; lt;property name=quot;resourceRefquot;gt;lt;valuegt;truelt;/valuegt; lt;/propertygt; lt;property name=quot;cachequot;gt;lt;valuegt;falselt;/valuegt; lt;/propertygt; lt;property name=quot;lookupOnStartupquot;gt;lt;valuegt;falselt;/valuegt; lt;/propertygt; lt;property name=quot;proxyInterfacequot;gt;lt;valuegt;org.hibernate.SessionFactorylt;/valuegt; lt;/propertygt; lt;!-- lt;property name=quot;proxyInterfacequot;gt;lt;valuegt;javax.sql.DataSourcelt;/valuegt; lt;/propertygt; --gt; lt;property name=quot;jndiNamequot;gt;lt;valuegt;java:/hibernate/SessionFactorylt;/valuegt; lt;/propertygt; lt;/beangt;Don't you think your mbean should include providerucl for your class to do a look up?
I am running JBoss 4.0.2+Spring with Hibernate deployed as a JBoss service
Code: lt;bean
id=quot;hibernateSessionFactoryquot;
class=quot;org..jndi.JndiObjectFactoryBeanquot;gt;
lt;property
name=quot;jndiNamequot;
value=quot;java:/hibernate/SessionFactoryquot; /gt;
lt;/beangt;
Works like a charm.
Originally Posted by tatvamasiDon't you think your mbean should include providerucl for your class to do a look up?
Hi, tatvamasi, how to include providerucl for my class to do a look up?Originally Posted by Arno WerrI am running JBoss 4.0.2+Spring with Hibernate deployed as a JBoss service
Code: lt;bean
id=quot;hibernateSessionFactoryquot;
class=quot;org..jndi.JndiObjectFactoryBeanquot;gt;
lt;property
name=quot;jndiNamequot;
value=quot;java:/hibernate/SessionFactoryquot; /gt;
lt;/beangt;
Works like a charm.
Could you show your detail configuration about mbean?
Here you go. hibernate-service.xml
Code:
lt;servergt;
lt;mbean
code=quot;org.jboss.hibernate.jmx.Hibernatequot;
name=quot;jboss.har:service=Hibernatequot;gt;
lt;attribute name=quot;DatasourceNamequot;gt;java:/TitanDSlt;/attributegt;
lt;attribute name=quot;Dialectquot;gt;org.hibernate.dialect.PostgreSQLDialectlt;/attributegt;
lt;attribute name=quot;SessionFactoryNamequot;gt;java:/hibernate/SessionFactorylt;/attributegt;
lt;attribute name=quot;CacheProviderClassquot;gt;org.hibernate.cache.HashtableCacheProviderlt;/attributegt;
lt;attribute name=quot;Hbm2ddlAutoquot;gt;create-droplt;/attributegt;
lt;attribute name=quot;ShowSqlEnabledquot;gt;truelt;/attributegt;
lt;/mbeangt;
lt;/servergt;
Standard stuff really. Nothing fancy. Works with Spring like a charm. |