写Ejb类的一点儿见解

今天在工作中根据业务名称写了一套Ejb的类,可总是报Web与Ejb类Not Bound。

找了半天也没找到原因,后来根据经验猜测是Ejb对敏感类名的问题,试着修改类名后搞定了,

import java.rmi.RemoteException;
import java.util.List;

import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

import com.zznode.inms.report.dao.NnProvinceCoreRouterDao;
import com.zznode.inms.report.service.INnProvinceCoreRouterService;

/**
 * XDoclet-based session bean.  The class must be declared
 * public according to the EJB specification.
 *
 * To generate the EJB related files to this EJB:
 *		- Add Standard EJB module to XDoclet project properties
 *		- Customize XDoclet configuration for your appserver
 *		- Run XDoclet
 *
 * Below are the xdoclet-related tags needed for this EJB.
 * 
 * @ejb.bean name="NnProvinceCoreRouter"
 *           display-name="Name for NnProvinceCoreRouter"
 *           description="Description for NnProvinceCoreRouter"
 *           jndi-name="ejb/NnProvinceCoreRouter"
 *           type="Stateless"
 *           view-type="both"
 */
public class NnProvinceCoreRouterBean implements SessionBean,INnProvinceCoreRouterService {

	private SessionContext context;
	private NnProvinceCoreRouterDao nnProvinceCoreRouterDao;
	
	
	public NnProvinceCoreRouterBean() {
		super();
		nnProvinceCoreRouterDao = nnProvinceCoreRouterDao.getInstance();
	}
	
	public void ejbActivate() throws EJBException, RemoteException {
	}

	public void ejbPassivate() throws EJBException, RemoteException {
	}

	public void ejbRemove() throws EJBException, RemoteException {
	}

	public void setSessionContext(SessionContext newContext) throws EJBException,RemoteException {
		context = newContext;
	}

	/**
     *  @ejb.interface-method view-type = "both"
     * */
	public List findNnProvinceCoreRouter(String year, String month) {
		return nnProvinceCoreRouterDao.getNnProvinceCoreRouter(year, month);
	}

}


我第一次的类名是: NotProvinceCoreRouterBean.java

解决办法: NotProvinceCoreRouterBean.java 改成 NnProvinceCoreRouterBean.java 即可。


【注】:在编写Ejb的Bean类是尽量不要写以Not开头的类名。

你可能感兴趣的:(java,DAO,bean,Web,ejb)