[jboss-user] [JBoss/Spring Integration] - Jndi lookup on spring factory return 'null'

jissma do-not-reply at jboss.com
Wed Sep 20 11:03:33 EDT 2006


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


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972962#3972962

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972962



More information about the jboss-user mailing list