1 Reply Latest reply on Aug 25, 2006 11:06 PM by Ales Justin

    JNDI implementation returned null used Jboss jndi

    benson wang Newbie

      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 ->


      <local-tx-datasource>
      <jndi-name>jdbc/plato</jndi-name>
      <connection-url>jdbc:mysql://localhost:3307/plato</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>root</user-name>
      root
      <exception-sorter-class-name>
      org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
      </exception-sorter-class-name>

      <type-mapping>mySQL</type-mapping>

      </local-tx-datasource>


      The configuration files in plato.ear\META-INF listed as below:

      application.xml ->



      <web-uri>plato.war</web-uri>
      <context-root>plato</context-root>



      jboss-app.xml ->

      <jboss-app>

      platoEntity.har

      </jboss-app>

      The platoEntity.har existed in plato.ear and there was a jboss-service.xml existed in platoEntity.har/META-INF directory:
      jboss-service.xml ->


      java:/jdbc/plato
      java:/hibernate/SessionFactory
      org.hibernate.dialect.MySQLInnoDBDialect
      org.hibernate.cache.HashtableCacheProvider
      true



      And I inject the jndi object in applicationContext-hibernate.xml that existed in WEB-INF directory:

      applicationContext-hibernate.xml ->
      <bean id="sessionFactory" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">

      java:/hibernate/SessionFactory



      Error occured when I start jboss server:

      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, warUrl=.../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.springframework.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.springframework.context.support.DelegatingMessageSource@ced1ac]
      21:00:54,859 INFO [WebClassPathXmlApplicationContext] Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@1d66aa9]
      21:00:54,875 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in factory [org.springframework.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.springframework.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.springframework.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.springframework.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.springframework.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.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:125)

      Who encounter the problem same as me and help me, thanks you!!!