0

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);

    }

}


パッケージ小売.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

誰か提案してください

4

1 に答える 1

0

考えられる理由としては

EJB 3.0 仕様の警告Applications that use mappedNames may not be portable これは、mappedNames なしで、または完全修飾 Bean 名を検索することによって機能しますか?

Glassfish ログで Bean の移植可能な名前を確認できます。代わりにその名前を使用してください。

于 2013-04-25T03:12:33.503 に答える