Announcement Announcement Module
Collapse
No announcement yet.
ejb session bean not bound issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

  • #2
    any thought?

    Comment


    • #3
      I found the solution after inspired by jaikiran pai from jboss community forum. In case anyone need it.

      the revised spring config file is this:


      <jee:jndi-lookup id="pservice" jndi-name="ProductServiceImpl/remote" lookup-on-startup="false" proxy-interface="com.lab.productsystem.ejb.session.Produ ctService"></jee:jndi-lookup>

      Comment


      • #4
        Hey blowice,
        I am facing the same problem as your. In mine server is started but whenever I am trying to use the controller the jndi lookup id is not bound error shows.What shold i do????

        Can u plzz help me out

        Comment


        • #5
          Originally posted by abhish View Post
          Hey blowice,
          I am facing the same problem as your. In mine server is started but whenever I am trying to use the controller the jndi lookup id is not bound error shows.What shold i do????

          Can u plzz help me out

          I found the solution after inspired by jaikiran pai from jboss community forum. In case anyone need it.

          __________________________________________________ ___

          wholesale jerseys
          nike nfl jerseys
          Cheap Pro Jerseys

          Comment


          • #6
            I found the solution after inspired by jaikiran pai from jboss community forum. In case anyone need it.
            Hey there,
            I tried to solve my problem through that solution also but not much is achieved. I think there is some other problem.
            In any case Thank you very much for reply.

            Comment

            Working...
            X