2013-04-22 49 views
0

IAM从JSF应用程序收到错误 - javax.naming.NamingException中:为远程业务EJB参考解析错误interfaceretail.ejb.service.CustomerSessionBeanRemote

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

这里调用EJB时​​,下面让下面错误的代码。

接口: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 

请建议人

+0

@downvoters - 尝试对downvoting进行评论,这样可以帮助其他人 – developer 2013-04-23 04:36:20

回答

0

一个可能的原因可能是

EJB 3.0规范警告Applications that use mappedNames may not be portable 这是工作没有mappedNames或通过查找全合格的bean名字?

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