获取错误 - javax.naming.NamingException:远程业务的ejb ref resolution错误interfaceretail.ejb.service.CustomerSessionBeanRemote

时间:2013-04-22 21:34:08

标签: java ejb-3.0 glassfish-3

从jsf应用程序调用ejb时出现以下错误

javax.naming.NamingException: ejb ref resolution error for remote business interfaceretail.ejb.service.CustomerSessionBeanRemote [Root exception is java.lang.ClassNotFoundException: retail.ejb.service.CustomerSessionBeanRemote]

这是下面的代码。

接口:CustomerSessionBean

package retail.ejb.service;

import retail.model.vo.Customer;

public interface CustomerSessionBean {
    public void insterCustomerDetails(Customer customer);

}


package retail.ejb.service;



import javax.ejb.Remote;

import retail.model.vo.Customer;

@Remote
public interface CustomerSessionBeanRemote extends CustomerSessionBean{

    void insterCustomerDetails(Customer customer);


}


package retail.ejb.service;



import javax.ejb.Local;

import retail.model.vo.Customer;

@Local
public interface CustomerSessionBeanLocal extends CustomerSessionBean{
    void insterCustomerDetails(Customer customer);
}


package retail.ejb.service;

import javax.ejb.Stateless;

import retail.model.vo.Customer;

@Stateless(name="CustomerSessionBeanImpl", mappedName="ejb/CustomerSessionBeanImplJNDI") 
public class CustomerSessionBeanImpl implements CustomerSessionBeanRemote,CustomerSessionBeanLocal,CustomerSessionBean{



    @Override
    public void insterCustomerDetails(Customer customer) {
        // TODO Auto-generated method stub
        System.out.println("Customer object ::::" + customer);

    }

}


    package retail.web.mbean;

import java.io.Serializable;
import java.util.Properties;

import javax.faces.bean.ManagedBean;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;


import retail.ejb.service.CustomerSessionBeanRemote;
import retail.model.vo.Customer;


@ManagedBean
public class CustomerMB implements Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = -4402277663508618618L;
    private Customer customer = new Customer();
    public void CustomerMB(){
        System.out.println("customer method +++++++++++++++++++++++"+getCustomer());
    }




public Customer getCustomer() {
    return customer;
}



public void setCustomer(Customer customer) {
    this.customer = customer;
}



public String createCustomer() throws NamingException{
    try{
    System.out.println("in Create customer method +++++++++++++++++++++++");
    Properties p = new Properties();
    //properties.put("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
    p.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.impl.SerialInitContextFactory");
    p.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
    p.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
    p.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
    p.setProperty("org.omg.CORBA.ORBInitialPort", "3700"); //any configured port different from 3700 - 34513
    InitialContext c = new InitialContext(p);
    CustomerSessionBeanRemote remote = (CustomerSessionBeanRemote) c.lookup("ejb/CustomerSessionBeanImplJNDI");
    remote.insterCustomerDetails(getCustomer());
    }catch(Exception e){
        e.printStackTrace();
    }
    //System.exit(1);
    return "viewCustomerDetails";
}

}


Caused by: javax.naming.NamingException: ejb ref resolution error for remote business interfaceretail.ejb.service.CustomerSessionBeanRemote [Root exception is java.lang.ClassNotFoundException: retail.ejb.service.CustomerSessionBeanRemote]
    at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:433)
    at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:75)
    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
    at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:556)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514)
    ... 43 more
Caused by: java.lang.ClassNotFoundException: retail.ejb.service.CustomerSessionBeanRemote
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
    at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:687)
    at com.sun.ejb.EJBUtils.loadGeneratedRemoteBusinessClasses(EJBUtils.java:462)
    at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:413)
    ... 47 more

请建议任何人

1 个答案:

答案 0 :(得分:0)

可能的原因可能是

EJB 3.0规范警告Applications that use mappedNames may not be portable 这是否在没有mappedNames或查找完全限定的bean名称的情况下工作?

您可以在Glassfish日志中看到bean的可移植名称,而不是使用该名称。