线程" main"中的例外情况java.lang.IllegalStateException:EJBCLIENT000025:没有可用的EJB接收器

时间:2016-10-22 06:55:36

标签: ejb jndi

我创建了一个EJB项目和另一个项目来测试第一个项目。 这个screenshot概述了我的两个项目。 测试项目的主要课程是:



public class TestEjb 
{
	public static void main(String[] args) 
	{
		GestionEmployeeRemote gestion = null;
		try {
			Properties jndiProperties = new Properties(); 
                        jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); 
		        Context context = new InitialContext(jndiProperties);
			Object o = context.lookup("ejb:/FirstEJBProject/GestionEmployee!services.GestionEmployeeRemote");
			gestion = (GestionEmployeeRemote) o;
		} catch (NamingException e) {
			e.printStackTrace();
		}
		createEmployee(gestion);
	}

	public static void createEmployee(GestionEmployeeRemote gestion)
	{
		Employee employee = new Employee("Foulen", "Ben Foulen", new Date(), "Directeur");
		gestion.createEmployee(employee);
	}
	




jndi.properties 文件是:



java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=remote://localhost:4447
jboss.naming.client.ejb.context=true
jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false




班级 GestionEmployee.java 是:



package services;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import persistance.Employee;

/**
 * Session Bean implementation class GestionEmployee
 */
@Stateless
public class GestionEmployee implements GestionEmployeeRemote, GestionEmployeeLocal {

    @PersistenceContext
    EntityManager em;
    public GestionEmployee() {
        // TODO Auto-generated constructor stub
    }

	@Override
	public void createEmployee(Employee employee) {
		em.persist(employee);
		
	}

	@Override
	public void updateEmployee(Employee employee) {
		em.merge(employee);
		
	}

	@Override
	public void deleteEmployee(Employee employee) {
		em.remove(employee);
		
	}

	@Override
	public Employee getEmployeeById(int idEmployee) {
		Employee elmployee = em.find(Employee.class, idEmployee);
		return null;
	}

	@Override
	public List<Employee> getAllEmployee() {
		Query query = em.createQuery("select e from Employee e");
		return query.getResultList();
	}

}
&#13;
&#13;
&#13;

GestionEmployeeRemote.java 这个类是:

&#13;
&#13;
package services;

import java.util.List;

import javax.ejb.Remote;

import persistance.Employee;

@Remote
public interface GestionEmployeeRemote
{
	public void createEmployee (Employee employee);
	public void updateEmployee (Employee employee);
	public void deleteEmployee (Employee employee);
	public Employee getEmployeeById (int idEmployee);
	public List<Employee> getAllEmployee();
}
&#13;
&#13;
&#13;

运行class main之后,我收到了这个错误:

  

线程中的异常&#34; main&#34; java.lang.IllegalStateException:EJBCLIENT000025:没有EJB接收器可用于处理调用上下文的[appName:,moduleName:FirstEJBProject,distinctName:]组合org.jboss.ejb.client.EJBClientInvocationContext@a47962       在org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:749)       at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)       在org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183)       在org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:253)       在org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:198)       在org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:181)       在org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144)       at com.sun.proxy。$ Proxy0.createEmployee(Unknown Source)       at test.TestEjb.createEmployee(TestEjb.java:37)       在test.TestEjb.main(TestEjb.java:31)

我正在寻找这个问题的解决方案,感谢任何帮助。非常感谢。

0 个答案:

没有答案