9 Replies Latest reply on Nov 26, 2009 12:36 AM by marius.bogoevici

    Jndi lookup on spring factory return 'null'

    jissma

      hello,

      I'm trying to deploy a spring application (no EJB inside only POJO class) with deployer ( Jboss 4.0.2 : the one packaged with jbpm)

      i export a jar(test3.spring) from eclipse and place it in deploy folder, when i watch the log everything seam to be ok :
      i get the following message : "Bean factory [test3] binded to local JNDI."

      then i inspect the JNDI listXML(); in JMX console my object seem to be referenced :

      test3
      org.jboss.spring.factory.NamedXmlApplicationContext


      when i run the Juint test to get the factory, the returned object of

      context.lookup("test3");
      is null


      could you help me solve this problem ?


      here is my : jboss-spring.xml in META-INF in test3.spring

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE beans SYSTEM "http://www.springframework.org/dtd/spring-beans.dtd">
      <beans>
       <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
       <property name="locations">
       <list>
       <value>/org/appli/hibernate.properties</value>
       </list>
       </property>
       </bean>
      
      
       <bean id="dSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
       <property name="url">
       <value>jdbc:firebirdsql:localhost/3050:c:/dev/databases/hibernate.gdb</value>
       </property>
       <property name="driverClassName" >
       <value>org.firebirdsql.jdbc.FBDriver</value>
       </property>
       <property name="username">
       <value>sysdba</value>
       </property>
       <property name="password">
       <value>masterkey</value>
       </property>
       </bean>
      
      
       <bean id="myTransactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
       <property name="sessionFactory"><ref local="sessionFactory"/></property>
       </bean>
      
       <bean id="contactService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
       <property name="transactionManager"><ref local="myTransactionManager"/></property>
       <property name="target"><ref local="contactDAO"/></property>
       <property name="transactionAttributes">
       <props>
       <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
       <prop key="save*">PROPAGATION_REQUIRED</prop>
       </props>
       </property>
       </bean>
      
      
       <bean id="habitationService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
       <property name="transactionManager"><ref local="myTransactionManager"/></property>
       <property name="target"><ref local="habitationDAO"/></property>
       <property name="transactionAttributes">
       <props>
       <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
       <prop key="save*">PROPAGATION_REQUIRED</prop>
       </props>
       </property>
       </bean>
      
      
       <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
       <property name="dataSource">
       <ref bean="dSource"/>
       </property>
       <property name="hibernateProperties">
       <props>
       <prop key="hibernate.dialect">${hibernate.dialect}</prop>
       <prop key="hibernate.show_sql">true</prop>
       <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
       </props>
       </property>
       <property name="mappingResources">
       <list>
       <value>org/appli/db/TContact.hbm</value>
       <value>org/appli/db/THabitation.hbm</value>
       </list>
       </property>
       </bean>
      
       <bean id="hTemplate" class="org.springframework.orm.hibernate.HibernateTemplate">
       <property name="sessionFactory">
       <ref bean="sessionFactory"/>
       </property>
       </bean>
      
       <bean id="contactDAO" class="org.appli.db.ContactsDao">
       <property name="hibernateTemplate">
       <ref local="hTemplate"/>
       </property>
       </bean>
      
       <bean id="habitationDAO" class="org.appli.db.HabitationsDao">
       <property name="hibernateTemplate">
       <ref local="hTemplate"/>
       </property>
       </bean>
      
       <bean id="contactBusiness" class="org.appli.business.ContactsBusiness" singleton="true">
       <property name="contactsDao">
       <ref local="contactDAO"/>
       </property>
       </bean>
      
      </beans>


      and there the Juint test that return null :

      public void testlookup() {
       try {
       Properties jndiProps = new Properties();
       jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interface");
       jndiProps.setProperty(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
       InitialContext context = new InitialContext(jndiProps);
       NamedXmlApplicationContext nXAC= (NamedXmlApplicationContext) context.lookup("test3");
       nXAC.getBean("contactDAO");
      
      
       } catch (NamingException e) {
       System.out.println("Naming Error " + e.getMessage());
      
       }
      
       }
      

      thank you in advance for your reply.

      jm


        • 1. Re: Jndi lookup on spring factory return 'null'
          jissma

          the boot sequence of the server :

          Undeploying Spring: file:/C:/dev/appservers/jbpm-server/server/jbpm/deploy/test3.spring
          Closing application context [org.jboss.spring.factory.NamedXmlApplicationContext;hashCode=19277415]
          Destroying singletons in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,dSource,myTransactionManager,contactService,habitationService,sessionFactory,hTemplate,contactDAO,habitationDAO,contactBusiness]; root of BeanFactory hierarchy}
          Retrieving dependent beans for bean 'dSource'
          Retrieving dependent beans for bean 'sessionFactory'
          Retrieving dependent beans for bean 'myTransactionManager'
          Retrieving dependent beans for bean 'contactService'
          Retrieving dependent beans for bean 'habitationService'
          Retrieving dependent beans for bean 'hTemplate'
          Retrieving dependent beans for bean 'contactDAO'
          Retrieving dependent beans for bean 'contactService'
          Retrieving dependent beans for bean 'contactBusiness'
          Retrieving dependent beans for bean 'habitationDAO'
          Retrieving dependent beans for bean 'habitationService'
          Invoking destroy() on bean with name 'sessionFactory'
          Closing Hibernate SessionFactory
          closing
          Invoking custom destroy method on bean with name 'dSource'
          Retrieving dependent beans for bean 'sessionFactory'
          Bean factory [test3] unbinded from local JNDI.
          Could not delete file:/C:/dev/appservers/jbpm-server/server/jbpm/tmp/deploy/tmp55960test3.spring restart will delete it
          checking for timers
          Creating [java.util.LinkedHashMap]
          Loading XML bean definitions from URL [jar:file:/C:/dev/appservers/jbpm-server/server/jbpm/tmp/deploy/tmp55964test3.spring!/META-INF/jboss-spring.xml]
          Attempting to resolve DTD [http://www.springframework.org/dtd/spring-beans.dtd] using [org.springframework.beans.factory.xml.BeansDtdResolver].
          Trying to resolve XML entity with public ID [null] and system ID [http://www.springframework.org/dtd/spring-beans.dtd]
          Trying to locate [spring-beans.dtd] in Spring jar
          Found beans DTD [http://www.springframework.org/dtd/spring-beans.dtd] in classpath
          Ignoring handler [org.springframework.web.servlet.config.MvcNamespaceHandler]: class not found
          Ignoring handler [org.springframework.transaction.config.TxNamespaceHandler]: class not found
          Bean factory for application context [org.jboss.spring.factory.NamedXmlApplicationContext;hashCode=21702681]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,dSource,myTransactionManager,contactService,habitationService,sessionFactory,hTemplate,contactDAO,habitationDAO,contactBusiness]; root of BeanFactory hierarchy
          10 beans defined in application context [org.jboss.spring.factory.NamedXmlApplicationContext;hashCode=21702681]
          Creating shared instance of singleton bean 'propertyConfigurer'
          Creating instance of bean 'propertyConfigurer' with merged definition [Root bean: class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer]; abstract=false; singleton=true; lazyInit=false; autowire=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/dev/appservers/jbpm-server/server/jbpm/tmp/deploy/tmp55964test3.spring!/META-INF/jboss-spring.xml]]
          Invoking BeanPostProcessors before instantiation of bean 'propertyConfigurer'
          Using cached introspection results for class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer]
          Creating [java.util.LinkedHashMap]
          Eagerly caching bean with name 'propertyConfigurer' to allow for resolving potential circular references
          Creating [java.util.LinkedHashSet]
          About to invoke write method [public void org.springframework.core.io.support.PropertiesLoaderSupport.setLocations(org.springframework.core.io.Resource[])] on object of class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer]
          Invoked write method [public void org.springframework.core.io.support.PropertiesLoaderSupport.setLocations(org.springframework.core.io.Resource[])] with value of type [[Lorg.springframework.core.io.Resource;]
          Invoking setBeanName on BeanNameAware bean 'propertyConfigurer'
          Invoking setBeanFactory on BeanFactoryAware bean 'propertyConfigurer'
          Invoking BeanPostProcessors before initialization of bean 'propertyConfigurer'
          Invoking BeanPostProcessors after initialization of bean 'propertyConfigurer'
          Loading properties file from class path resource [org/appli/hibernate.properties]
          Resolved placeholder 'hibernate.dialect' to value [net.sf.hibernate.dialect.FirebirdDialect]
          Creating [java.util.LinkedHashMap]
          Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@3b014c]
          Creating [java.util.LinkedHashSet]
          Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@1d26552]
          Creating [java.util.LinkedHashMap]
          Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,dSource,myTransactionManager,contactService,habitationService,sessionFactory,hTemplate,contactDAO,habitationDAO,contactBusiness]; root of BeanFactory hierarchy]
          Returning cached instance of singleton bean 'propertyConfigurer'
          Creating shared instance of singleton bean 'dSource'
          Creating instance of bean 'dSource' with merged definition [Root bean: class [org.apache.commons.dbcp.BasicDataSource]; abstract=false; singleton=true; lazyInit=false; autowire=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=close; defined in URL [jar:file:/C:/dev/appservers/jbpm-server/server/jbpm/tmp/deploy/tmp55964test3.spring!/META-INF/jboss-spring.xml]]
          Invoking BeanPostProcessors before instantiation of bean 'dSource'
          Getting BeanInfo for class [org.apache.commons.dbcp.BasicDataSource]
          Caching PropertyDescriptors for class [org.apache.commons.dbcp.BasicDataSource]
          Found property 'accessToUnderlyingConnectionAllowed' of type [boolean]
          Found property 'class' of type [java.lang.Class]
          Found property 'connection' of type [java.sql.Connection]
          Found property 'defaultAutoCommit' of type [boolean]
          Found property 'defaultCatalog' of type [java.lang.String]
          Found property 'defaultReadOnly' of type [boolean]
          Found property 'defaultTransactionIsolation' of type [int]
          Found property 'driverClassName' of type [java.lang.String]
          Found property 'initialSize' of type [int]
          Found property 'logAbandoned' of type [boolean]
          Found property 'logWriter' of type [java.io.PrintWriter]
          Found property 'loginTimeout' of type [int]
          Found property 'maxActive' of type [int]
          Found property 'maxIdle' of type [int]
          Found property 'maxOpenPreparedStatements' of type [int]
          Found property 'maxWait' of type [long]
          Found property 'minEvictableIdleTimeMillis' of type [long]
          Found property 'minIdle' of type [int]
          Found property 'numActive' of type [int]
          Found property 'numIdle' of type [int]
          Found property 'numTestsPerEvictionRun' of type [int]
          Found property 'password' of type [java.lang.String]
          Found property 'poolPreparedStatements' of type [boolean]
          Found property 'removeAbandoned' of type [boolean]
          Found property 'removeAbandonedTimeout' of type [int]
          Found property 'testOnBorrow' of type [boolean]
          Found property 'testOnReturn' of type [boolean]
          Found property 'testWhileIdle' of type [boolean]
          Found property 'timeBetweenEvictionRunsMillis' of type [long]
          Found property 'url' of type [java.lang.String]
          Found property 'username' of type [java.lang.String]
          Found property 'validationQuery' of type [java.lang.String]
          Class [org.apache.commons.dbcp.BasicDataSource] is not cache-safe
          Creating [java.util.LinkedHashMap]
          Eagerly caching bean with name 'dSource' to allow for resolving potential circular references
          About to invoke write method [public synchronized void org.apache.commons.dbcp.BasicDataSource.setUrl(java.lang.String)] on object of class [org.apache.commons.dbcp.BasicDataSource]
          Invoked write method [public synchronized void org.apache.commons.dbcp.BasicDataSource.setUrl(java.lang.String)] with value of type [java.lang.String]
          About to invoke write method [public synchronized void org.apache.commons.dbcp.BasicDataSource.setDriverClassName(java.lang.String)] on object of class [org.apache.commons.dbcp.BasicDataSource]
          Invoked write method [public synchronized void org.apache.commons.dbcp.BasicDataSource.setDriverClassName(java.lang.String)] with value of type [java.lang.String]
          About to invoke write method [public synchronized void org.apache.commons.dbcp.BasicDataSource.setUsername(java.lang.String)] on object of class [org.apache.commons.dbcp.BasicDataSource]
          Invoked write method [public synchronized void org.apache.commons.dbcp.BasicDataSource.setUsername(java.lang.String)] with value of type [java.lang.String]
          About to invoke write method [public synchronized void org.apache.commons.dbcp.BasicDataSource.setPassword(java.lang.String)] on object of class [org.apache.commons.dbcp.BasicDataSource]
          Invoked write method [public synchronized void org.apache.commons.dbcp.BasicDataSource.setPassword(java.lang.String)] with value of type [java.lang.String]
          Invoking BeanPostProcessors before initialization of bean 'dSource'
          Invoking BeanPostProcessors after initialization of bean 'dSource'
          Creating shared instance of singleton bean 'myTransactionManager'
          Creating instance of bean 'myTransactionManager' with merged definition [Root bean: class [org.springframework.orm.hibernate.HibernateTransactionManager]; abstract=false; singleton=true; lazyInit=false; autowire=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/dev/appservers/jbpm-server/server/jbpm/tmp/deploy/tmp55964test3.spring!/META-INF/jboss-spring.xml]]
          Invoking BeanPostProcessors before instantiation of bean 'myTransactionManager'
          Getting BeanInfo for class [org.springframework.orm.hibernate.HibernateTransactionManager]
          Caching PropertyDescriptors for class [org.springframework.orm.hibernate.HibernateTransactionManager]
          Found property 'autodetectDataSource' of type [boolean]
          Found property 'beanFactory' of type [org.springframework.beans.factory.BeanFactory]
          Found property 'class' of type [java.lang.Class]
          Found property 'dataSource' of type [javax.sql.DataSource]
          Found property 'entityInterceptor' of type [net.sf.hibernate.Interceptor]
          Found property 'entityInterceptorBeanName' of type [java.lang.String]
          Found property 'globalRollbackOnParticipationFailure' of type [boolean]
          Found property 'jdbcExceptionTranslator' of type [org.springframework.jdbc.support.SQLExceptionTranslator]
          Found property 'nestedTransactionAllowed' of type [boolean]
          Found property 'rollbackOnCommitFailure' of type [boolean]
          Found property 'sessionFactory' of type [net.sf.hibernate.SessionFactory]
          Found property 'transactionSynchronization' of type [int]
          Found property 'transactionSynchronizationName' of type [java.lang.String]
          Class [org.springframework.orm.hibernate.HibernateTransactionManager] is not cache-safe
          Creating [java.util.LinkedHashMap]
          Eagerly caching bean with name 'myTransactionManager' to allow for resolving potential circular references
          Resolving reference from property 'bean property 'sessionFactory'' in bean 'myTransactionManager' to bean 'sessionFactory'
          Creating [java.util.LinkedHashSet]
          Creating shared instance of singleton bean 'sessionFactory'
          Creating instance of bean 'sessionFactory' with merged definition [Root bean: class [org.springframework.orm.hibernate.LocalSessionFactoryBean]; abstract=false; singleton=true; lazyInit=false; autowire=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/dev/appservers/jbpm-server/server/jbpm/tmp/deploy/tmp55964test3.spring!/META-INF/jboss-spring.xml]]
          Invoking BeanPostProcessors before instantiation of bean 'sessionFactory'
          Getting BeanInfo for class [org.springframework.orm.hibernate.LocalSessionFactoryBean]
          Caching PropertyDescriptors for class [org.springframework.orm.hibernate.LocalSessionFactoryBean]
          Found property 'class' of type [java.lang.Class]
          Found property 'configLocation' of type [org.springframework.core.io.Resource]
          Found property 'configuration' of type [net.sf.hibernate.cfg.Configuration]
          Found property 'dataSource' of type [javax.sql.DataSource]
          Found property 'entityInterceptor' of type [net.sf.hibernate.Interceptor]
          Found property 'hibernateProperties' of type [java.util.Properties]
          Found property 'jtaTransactionManager' of type [javax.transaction.TransactionManager]
          Found property 'lobHandler' of type [org.springframework.jdbc.support.lob.LobHandler]
          Found property 'mappingDirectoryLocations' of type [[Lorg.springframework.core.io.Resource;]
          Found property 'mappingJarLocations' of type [[Lorg.springframework.core.io.Resource;]
          Found property 'mappingLocations' of type [[Lorg.springframework.core.io.Resource;]
          Found property 'mappingResources' of type [[Ljava.lang.String;]
          Found property 'namingStrategy' of type [net.sf.hibernate.cfg.NamingStrategy]
          Found property 'object' of type [java.lang.Object]
          Found property 'objectType' of type [java.lang.Class]
          Found property 'schemaUpdate' of type [boolean]
          Found property 'singleton' of type [boolean]
          Found property 'useTransactionAwareDataSource' of type [boolean]
          Class [org.springframework.orm.hibernate.LocalSessionFactoryBean] is not cache-safe
          Creating [java.util.LinkedHashMap]
          Eagerly caching bean with name 'sessionFactory' to allow for resolving potential circular references
          Resolving reference from property 'bean property 'dataSource'' in bean 'sessionFactory' to bean 'dSource'
          Creating [java.util.LinkedHashSet]
          Returning cached instance of singleton bean 'dSource'
          About to invoke write method [public void org.springframework.orm.hibernate.LocalSessionFactoryBean.setDataSource(javax.sql.DataSource)] on object of class [org.springframework.orm.hibernate.LocalSessionFactoryBean]
          Invoked write method [public void org.springframework.orm.hibernate.LocalSessionFactoryBean.setDataSource(javax.sql.DataSource)] with value of type [javax.sql.DataSource]
          About to invoke write method [public void org.springframework.orm.hibernate.LocalSessionFactoryBean.setHibernateProperties(java.util.Properties)] on object of class [org.springframework.orm.hibernate.LocalSessionFactoryBean]
          Invoked write method [public void org.springframework.orm.hibernate.LocalSessionFactoryBean.setHibernateProperties(java.util.Properties)] with value of type [java.util.Properties]
          About to invoke write method [public void org.springframework.orm.hibernate.LocalSessionFactoryBean.setMappingResources(java.lang.String[])] on object of class [org.springframework.orm.hibernate.LocalSessionFactoryBean]
          Invoked write method [public void org.springframework.orm.hibernate.LocalSessionFactoryBean.setMappingResources(java.lang.String[])] with value of type [[Ljava.lang.String;]
          Invoking BeanPostProcessors before initialization of bean 'sessionFactory'
          Invoking afterPropertiesSet() on bean with name 'sessionFactory'
          Hibernate 2.1.6
          hibernate.properties not found
          using CGLIB reflection optimizer
          Mapping class: org.appli.db.TContact -> T_CONTACT
          Mapping class: org.appli.db.THabitation -> T_HABITATION
          Building new Hibernate SessionFactory
          processing one-to-many association mappings
          Mapping collection: org.appli.db.THabitation.TContactSet -> T_CONTACT
          processing one-to-one association property references
          processing foreign key constraints
          Using dialect: net.sf.hibernate.dialect.FirebirdDialect
          Use outer join fetching: true
          Initializing connection provider: org.springframework.orm.hibernate.LocalDataSourceConnectionProvider
          No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
          Use scrollable result sets: true
          Use JDBC3 getGeneratedKeys(): false
          Optimize cache for minimal puts: false
          echoing all SQL to stdout
          Query language substitutions: {}
          cache provider: net.sf.hibernate.cache.EhCacheProvider
          instantiating and configuring caches
          building session factory
          Not binding factory to JNDI, no JNDI name configured
          Invoking BeanPostProcessors after initialization of bean 'sessionFactory'
          Bean with name 'sessionFactory' is a factory bean
          About to invoke write method [public void org.springframework.orm.hibernate.HibernateTransactionManager.setSessionFactory(net.sf.hibernate.SessionFactory)] on object of class [org.springframework.orm.hibernate.HibernateTransactionManager]
          Invoked write method [public void org.springframework.orm.hibernate.HibernateTransactionManager.setSessionFactory(net.sf.hibernate.SessionFactory)] with value of type [net.sf.hibernate.SessionFactory]
          Invoking setBeanFactory on BeanFactoryAware bean 'myTransactionManager'
          Invoking BeanPostProcessors before initialization of bean 'myTransactionManager'
          Invoking afterPropertiesSet() on bean with name 'myTransactionManager'
          Using DataSource [org.apache.commons.dbcp.BasicDataSource@c5c32e] of Hibernate SessionFactory for HibernateTransactionManager
          Invoking BeanPostProcessors after initialization of bean 'myTransactionManager'
          Creating shared instance of singleton bean 'contactService'
          Creating instance of bean 'contactService' with merged definition [Root bean: class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean]; abstract=false; singleton=true; lazyInit=false; autowire=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/dev/appservers/jbpm-server/server/jbpm/tmp/deploy/tmp55964test3.spring!/META-INF/jboss-spring.xml]]
          Invoking BeanPostProcessors before instantiation of bean 'contactService'
          Getting BeanInfo for class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean]
          Caching PropertyDescriptors for class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean]
          Found property 'advisorAdapterRegistry' of type [org.springframework.aop.framework.adapter.AdvisorAdapterRegistry]
          Found property 'aopProxyFactory' of type [org.springframework.aop.framework.AopProxyFactory]
          Found property 'beanFactory' of type [org.springframework.beans.factory.BeanFactory]
          Found property 'class' of type [java.lang.Class]
          Found property 'exposeProxy' of type [boolean]
          Found property 'frozen' of type [boolean]
          Found property 'object' of type [java.lang.Object]
          Found property 'objectType' of type [java.lang.Class]
          Found property 'opaque' of type [boolean]
          Found property 'optimize' of type [boolean]
          Found property 'pointcut' of type [org.springframework.aop.Pointcut]
          Found property 'postInterceptors' of type [[Ljava.lang.Object;]
          Found property 'preInterceptors' of type [[Ljava.lang.Object;]
          Found property 'proxyInterfaces' of type [[Ljava.lang.String;]
          Found property 'proxyTargetClass' of type [boolean]
          Found property 'singleton' of type [boolean]
          Found property 'target' of type [java.lang.Object]
          Found property 'transactionAttributeSource' of type [org.springframework.transaction.interceptor.TransactionAttributeSource]
          Found property 'transactionAttributes' of type [java.util.Properties]
          Found property 'transactionManager' of type [org.springframework.transaction.PlatformTransactionManager]
          Class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean] is not cache-safe
          Creating [java.util.LinkedHashMap]
          Eagerly caching bean with name 'contactService' to allow for resolving potential circular references
          Resolving reference from property 'bean property 'transactionManager'' in bean 'contactService' to bean 'myTransactionManager'
          Creating [java.util.LinkedHashSet]
          Returning cached instance of singleton bean 'myTransactionManager'
          Resolving reference from property 'bean property 'target'' in bean 'contactService' to bean 'contactDAO'
          Creating [java.util.LinkedHashSet]
          Creating shared instance of singleton bean 'contactDAO'
          Creating instance of bean 'contactDAO' with merged definition [Root bean: class [org.appli.db.ContactsDao]; abstract=false; singleton=true; lazyInit=false; autowire=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/dev/appservers/jbpm-server/server/jbpm/tmp/deploy/tmp55964test3.spring!/META-INF/jboss-spring.xml]]
          Invoking BeanPostProcessors before instantiation of bean 'contactDAO'
          Getting BeanInfo for class [org.appli.db.ContactsDao]
          Caching PropertyDescriptors for class [org.appli.db.ContactsDao]
          Found property 'class' of type [java.lang.Class]
          Found property 'contact'
          Found property 'hibernateTemplate' of type [org.springframework.orm.hibernate.HibernateTemplate]
          Found property 'sessionFactory' of type [net.sf.hibernate.SessionFactory]
          Class [org.appli.db.ContactsDao] is not cache-safe
          Creating [java.util.LinkedHashMap]
          Eagerly caching bean with name 'contactDAO' to allow for resolving potential circular references
          Resolving reference from property 'bean property 'hibernateTemplate'' in bean 'contactDAO' to bean 'hTemplate'
          Creating [java.util.LinkedHashSet]
          Creating shared instance of singleton bean 'hTemplate'
          Creating instance of bean 'hTemplate' with merged definition [Root bean: class [org.springframework.orm.hibernate.HibernateTemplate]; abstract=false; singleton=true; lazyInit=false; autowire=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/dev/appservers/jbpm-server/server/jbpm/tmp/deploy/tmp55964test3.spring!/META-INF/jboss-spring.xml]]
          Invoking BeanPostProcessors before instantiation of bean 'hTemplate'
          Getting BeanInfo for class [org.springframework.orm.hibernate.HibernateTemplate]
          Caching PropertyDescriptors for class [org.springframework.orm.hibernate.HibernateTemplate]
          Found property 'allowCreate' of type [boolean]
          Found property 'alwaysUseNewSession' of type [boolean]
          Found property 'beanFactory' of type [org.springframework.beans.factory.BeanFactory]
          Found property 'cacheQueries' of type [boolean]
          Found property 'checkWriteOperations' of type [boolean]
          Found property 'class' of type [java.lang.Class]
          Found property 'entityInterceptor' of type [net.sf.hibernate.Interceptor]
          Found property 'entityInterceptorBeanName' of type [java.lang.String]
          Found property 'exposeNativeSession' of type [boolean]
          Found property 'fetchSize' of type [int]
          Found property 'flushMode' of type [int]
          Found property 'flushModeName' of type [java.lang.String]
          Found property 'jdbcExceptionTranslator' of type [org.springframework.jdbc.support.SQLExceptionTranslator]
          Found property 'maxResults' of type [int]
          Found property 'queryCacheRegion' of type [java.lang.String]
          Found property 'sessionFactory' of type [net.sf.hibernate.SessionFactory]
          Class [org.springframework.orm.hibernate.HibernateTemplate] is not cache-safe
          Creating [java.util.LinkedHashMap]
          Eagerly caching bean with name 'hTemplate' to allow for resolving potential circular references
          Resolving reference from property 'bean property 'sessionFactory'' in bean 'hTemplate' to bean 'sessionFactory'
          Returning cached instance of singleton bean 'sessionFactory'
          Bean with name 'sessionFactory' is a factory bean
          About to invoke write method [public void org.springframework.orm.hibernate.HibernateAccessor.setSessionFactory(net.sf.hibernate.SessionFactory)] on object of class [org.springframework.orm.hibernate.HibernateTemplate]
          Invoked write method [public void org.springframework.orm.hibernate.HibernateAccessor.setSessionFactory(net.sf.hibernate.SessionFactory)] with value of type [net.sf.hibernate.SessionFactory]
          Invoking setBeanFactory on BeanFactoryAware bean 'hTemplate'
          Invoking BeanPostProcessors before initialization of bean 'hTemplate'
          Invoking afterPropertiesSet() on bean with name 'hTemplate'
          Invoking BeanPostProcessors after initialization of bean 'hTemplate'
          About to invoke write method [public final void org.springframework.orm.hibernate.support.HibernateDaoSupport.setHibernateTemplate(org.springframework.orm.hibernate.HibernateTemplate)] on object of class [org.appli.db.ContactsDao]
          Invoked write method [public final void org.springframework.orm.hibernate.support.HibernateDaoSupport.setHibernateTemplate(org.springframework.orm.hibernate.HibernateTemplate)] with value of type [org.springframework.orm.hibernate.HibernateTemplate]
          Invoking BeanPostProcessors before initialization of bean 'contactDAO'
          Invoking afterPropertiesSet() on bean with name 'contactDAO'
          Invoking BeanPostProcessors after initialization of bean 'contactDAO'
          About to invoke write method [public void org.springframework.transaction.interceptor.TransactionProxyFactoryBean.setTransactionManager(org.springframework.transaction.PlatformTransactionManager)] on object of class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean]
          Invoked write method [public void org.springframework.transaction.interceptor.TransactionProxyFactoryBean.setTransactionManager(org.springframework.transaction.PlatformTransactionManager)] with value of type [org.springframework.transaction.PlatformTransactionManager]
          About to invoke write method [public void org.springframework.transaction.interceptor.TransactionProxyFactoryBean.setTarget(java.lang.Object)] on object of class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean]
          Invoked write method [public void org.springframework.transaction.interceptor.TransactionProxyFactoryBean.setTarget(java.lang.Object)] with value of type [java.lang.Object]
          About to invoke write method [public void org.springframework.transaction.interceptor.TransactionProxyFactoryBean.setTransactionAttributes(java.util.Properties)] on object of class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean]
          Adding transactional method [find*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly]
          Adding transactional method [save*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
          Invoked write method [public void org.springframework.transaction.interceptor.TransactionProxyFactoryBean.setTransactionAttributes(java.util.Properties)] with value of type [java.util.Properties]
          Invoking setBeanFactory on BeanFactoryAware bean 'contactService'
          Invoking BeanPostProcessors before initialization of bean 'contactService'
          Invoking afterPropertiesSet() on bean with name 'contactService'
          Creating [java.util.IdentityHashMap]
          Added new aspect interface: org.springframework.beans.factory.InitializingBean
          Added new aspect interface: org.appli.db.IContactsDao
          Creating JDK dynamic proxy for [org.appli.db.ContactsDao]
          Invoking BeanPostProcessors after initialization of bean 'contactService'
          Calling code asked for FactoryBean instance for name 'contactService'
          Returning cached instance of singleton bean 'contactService'
          Bean with name 'contactService' is a factory bean
          Creating shared instance of singleton bean 'habitationService'
          Creating instance of bean 'habitationService' with merged definition [Root bean: class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean]; abstract=false; singleton=true; lazyInit=false; autowire=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/dev/appservers/jbpm-server/server/jbpm/tmp/deploy/tmp55964test3.spring!/META-INF/jboss-spring.xml]]
          Invoking BeanPostProcessors before instantiation of bean 'habitationService'
          Using cached introspection results for class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean]
          Creating [java.util.LinkedHashMap]
          Eagerly caching bean with name 'habitationService' to allow for resolving potential circular references
          Resolving reference from property 'bean property 'transactionManager'' in bean 'habitationService' to bean 'myTransactionManager'
          Returning cached instance of singleton bean 'myTransactionManager'
          Resolving reference from property 'bean property 'target'' in bean 'habitationService' to bean 'habitationDAO'
          Creating [java.util.LinkedHashSet]
          Creating shared instance of singleton bean 'habitationDAO'
          Creating instance of bean 'habitationDAO' with merged definition [Root bean: class [org.appli.db.HabitationsDao]; abstract=false; singleton=true; lazyInit=false; autowire=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/dev/appservers/jbpm-server/server/jbpm/tmp/deploy/tmp55964test3.spring!/META-INF/jboss-spring.xml]]
          Invoking BeanPostProcessors before instantiation of bean 'habitationDAO'
          Getting BeanInfo for class [org.appli.db.HabitationsDao]
          Caching PropertyDescriptors for class [org.appli.db.HabitationsDao]
          Found property 'allHabitations' of type [java.util.List]
          Found property 'class' of type [java.lang.Class]
          Found property 'habitation'
          Found property 'hibernateTemplate' of type [org.springframework.orm.hibernate.HibernateTemplate]
          Found property 'sessionFactory' of type [net.sf.hibernate.SessionFactory]
          Class [org.appli.db.HabitationsDao] is not cache-safe
          Creating [java.util.LinkedHashMap]
          Eagerly caching bean with name 'habitationDAO' to allow for resolving potential circular references
          Resolving reference from property 'bean property 'hibernateTemplate'' in bean 'habitationDAO' to bean 'hTemplate'
          Returning cached instance of singleton bean 'hTemplate'
          About to invoke write method [public final void org.springframework.orm.hibernate.support.HibernateDaoSupport.setHibernateTemplate(org.springframework.orm.hibernate.HibernateTemplate)] on object of class [org.appli.db.HabitationsDao]
          Invoked write method [public final void org.springframework.orm.hibernate.support.HibernateDaoSupport.setHibernateTemplate(org.springframework.orm.hibernate.HibernateTemplate)] with value of type [org.springframework.orm.hibernate.HibernateTemplate]
          Invoking BeanPostProcessors before initialization of bean 'habitationDAO'
          Invoking afterPropertiesSet() on bean with name 'habitationDAO'
          Invoking BeanPostProcessors after initialization of bean 'habitationDAO'
          About to invoke write method [public void org.springframework.transaction.interceptor.TransactionProxyFactoryBean.setTransactionManager(org.springframework.transaction.PlatformTransactionManager)] on object of class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean]
          Invoked write method [public void org.springframework.transaction.interceptor.TransactionProxyFactoryBean.setTransactionManager(org.springframework.transaction.PlatformTransactionManager)] with value of type [org.springframework.transaction.PlatformTransactionManager]
          About to invoke write method [public void org.springframework.transaction.interceptor.TransactionProxyFactoryBean.setTarget(java.lang.Object)] on object of class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean]
          Invoked write method [public void org.springframework.transaction.interceptor.TransactionProxyFactoryBean.setTarget(java.lang.Object)] with value of type [java.lang.Object]
          About to invoke write method [public void org.springframework.transaction.interceptor.TransactionProxyFactoryBean.setTransactionAttributes(java.util.Properties)] on object of class [org.springframework.transaction.interceptor.TransactionProxyFactoryBean]
          Adding transactional method [find*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly]
          Adding transactional method [save*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
          Invoked write method [public void org.springframework.transaction.interceptor.TransactionProxyFactoryBean.setTransactionAttributes(java.util.Properties)] with value of type [java.util.Properties]
          Invoking setBeanFactory on BeanFactoryAware bean 'habitationService'
          Invoking BeanPostProcessors before initialization of bean 'habitationService'
          Invoking afterPropertiesSet() on bean with name 'habitationService'
          Creating [java.util.IdentityHashMap]
          Added new aspect interface: org.appli.db.IHabitationsDao
          Added new aspect interface: org.springframework.beans.factory.InitializingBean
          Creating JDK dynamic proxy for [org.appli.db.HabitationsDao]
          Invoking BeanPostProcessors after initialization of bean 'habitationService'
          Calling code asked for FactoryBean instance for name 'habitationService'
          Returning cached instance of singleton bean 'habitationService'
          Bean with name 'habitationService' is a factory bean
          Returning cached instance of singleton bean 'sessionFactory'
          Calling code asked for FactoryBean instance for name 'sessionFactory'
          Returning cached instance of singleton bean 'sessionFactory'
          Bean with name 'sessionFactory' is a factory bean
          Returning cached instance of singleton bean 'hTemplate'
          Returning cached instance of singleton bean 'contactDAO'
          Returning cached instance of singleton bean 'habitationDAO'
          Creating shared instance of singleton bean 'contactBusiness'
          Creating instance of bean 'contactBusiness' with merged definition [Root bean: class [org.appli.business.ContactsBusiness]; abstract=false; singleton=true; lazyInit=false; autowire=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/C:/dev/appservers/jbpm-server/server/jbpm/tmp/deploy/tmp55964test3.spring!/META-INF/jboss-spring.xml]]
          Invoking BeanPostProcessors before instantiation of bean 'contactBusiness'
          Getting BeanInfo for class [org.appli.business.ContactsBusiness]
          Caching PropertyDescriptors for class [org.appli.business.ContactsBusiness]
          Found property 'class' of type [java.lang.Class]
          Found property 'contactsDao' of type [org.appli.db.IContactsDao]
          Class [org.appli.business.ContactsBusiness] is not cache-safe
          Creating [java.util.LinkedHashMap]
          Eagerly caching bean with name 'contactBusiness' to allow for resolving potential circular references
          Resolving reference from property 'bean property 'contactsDao'' in bean 'contactBusiness' to bean 'contactDAO'
          Returning cached instance of singleton bean 'contactDAO'
          About to invoke write method [public void org.appli.business.ContactsBusiness.setContactsDao(org.appli.db.IContactsDao)] on object of class [org.appli.business.ContactsBusiness]
          Invoked write method [public void org.appli.business.ContactsBusiness.setContactsDao(org.appli.db.IContactsDao)] with value of type [org.appli.db.IContactsDao]
          Invoking BeanPostProcessors before initialization of bean 'contactBusiness'
          Invoking BeanPostProcessors after initialization of bean 'contactBusiness'
          Bean factory [test3] binded to local JNDI.
          Deployed Spring: file:/C:/dev/appservers/jbpm-server/server/jbpm/deploy/test3.spring
          


          • 2. Re: Jndi lookup on spring factory return 'null'
            jissma

            i try with JBOss AS 4.0.4 , the result is the same ...

            • 3. Re: Jndi lookup on spring factory return 'null'
              alesj

              Runtime lookup uses this:

               private Object getObjectFromBeanFactory(Spring spring) throws Exception
               {
               BeanFactory beanFactory = (BeanFactory) org.jboss.naming.Util.lookup(spring.jndiName(), BeanFactory.class);
               return beanFactory.getBean(spring.bean());
               }
              


              Will try doing the same as you - from junit or standalone/client.

              • 4. Re: Jndi lookup on spring factory return 'null'
                jissma

                thanks but it's still not working, I try this ....

                public class jndiLookup extends TestCase {
                
                 public void testlookup() {
                 try {
                 Properties jndiProps = new Properties();
                 jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                 jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interface");
                 jndiProps.setProperty(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
                 Context context = new InitialContext(jndiProps);
                
                 BeanFactory beanFactory = (BeanFactory) org.jboss.naming.Util.lookup(context, "test3", BeanFactory.class);
                
                 } catch (NamingException e) {
                 System.out.println("Naming Error " + e);
                
                 } catch (Exception e) {
                 e.printStackTrace();
                 }
                
                 }
                }
                


                and the result is


                java.lang.NullPointerException
                 at org.jboss.naming.Util.checkObject(Util.java:230)
                 at org.jboss.naming.Util.lookup(Util.java:199)
                 at spring.deplyer.test.jndiLookup.testlookup(jndiLookup.java:25)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                 at java.lang.reflect.Method.invoke(Unknown Source)
                 at junit.framework.TestCase.runTest(TestCase.java:154)
                 at junit.framework.TestCase.runBare(TestCase.java:127)
                 at junit.framework.TestResult$1.protect(TestResult.java:106)
                 at junit.framework.TestResult.runProtected(TestResult.java:124)
                 at junit.framework.TestResult.run(TestResult.java:109)
                 at junit.framework.TestCase.run(TestCase.java:118)
                 at junit.framework.TestSuite.runTest(TestSuite.java:208)
                 at junit.framework.TestSuite.run(TestSuite.java:203)
                 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
                 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
                 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
                


                • 5. Re: Jndi lookup on spring factory return 'null'
                  blubberfoo

                  Hello,

                  I have the same problem. Have you found a solution yet?

                  I have JBoss 4.0.4GA and a .ear archive with a bla-server.spring archive inside. The spring deployer does its job well and the ApplicationContext is created and registered to local JNDI:

                  11:49:27,755 INFO [ApplicationContextLoaderImpl] Bean factory [bla-server] binded to local JNDI.
                  


                  The JNDIView lists the bound object in the gloabal namespace:

                  +- bla-server (class: org.jboss.spring.factory.NamedXmlApplicationContext)
                  


                  With the following code it is not possible to access the bound object when the snippet is run from outside the container.

                  Hashtable<String,String> environment = new Hashtable<String,String>();
                  environment.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
                  environment.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
                  environment.put("java.naming.provider.url","jnp://localhost:1099");
                  
                  try {
                   initialContext = new InitialContext(environment);
                  }
                  catch (NamingException exception) {
                   fail("Could not create InitialContext.Exception:"+exception);
                   return;
                  }
                  try {
                   this.ac = (ApplicationContext)initialContext.lookup("bla-server");
                  }
                  catch (NamingException exception) {
                   fail("Could not obtain 'bla-server' ApplicationContext:"+exception);
                   return;
                  }
                  


                  I want to access the ApplicationContext from the outside to test my beans and the associated ejb3 persistence which are inside the container. Access from inside the container is no problem.

                  Is there a way to register the ApplicationContext in a way it is visible from the outside? On a more general note I would be interested in how people do test there beans when they rely on the container.

                  Regards,

                  Ricky

                  • 6. Re: Jndi lookup on spring factory return 'null'
                    zumbiehl

                    Hi ,

                    I have the exact same issue here trying to access the Spring NamedXmlApplicationContext bound to the global jndi context from a JUnit client.

                    The lookup returns me a null instance of the Spring context although lookups work fine from within the JBoss container.

                    Has anyone been successful doing that ?

                    Thanks for any hint on this
                    christian

                    • 7. Re: Jndi lookup on spring factory return 'null'
                      alesj

                       

                      "zumbiehl" wrote:

                      The lookup returns me a null instance of the Spring context although lookups work fine from within the JBoss container.

                      I think this is expected behavior.
                      Since we put the bean factory into non-serializable JNDI context, there are no means of pulling it out from another VM.
                      http://docs.jboss.org/jbossas/javadoc/4.0.2/org/jboss/naming/NonSerializableFactory.java.html

                      We cannot expect that all beans are serializable, plus the bean factory impl itself is not serializable in some places.

                      • 8. Re: Jndi lookup on spring factory return 'null'
                        ivanyuan

                        I have exact same issue. I want to retrieve either the deployed bean or the bean factory from outside of the spring deployer.

                        Wonder if there is any way to get the bean factory handler? Since the handler is stored in JBoss local JNDI, it should be a way to do it.

                        Does any one have clue?

                        Thanks,
                        Ivan Yuan

                        • 9. Re: Jndi lookup on spring factory return 'null'
                          marius.bogoevici

                          Ivan,

                          From the other posts I understand that you are trying to get access to the JNDI-bound Application Context from another application running in the same application server (hence the same VM). These questions are about accessing the Application Context from outside the AS/VM (which as Ales said earlier is not possible, in short because of serialization-related issues).

                          So, you should access the context by a simple JNDI lookup for the name defined in the element, as long as this is done from within an application running in the same AS the one where the deployer is being used.

                          Marius