Environnement
-Jboss 4.2x + HSQL database
-spring 2.5.6
-EJB3



My test client in Java bellow . I've checked the jndi list on my jboss 4.2x but i can't figure out why spring cannot bind the EJB context using the (jndi jee:jndi-lookup tag)

My exception raised on main program is javax.naming.NameNotFoundException . I think it because the biding isn't done by Spring . What did I miss ? Is there something to add on Jboss 4.2 ?

Caused by: javax.naming.NameNotFoundException: com.ejb.service.CustomerServiceImpl not bound

TEST CLIENT CODE

Code:
import javax.naming.Context; import javax.naming.InitialContext;

import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ejb.domain.Customer; import com.spring.service.CustomerManager;

public class SpringAndEJBMain { private static Context context;
public static void main(String[] args) {

    try {       
        Context context = new InitialContext();
        context.lookup("CustomerServiceImpl/remote");
        CustomerService stock = (CustomerService) context.lookup("CustomerServiceImpl/remote");

         ApplicationContext contextSpring =
                 new ClassPathXmlApplicationContext("SpringXMLConfig.xml");

         CustomerManager service = (CustomerManager) contextSpring.getBean("manageCustomer");
         Customer customer = new Customer();
         customer.setFirstName("Meera");
         customer.setLastName("Subbarao");
         customer.setMiddleName("B");
         customer.setEmailId("meera@springandejb.com");
         customer.setCustomerId(new Long(1));

         service.addCustomer(customer);
         for (Customer cust : service.listCustomers()) {
             System.out.println(cust.getFirstName());
             System.out.println(cust.getLastName());
             System.out.println(cust.getMiddleName());
             System.out.println(cust.getEmailId());

         }
         service.removeCustomer(new Long(1));

    }
    catch (Exception e) {
         e.printStackTrace();
      }

}

}
JNDI TREE on Jboss 4.2

+- CustomerServiceImpl (class: org.jnp.interfaces.NamingContext)
| +- remote (proxy: $Proxy103 implements interface com.ejb.service.CustomerService,interface org.jboss.ejb3.JBossProxy)


Code:
package com.ejb.service;

import java.util.Collection;

import javax.ejb.Remote;

import com.ejb.domain.Customer;

@Remote public interface CustomerService {

Customer create(Customer info);

Customer update(Customer info);

void remove(Long customerId);

Collection<Customer> findAll();

Customer[] findAllAsArray();

Customer findByPrimaryKey(Long customerId);

}


package com.ejb.service;

import com.ejb.domain.Customer; import java.util.Collection; import javax.ejb.Stateless; import javax.interceptor.Interceptors; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.Query; import javax.jws.WebMethod;

@WebService(name = "CustomerService", serviceName = "CustomerService", targetNamespace = "urn:CustomerService") @SOAPBinding(style = SOAPBinding.Style.RPC) @Stateless(name = "CustomerServiceImpl") public class CustomerServiceImpl implements CustomerService {

@PersistenceContext(name="Customer")
private EntityManager manager;

@WebMethod
public Customer create(Customer info) {
    this.manager.persist(info);
    return info;
}

@WebMethod
public Customer update(Customer info) {
    return this.manager.merge(info);
}

@WebMethod
public void remove(Long customerId) {
    this.manager.remove(this.manager.getReference(Customer.class, customerId));
}

public Collection<Customer> findAll() {
    Query query = this.manager.createQuery("SELECT c FROM Customer c");
    return query.getResultList();
}

@WebMethod
public Customer[] findAllAsArray() {
    Collection<Customer> collection = findAll();
    return (Customer[]) collection.toArray(new Customer[collection.size()]);
}

@WebMethod
public Customer findByPrimaryKey(Long customerId) {
    return (Customer) this.manager.find(Customer.class, customerId);
}

}

Code:
<persistence>
   <persistence-unit name="Customer">
   	 <class>com.ejb.domain.Customer</class>
      <jta-data-source>java:/DefaultDS</jta-data-source>
      <properties>
      	 <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
         <property name="hibernate.hbm2ddl.auto" value="update"/>
      </properties>
   </persistence-unit>
</persistence>
Spring configuration
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jee="http://www.springframework.org/schema/jee"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
       
       
       
	<!-- Use a custom JNDI bean factory configured not to prepend lookups with 
		"java:comp/env" -->
	<bean id="jndiFactory" class="org.springframework.jndi.support.SimpleJndiBeanFactory">
    	<property name="resourceRef" value="false" />
	</bean>

	<!-- Configure the CommonAnnotationBeanPostProcessor to always use JNDI 
		lookup (for EJBs) and use the custom JNDI bean factory above. -->
	<bean
		class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor">
		<property name="alwaysUseJndiLookup" value="true" />
		<property name="jndiFactory" ref="jndiFactory" />
	</bean>


	<jee:jndi-lookup id="customerService"
		jndi-name="com.ejb.service.CustomerServiceImpl">
	</jee:jndi-lookup>



	<bean id="manageCustomer" class="com.spring.service.CustomerManagerImpl">
		<property name="customerService" ref="customerService" />
	</bean>
</beans>
jndi properties
java.naming.factory.initial=org.jnp.interfaces.Nam ingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org. jnp.interfaces
java.naming.provider.url=localhost:1099


Full Stack Trace :

org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'customerService': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: com.ejb.service.CustomerServiceImpl not bound at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380) at