ejb session bean not bound issue
Hi there,
I've got a strange situation in my spring+ejb3 deployment under jboss5.0.1GA + IntelliJ IDEA 8.1.4.
every time i start jboss from IntelliJ, it will give me
'
ERROR [DispatcherServlet] Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'pservice': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: ProductServiceImpl not bound ' error
springapp-servlet.xml
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: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/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"/>
</bean>
<!-- the application context definition for the springapp DispatcherServlet -->
<jee:jndi-lookup id="pservice" jndi-name="ProductServiceImpl/remote"></jee:jndi-lookup>
<bean id="productManager" class="com.lab.productsystem.spring.bean.ProductManagerImpl">
<property name="pservice" ref="pservice"/>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<bean id="urlHandler"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<map>
<entry key="/listProduct.htm" value="productController"/>
<entry key="/editProduct.htm" value="productController"/>
</map>
</property>
</bean>
<bean id="productController"
class="com.lab.productsystem.spring.mvc.controller.ProductController">
<property name="methodNameResolver"
ref="productControllerResolver"/>
<property name="productManager" ref="productManager"/>
</bean>
<bean id="productControllerResolver"
class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/listProduct.htm">handleListProductRequest</prop>
<prop key="/editProduct.htm">handleUpdateProductRequest</prop>
</props>
</property>
</bean>
</beans>
session bean class
Code:
@Stateless
public class ProductServiceImpl implements ProductService{
@PersistenceContext
private EntityManager em;
public Product findById(int id) {
try {
Product product = em.find(Product.class, id);
return product;
} catch (Exception e) {
System.out.println(e);
return null;
}
}
public List<Product> findAll() {
try {
return em.createNamedQuery("Product.findAll").getResultList();
} catch (Exception e) {
System.out.println(e);
return null;
}
}
}
class to call this session bean service via JNDI lookup
Code:
public class ProductManagerImpl implements ProductManager{
private ProductService pservice; // inject me!!
public void setPservice(ProductService p){
this.pservice=p;
}
public Product getProduct(int id) {
return pservice.findById(id);
}
public List<Product> getProducts() {
return pservice.findAll();
}
}
he strange thing is, even though, the first time upon jboss startup it always says 'ProductServiceImpl not bound'. as soon as I deploy the project again via my IDE, the error just gone!! and the app runs perfect.
is there a way to get rid of this not bound error?
Thanks in advance.